Forum Discussion
Altera_Forum
Honored Contributor
16 years agoProblem building C++ shared library
I am using uClinux-dist with MMU and the gcc 4.1.2 binary toolchain, and I am having a problem with g++ when building a shared library.
A test:#include <stdio.h>
int main(void)
{
printf("hello world\n");
} gcc build works: $ /data/nios/nios2-linux/toolchain-mmu/x86-linux2/bin/nios2-linux-gnu-gcc -DEMBED -mhw-mul -mno-hw-mulx -mno-hw-div -shared -o hello.c.o -c /data/nios/hello.c
$ /data/nios/nios2-linux/toolchain-mmu/x86-linux2/bin/nios2-linux-gnu-gcc -mhw-mul -mno-hw-mulx -mno-hw-div -shared -Wl,-soname,libhelloworldc.so -o libhelloworldc.so hello.c.o Same thing, with g++: $ /data/nios/nios2-linux/toolchain-mmu/x86-linux2/bin/nios2-linux-gnu-g++ -DEMBED -mhw-mul -mno-hw-mulx -mno-hw-div -shared -o hello.c.o -c /data/nios/hello.c
$ /data/nios/nios2-linux/toolchain-mmu/x86-linux2/bin/nios2-linux-gnu-g++ -mhw-mul -mno-hw-mulx -mno-hw-div -shared -Wl,-soname,libhelloworldc.so -o libhelloworldc.so hello.c.o
/data/nios/nios2-linux/toolchain-mmu/x86-linux2/bin/../lib/gcc/nios2-linux-gnu/4.1.2/../../../../nios2-linux-gnu/bin/ld: fde encoding in hello.c.o(.eh_frame) prevents .eh_frame_hdr table being created. The library actually gets created, but a program using a C++ library built like this gives a SEGV on start. If I build a C++ helloworld executable using g++ and make sure not to use the "-shared" option, then it works. Ideas?4 Replies
- Altera_Forum
Honored Contributor
Hi,
Would you please give me some information by setting
. And please try the switch '-fPIC', if possible. Kazuecho 1 > /proc/sys/kernel/print-fatal-signals - Altera_Forum
Honored Contributor
Looks like the problem I am running into is not because of this warning. helloworld works with -fPIC although I still get the linker warnings.
- Altera_Forum
Honored Contributor
OK, I accidentally covered this up before, but I think this is my real problem in addition to the .eh_frame_hdr table warnings. I can't reproduce this with helloworld, but when I build my executable that uses two C++ shared libraries, I get:
UPDATE: The .eh_frame_hdr warnings seem to be hiding actual link errors. Adding -lgcc -lc to my libraries got me past that error./data/nios/nios2-linux/toolchain-mmu/x86-linux2/bin/../lib/gcc/nios2-linux-gnu/4.1.2/../../../../nios2-linux-gnu/bin/ld: testserver: hidden symbol `__divsi3_table' in /data/nios/nios2-linux/toolchain-mmu/x86-linux2/bin/../lib/gcc/nios2-linux-gnu/4.1.2/libgcc.a(lib2-divtable.o) is referenced by DSO /data/nios/nios2-linux/toolchain-mmu/x86-linux2/bin/../lib/gcc/nios2-linux-gnu/4.1.2/../../../../nios2-linux-gnu/bin/ld: final link failed: Nonrepresentable section on output - Altera_Forum
Honored Contributor
Hi,
About the error 'hidden symbol...', please visit the next site http://www.xastir.org/wiki/index.php/howto:ubuntu_6.10 and refer the 'Work around a bug in libeotiff's configure script' term. Kazu