Note. Despite mentioning Python in the following, I have a good chance that my problem is not related to Python at all. If I'm not mistaken, the βmoduleβ I mention is equivalent to the C library - at least for the problems of my problem.
In Debian, I am trying to create a Python module with C, which in turn uses GSL. The following Makefile successfully compiles it:
CC = gcc -Wall -fPIC -O3 NAME = meinzeug matrizenwuerfler: $(SRC) $(CC) -o $(NAME).o -I/usr/lib/python2.5/site-packages/numpy/core/include -I/usr/include/python2.5 -c $(NAME).c $(CC) -shared -o $(NAME).so -lgsl -lgslcblas -lm $(NAME).o
Since this module is supposed to be used (Linux), among others, I want GSL to be included in the module (or sent along with it).
However, if I add -static as an option to the last line of the Makefile, I get the following error:
gcc -Wall -fPIC -O3 -shared -static -o meinzeug.so -lgsl -lgslcblas -lm meinzeug.o /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.3.2/crtbeginT.o: relocation R_X86_64_32 against `__DTOR_END__' can not be used when making a shared object; recompile with -fPIC /usr/lib/gcc/x86_64-linux-gnu/4.3.2/crtbeginT.o: could not read symbols: Bad value collect2: ld returned 1 exit status
Adding -Wl,-Bstatic before the library associates the results with another error:
gcc -Wall -fPIC -O3 -shared -o meinzeug.so -Wl,-Bstatic -lgsl -lgslcblas -lm meinzeug.o /usr/bin/ld: cannot find -lgcc_s collect2: ld returned 1 exit status
Other stuff that didn't work: recompiling GSL with fPIC, -static-libgcc, permutation of parameters. What I have not tried yet is to compile gcc with fPIC or similar.
source share