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

x86_64 support requires -fPIC #7

Closed
razvand opened this issue Nov 19, 2010 · 2 comments
Closed

x86_64 support requires -fPIC #7

razvand opened this issue Nov 19, 2010 · 2 comments

Comments

@razvand
Copy link

razvand commented Nov 19, 2010

Compiling libutp under a Linux running on a x86_64 architecture results in the error below:

g++ -Wall -ansi --shared -o libutp.so -g utp.cpp utp_utils.cpp -DPOSIX -I . -I utp_config_lib -lrt -fno-exceptions -fno-rtti
/usr/bin/ld: /tmp/ccglGf8u.o: relocation R_X86_64_32 against `.text' can not be used when making a shared object; recompile with -fPIC
/tmp/ccglGf8u.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [libutp.so] Error 1

The solution is adding -fPIC when using getting libutp.so in the root Makefile, as in the diff below:

--- makefile.old    2010-11-19 18:33:24.000000000 +0200
+++ makefile    2010-11-19 18:33:09.000000000 +0200
@@ -15 +15 @@
-   g++ -Wall -ansi --shared -o libutp.so -g $(utp) -DPOSIX -I . -I utp_config_lib $(libs) $(cflags)
+   g++ -Wall -ansi -fPIC --shared -o libutp.so -g $(utp) -DPOSIX -I . -I utp_config_lib $(libs) $(cflags)
@ghazel
Copy link
Contributor

ghazel commented Nov 19, 2010

And -fPIC works on x86 (32bit) architectures as well?

@razvand
Copy link
Author

razvand commented Nov 19, 2010

Yes, it works. See below:

razvan@anaconda:/tmp/libutp$ make
g++ -Wall -ansi -fPIC --shared -o libutp.so -g utp.cpp utp_utils.cpp -DPOSIX -I . -I utp_config_lib -lrt -fno-exceptions -fno-rtti
razvan@anaconda:/tmp/libutp$ ls -l libutp.so 
-rwxr-xr-x 1 razvan razvan 93195 Nov 19 23:33 libutp.so
razvan@anaconda:/tmp/libutp$ file libutp.so 
libutp.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, not stripped
razvan@anaconda:/tmp/libutp$ uname -a
Linux anaconda 2.6.26-2-686 #1 SMP Thu Aug 19 03:44:10 UTC 2010 i686 GNU/Linux

This issue was closed.
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