On Mon, Oct 21, 2013 at 7:40 PM, GHui <ugiwgh@xxxxxxxxx> wrote: > > I tried to add "-shared". It succeed to compile. That is not surprising, as when using -shared the linker will not complain about undefined symbols. > The following is the log > ---------------------------- > [root@dev libgomp]# /root/JULY/gcc-4.8.1/build/./gcc/xgcc -L/lib64 -L/usr/lib64 -B/root/JULY/gcc-4.8.1/build/./gcc/ -B/usr/local/gcc-4.8.1/x86_64-redhat-linux/bin/ -B/usr/local/gcc-4.8.1/x86_64-redhat-linux/lib/ -isystem /usr/local/gcc-4.8.1/x86_64-redhat-linux/include -isystem /usr/local/gcc-4.8.1/x86_64-redhat-linux/sys-include -g -O2 conftest.c -v > Reading specs from /root/JULY/gcc-4.8.1/build/./gcc/specs > COLLECT_GCC=/root/JULY/gcc-4.8.1/build/./gcc/xgcc > COLLECT_LTO_WRAPPER=/root/JULY/gcc-4.8.1/build/./gcc/lto-wrapper > Target: x86_64-redhat-linux > Configured with: ../configure --prefix=/usr/local/gcc-4.8.1 --enable-FEATURE=yes --with-gmp=/usr/local/gmp-4.3.2 --with-mpfr=/usr/local/mpfr-2.4.2 --with-mpc=/usr/local/mpc-0.8.1/ --disable-multilib --build=x86_64-redhat-linux --enable-languages=c,c++ > Thread model: posix > gcc version 4.8.1 (GCC) > COLLECT_GCC_OPTIONS='-L/lib64' '-L/usr/lib64' '-B' '/root/JULY/gcc-4.8.1/build/./gcc/' '-B' '/usr/local/gcc-4.8.1/x86_64-redhat-linux/bin/' '-B' '/usr/local/gcc-4.8.1/x86_64-redhat-linux/lib/' '-isystem' '/usr/local/gcc-4.8.1/x86_64-redhat-linux/include' '-isystem' '/usr/local/gcc-4.8.1/x86_64-redhat-linux/sys-include' '-g' '-O2' '-v' '-mtune=generic' '-march=x86-64' > /root/JULY/gcc-4.8.1/build/./gcc/cc1 -quiet -v -iprefix /root/JULY/gcc-4.8.1/build/gcc/../lib/gcc/x86_64-redhat-linux/4.8.1/ -isystem /root/JULY/gcc-4.8.1/build/./gcc/include -isystem /root/JULY/gcc-4.8.1/build/./gcc/include-fixed -isystem /usr/local/gcc-4.8.1/x86_64-redhat-linux/include -isystem /usr/local/gcc-4.8.1/x86_64-redhat-linux/sys-include conftest.c -quiet -dumpbase conftest.c -mtune=generic -march=x86-64 -auxbase conftest -g -O2 -version -o /tmp/cco2DRlF.s > GNU C (GCC) version 4.8.1 (x86_64-redhat-linux) > compiled by GNU C version 4.4.4 20100726 (Red Hat 4.4.4-13), GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1 > warning: GMP header version 4.3.2 differs from library version 4.3.1. > GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 > ignoring nonexistent directory "/usr/local/gcc-4.8.1/x86_64-redhat-linux/include" > ignoring nonexistent directory "/usr/local/gcc-4.8.1/x86_64-redhat-linux/sys-include" > ignoring nonexistent directory "/root/JULY/gcc-4.8.1/build/gcc/../lib/gcc/x86_64-redhat-linux/4.8.1/include" > ignoring nonexistent directory "/root/JULY/gcc-4.8.1/build/gcc/../lib/gcc/x86_64-redhat-linux/4.8.1/include-fixed" > ignoring nonexistent directory "/root/JULY/gcc-4.8.1/build/gcc/../lib/gcc/x86_64-redhat-linux/4.8.1/../../../../x86_64-redhat-linux/include" > ignoring nonexistent directory "/root/JULY/gcc-4.8.1/build/gcc/../lib/gcc/../../lib/gcc/x86_64-redhat-linux/4.8.1/include" > ignoring nonexistent directory "/root/JULY/gcc-4.8.1/build/gcc/../lib/gcc/../../include" > ignoring nonexistent directory "/root/JULY/gcc-4.8.1/build/gcc/../lib/gcc/../../lib/gcc/x86_64-redhat-linux/4.8.1/include-fixed" > ignoring nonexistent directory "/root/JULY/gcc-4.8.1/build/gcc/../lib/gcc/../../lib/gcc/x86_64-redhat-linux/4.8.1/../../../../x86_64-redhat-linux/include" > #include "..." search starts here: > #include <...> search starts here: > /root/JULY/gcc-4.8.1/build/./gcc/include > /root/JULY/gcc-4.8.1/build/./gcc/include-fixed > /usr/local/include > /usr/include > End of search list. > GNU C (GCC) version 4.8.1 (x86_64-redhat-linux) > compiled by GNU C version 4.4.4 20100726 (Red Hat 4.4.4-13), GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1 > warning: GMP header version 4.3.2 differs from library version 4.3.1. > GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 > Compiler executable checksum: 9c1c7d7825f2bb1296264af9c01aea4e > COLLECT_GCC_OPTIONS='-L/lib64' '-L/usr/lib64' '-B' '/root/JULY/gcc-4.8.1/build/./gcc/' '-B' '/usr/local/gcc-4.8.1/x86_64-redhat-linux/bin/' '-B' '/usr/local/gcc-4.8.1/x86_64-redhat-linux/lib/' '-isystem' '/usr/local/gcc-4.8.1/x86_64-redhat-linux/include' '-isystem' '/usr/local/gcc-4.8.1/x86_64-redhat-linux/sys-include' '-g' '-O2' '-v' '-mtune=generic' '-march=x86-64' > /root/JULY/gcc-4.8.1/build/./gcc/as -v --64 -o /tmp/cchXesE3.o /tmp/cco2DRlF.s > GNU assembler version 2.20.51.0.2 (x86_64-redhat-linux) using BFD version version 2.20.51.0.2-5.11.el6 20091009 > COMPILER_PATH=/root/JULY/gcc-4.8.1/build/./gcc/ > LIBRARY_PATH=/root/JULY/gcc-4.8.1/build/./gcc/:/lib/../lib64/:/usr/lib/../lib64/:/lib/:/usr/lib/ > COLLECT_GCC_OPTIONS='-L/lib64' '-L/usr/lib64' '-B' '/root/JULY/gcc-4.8.1/build/./gcc/' '-B' '/usr/local/gcc-4.8.1/x86_64-redhat-linux/bin/' '-B' '/usr/local/gcc-4.8.1/x86_64-redhat-linux/lib/' '-isystem' '/usr/local/gcc-4.8.1/x86_64-redhat-linux/include' '-isystem' '/usr/local/gcc-4.8.1/x86_64-redhat-linux/sys-include' '-g' '-O2' '-v' '-mtune=generic' '-march=x86-64' > /root/JULY/gcc-4.8.1/build/./gcc/collect2 --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 /usr/lib/../lib64/crt1.o /usr/lib/../lib64/crti.o /root/JULY/gcc-4.8.1/build/./gcc/crtbegin.o -L/lib64 -L/usr/lib64 -L/root/JULY/gcc-4.8.1/build/./gcc -L/lib/../lib64 -L/usr/lib/../lib64 /tmp/cchXesE3.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /root/JULY/gcc-4.8.1/build/./gcc/crtend.o /usr/lib/../lib64/crtn.o > /usr/lib/../lib64/crt1.o: In function `_start': > (.text+0x12): undefined reference to `__libc_csu_fini' > /usr/lib/../lib64/crt1.o: In function `_start': > (.text+0x19): undefined reference to `__libc_csu_init' > collect2: error: ld returned 1 exit status Thanks. This looks fine. Now we need to find out what file the linker is opening for -lc. To find that out, run the same command with -Wl,-t. Ideally it will not show anything for -lc, but will show that the linker is opening a file like /usr/lib64/libc_nonshared.a. Ian