Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compilation of python-bindings on ubuntu #18

Closed
molsim opened this issue Apr 18, 2017 · 4 comments
Closed

compilation of python-bindings on ubuntu #18

molsim opened this issue Apr 18, 2017 · 4 comments

Comments

@molsim
Copy link

molsim commented Apr 18, 2017

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
Copy link
Owner

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

@molsim
Copy link
Author

molsim commented Apr 18, 2017

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
Copy link
Owner

mittinatten commented Apr 18, 2017

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
Copy link
Author

molsim commented Apr 18, 2017

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

@molsim molsim closed this as completed Apr 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants