codon icon indicating copy to clipboard operation
codon copied to clipboard

Generating .so error : /usr/bin/ld: cannot find -lz

Open SM1991CODES opened this issue 1 year ago • 3 comments

Hello, I have a special but simple test case: `@export def show_array(): @python def plot_random_matrix_100x100(): import numpy as np import matplotlib.pyplot as plt

    arr = np.random.random((100,100, 3))
    plt.imshow(arr)
    plt.show()`
  • I am not sure I used the syntax correctly - basically I want this function to be callable from a C++ application.
  • It uses numpy and matplotlib internally, hence the @python is needed.

I get the following error: /usr/bin/ld: cannot find -lz gcc returned with error code 1

Please help.

SM1991CODES avatar Mar 12 '23 20:03 SM1991CODES

Can you try installing zlib? If you're on Ubuntu: sudo apt-get install zlib1g-dev.

arshajii avatar Mar 13 '23 13:03 arshajii

Sure, will try that and let you know. But, is the way I try to use the functionality in C/C++ correct? I am basically trying to use matplotlib from C++ via codon.

SM1991CODES avatar Mar 14 '23 07:03 SM1991CODES

Now I get this error (after installing zlib)

/usr/bin/ld: test_codon.so.o: relocation R_X86_64_32 against `.bss' can not be used when making a shared object; recompile with -fPIC collect2: error: ld returned 1 exit status error: process for 'gcc' exited with status 1

Also tried passing -fPIC to build command: codon build -fPIC -o test_codon.so mpl_test.codon

Seems this is the wrong way.

SM1991CODES avatar Mar 14 '23 07:03 SM1991CODES