': relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC'

6,602 views
Skip to first unread message

Anders Branderud

unread,
Feb 20, 2012, 11:35:17 AM2/20/12
to ns-3-...@googlegroups.com
Hello,
Since I cannot get it to work with linking in the openfec.so-file and since no one has
been able to help (I am still hoping someone can help!), I am trying another approach. I am now linking the files of the OpenFEC-library separately into src/applications/wafscript

I now get this error:
'/usr/bin/ld: src/applications/openfec/lib_common/of_openfec_api.c.1.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
src/applications/openfec/lib_common/of_openfec_api.c.1.o: could not read symbols: Bad value
collect2: ld returnerade avslutningsstatus 1'

What should I do to solve this error?
When I Googled I found that the problem is solved by doing this: 'exporting the -fPIC flags to the CC and CXX environmental variables'.
How do I tell WAF to use -fPIC-flags?

Thanks!

-- Kind regards, Anders

[Personal blog] Will of the Creator  : Logical reasons - based on scientific premises - for the existence of a Super intelligent and Orderly Creator and that He hasn't left His sapient creatures without an Instruction Manual - Torah ['books of Moses'] - to ascertain, and aspire to, His purpose.

[Company] Anders Branderud IT Solutions - www.abitsolutions.org

Anders Branderud

unread,
Feb 20, 2012, 1:53:20 PM2/20/12
to ns-3-users
Hello,
I tried to add the following code to the wscript of the src/
applications-directory, but it still doesn't work:
'module.env.append_value('CXXFLAGS', ["-fPIC"])
module.env.append_value('CCFLAGS', ["-fPIC"])
module.env.append_value('LINKFLAGS', ["/usr/lib/libopenfec.so"])'

I built the program with 'sudo CXXFLAGS_EXTRA="-fPIC" ./WAF

On 20 Feb, 18:35, Anders Branderud <anders.brande...@gmail.com> wrote:
> Hello,
> Since I cannot get it to work with linking in the openfec.so-file and since
> no one has
> been able to help (I am still hoping someone can help!), I am trying
> another approach. I am now linking the files of the OpenFEC-library
> separately into src/applications/wafscript
>
> I now get this error:
> '/usr/bin/ld: src/applications/openfec/lib_common/of_openfec_api.c.1.o:
> relocation R_X86_64_32 against `.rodata' can not be used when making a
> shared object; recompile with -fPIC
> src/applications/openfec/lib_common/of_openfec_api.c.1.o: could not read
> symbols: Bad value
> collect2: ld returnerade avslutningsstatus 1'
>
> What should I do to solve this error?
> When I Googled I found that the problem is solved by doing this: 'exporting
> the -fPIC flags to the CC and CXX environmental variables'.
> How do I tell WAF to use -fPIC-flags?
>
> Thanks!
>
> -- *Kind regards, Anders
> *
>
> [Personal blog] Will of the
> Creator<http://www.proofexistencegod.com/will-of-god/will-of-god/>  :

Mathieu Lacage

unread,
Feb 21, 2012, 1:55:32 AM2/21/12
to ns-3-...@googlegroups.com, ns-3-...@googlegroups.com
-mcmodel=large ?

Envoyé de mon iPad
--
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To post to this group, send email to ns-3-...@googlegroups.com.
To unsubscribe from this group, send email to ns-3-users+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ns-3-users?hl=en.

Anders Branderud

unread,
Feb 21, 2012, 7:21:30 AM2/21/12
to ns-3-users
Hello!

I tried this:
sudo CXXFLAGS_EXTRA="-mcmodel=large" ./waf

I got this error report:
/usr/bin/ld: src/applications/openfec/lib_common/of_openfec_api.c.1.o:
relocation R_X86_64_32 against `.rodata' can not be used when making a
shared object; recompile with -fPIC
src/applications/openfec/lib_common/of_openfec_api.c.1.o: could not
read symbols: Bad value
collect2: ld returnerade avslutningsstatus 1


On 21 Feb, 08:55, Mathieu Lacage <mathieu.lac...@gmail.com> wrote:
> -mcmodel=large ?
>
> Envoyé de mon iPad
>

Mathieu Lacage

unread,
Feb 21, 2012, 12:55:07 PM2/21/12
to ns-3-...@googlegroups.com
rm -rf build && CXXFLAGS=... ./waf configure && ./waf

?

But, really, you appear to be trying to build a static version of
ns-3. I do not know which platform you are using but static builds are
rarely tested so, you would be better off using a non-static version.

Mathieu

--
Mathieu Lacage <mathieu...@gmail.com>

Anders Branderud

unread,
Feb 22, 2012, 8:07:24 AM2/22/12
to ns-3-users
Hello!

Thanks!

It worked, but it generated other errors (I think related to the paths
in the c-files.). I could work to solve these errors, but it would be
less work if I succeeded to link the library 'libopenfec.so'.

I tried the command 'sudo LINKFLAGS="/usr/lib/libopenfec.so" ./waf'.
It still didn't find 'of_build_repair_symbol', which is inluded in the
library.
Did I do anything wrong? Or otherwise, why doesn't it work?

Here follows what was printed out in the terminal:
"anders@ubuntu:~/repos/ns3.13-2/ns-allinone-3.13/ns-3.13$ sudo
LINKFLAGS="/usr/lib/libopenfec.so" ./waf
(..)
./libns3-applications.so: undefined reference to
`of_build_repair_symbol(of_session*, void**, unsigned int)'
collect2: ld returnerade avslutningsstatus 1
./libns3-applications.so: undefined reference to
`of_build_repair_symbol(of_session*, void**, unsigned int)'
collect2: ld returnerade avslutningsstatus 1 "

---
I am building this version of NS-3 (http://www.nsnam.org/ns-3-13/
download/) following the instructions of the NS-3-website. My system:
Ubuntu 11
> Mathieu Lacage <mathieu.lac...@gmail.com>

Anders Branderud

unread,
Feb 23, 2012, 1:54:54 PM2/23/12
to ns-3-users
Hello!

I did some changes in the header-files of the library, the 'wafscript'
and linked one more c-file, and then
I compiled the program with this command:
rm -rf build CXXFLAGS="-mcmodel=large" && LINKFLAGS="-lopenfec" ./waf
configure && ./waf

I get this error again:
'/usr/bin/ld: src/applications/lib_common/of_openfec_api.c.1.o:
relocation R_X86_64_32 against `.rodata' can not be used when making a
shared object; recompile with -fPIC
src/applications/lib_common/of_openfec_api.c.1.o: could not read
symbols: Bad value
collect2: ld returnerade avslutningsstatus 1'

What should I do in order to solve this?
Thanks in advance!

Rod Lester Dizon

unread,
Feb 27, 2012, 12:11:38 AM2/27/12
to ns-3-...@googlegroups.com, Виталий Балашов, Mathieu Lacage
Hi Everyone,


I just want to ask if my understanding of how buffer code is called is
correct or not?

First.cc >> >>NodoContainer.cc>>NetDevice.cc>>Packet.cc>>Buffer.cc


Is this correct?


Thanks a lot, I'm really just trying to study how it works but I'm
confused right now XD


Regards,
Rod Lester Dizon

paszcior

unread,
Mar 9, 2012, 1:34:50 PM3/9/12
to ns-3-...@googlegroups.com
Hello Anders,

I had a problem similar to yours (https://groups.google.com/d/msg/ns-3-users/Lm0M4GKaxW0/8sL6r9QDQcIJ) and I fixed it by using "--enable-static" option during configuration. I'm not sure if it helps in your case, though.

Juan Martinez

unread,
Dec 24, 2013, 6:39:11 PM12/24/13
to ns-3-...@googlegroups.com, anders.b...@gmail.com, xd...@live.com

/usr/bin/ld: .libs/libmist_1_0_la-amf.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
.libs/libmist_1_0_la-amf.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[1]: *** [libmist-1.0.la] Error 1
make[1]: Leaving directory `/home/encoder2/libmist/libmist-6.1.0/lib'
make: *** [install-recursive] Error 1
Reply all
Reply to author
Forward
0 new messages