libcompat

Hi,
I try to build an old code on 8.1 amd64 with gcc using -lcompat and I get the following message:

Code:
gcc -shared -Xlinker -x -o <lots of files here> -lc -lcrypt -lcompat
/usr/bin/ld: /usr/lib/libcompat.a(ftime.o): relocation R_X86_64_32 can not be used when making a shared object; recompile with -fPIC
/usr/lib/libcompat.a: could not read symbols: Bad value
*** Error code 1
So as I can understand it wants me to rebuild libcompat with -fPIC. How can I do that?
Thanks!
 
-fPIC
If supported for the target machine, emit position-independent code, suitable for dynamic linking and avoiding any limit on the size of the global offset table. This option makes a difference on the m68k, PowerPC and SPARC.
Position-independent code requires special support, and therefore works only on certain machines.

When this flag is set, the macros __pic__ and __PIC__ are defined to 2.
 
I was managed to build it with adding -fPIC in the Makefile but still needs testing whether it works or not.

I read somewhere that shared objects on amd64 must be compiled with this flag anyways.
 
make.conf

Goto /etc/
edit /etc/make.conf
add
Code:
CFLAGS+= -fPIC

or add the same line in your port's Makefile in port directory.
then [cmd=]make clean[/cmd] your port and [cmd=]make install[/cmd] again.
 
i_masoomi said:
Goto /etc/
edit /etc/make.conf
add
Code:
CFLAGS+= -fPIC
Don't be tempted to do this. This will also effect the building of the kernel and world. Something you really don't want to mess with.
 
rebuilding libcompat with -fPIC

Yep, you must have sources on your system, (if otherwise run sysinstall and add sources).

[cmd=]# cd /usr/src/lib/libcompat[/cmd]
[cmd=]# make clean[/cmd]

Edit /usr/src/lib/libcompat/Makefile and add the line
Code:
CFLAGS+= -fPIC

then

[cmd=]# make[/cmd]

This will make all libcompat libraries with the specified flag.

[cmd=]# make install[/cmd]

This will copy newly generated libs to the proper location.

If this does not suffice, manually copy files to your needed location. You can build any library the same way.
 
i_masoomi said:
Yep, you must have sources on your system, (if otherwise run sysinstall and add sources).

[cmd=]# cd /usr/src/lib/libcompat[/cmd]
[cmd=]# make clean[/cmd]

Edit /usr/src/lib/libcompat/Makefile and add the line
Code:
CFLAGS+= -fPIC

then

[cmd=]# make[/cmd]

This will make all libcompat libraries with the specified flag.

[cmd=]# make install[/cmd]

This will copy newly generated libs to the proper location.

If this does not suffice, manually copy files to your needed location. You can build any library the same way.
Yes, I did this way.
 
Back
Top