Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12748 Discussions

Problem building C++ shared library

Altera_Forum
Honored Contributor II
1,304 Views

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?
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
597 Views

Hi,  

 

Would you please give me some information by setting 

echo 1 > /proc/sys/kernel/print-fatal-signals

 

And please try the switch '-fPIC', if possible. 

 

Kazu
0 Kudos
Altera_Forum
Honored Contributor II
597 Views

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.

0 Kudos
Altera_Forum
Honored Contributor II
597 Views

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: 

/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 

 

UPDATE: The .eh_frame_hdr warnings seem to be hiding actual link errors. Adding -lgcc -lc to my libraries got me past that error.
0 Kudos
Altera_Forum
Honored Contributor II
597 Views

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
0 Kudos
Reply