mittinatten / freesasa

C-library for calculating Solvent Accessible Surface Areas
http://freesasa.github.io/
MIT License
105 stars 37 forks source link

compilation of python-bindings on ubuntu #18

Closed molsim closed 7 years ago

molsim commented 7 years ago

On a fresh install of Ubuntu 16.04.2 LTS with ./configure --enable-python-bindings --disable-xml --disable-json make I get the error below - not sure, but configure/autoconf might need some tweeks.


make[2]: Entering directory '/media/freesasa-2.0/bindings' running build_ext building 'freesasa' extension creating build creating build/temp.linux-x86_64-2.7 x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I../../src -I/usr/include/python2.7 -c freesasa.c -o build/temp.linux-x86_64-2.7/freesasa.o -w x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/freesasa.o ../../src/libfreesasa.a -o /media/ubuntu/data/junk/freesasa-2.0/bindings/python/freesasa.so /usr/bin/ld: ../../src/libfreesasa.a(classifier.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC ../../src/libfreesasa.a: error adding symbols: Bad value collect2: error: ld returned 1 exit status error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 Makefile:804: recipe for target 'pylib' failed make[2]: [pylib] Error 1 make[2]: Leaving directory '/media/freesasa-2.0/bindings' Makefile:380: recipe for target 'all-recursive' failed make[1]: [all-recursive] Error 1 make[1]: Leaving directory '/media/freesasa-2.0' Makefile:319: recipe for target 'all' failed make: *** [all] Error 2

mittinatten commented 7 years ago

I think if you add CFLAGS=-fPIC to the configure-script arguments it should work

molsim commented 7 years ago

Yep, this works. I wonder if configure can handle the -fPIC option automatically. I see that by default it is added to the calls that compile freesasa executable, but not the python bindings.

Although on Mac everything compiles without problems, so this is definitely platform specific.

PS my interest in this, is because I use freesasa as a submodule in my project https://github.com/molsim/HYDROID and I try to provide easy to use instructions for compilation.

mittinatten commented 7 years ago

I had the same problem on a Debian system earlier, and the solution is mentioned in the Readme-file already. But maybe the configure script could detect the operating system and add this flag automatically if necessary. Although that might cause problems with other compilers that don't recognize this flag. I will think about it :)

For your repo you could try always using -fPIC (I don't remember now if that works or not in Mac OS X). You should probably include -O2 as well (CFLAGS="-fPIC -O2") for performance.

molsim commented 7 years ago

Now I see the readme:) thank you. On Mac adding CFLAGS="-fPIC -O2" compiles fine.