top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

static library unresolved symbols compiled using gcc

0 votes
482 views

I'm inspecting a static library with nm, and I see that the tool provides me with the unresolved symbols of a file foo.o even though those symbols are defined in file zoo.o and both are included in the static library (ar rcs libmy.a zoo.o foo.o).

How can I ask nm to resolve these symbols if they can be found within the files of the archive and just report me about the other not resolved?

posted Jun 18, 2013 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

As far as I know there is no way to do that directly.

You can do it indirectly by doing

ld -r -o foo.o --whole-archive foo.a
nm -u foo.o

answer Jun 18, 2013 by anonymous
Similar Questions
0 votes

When I was building GCC, I found out that stage1-gcc is not compiled with optimization (such as -O2). So the compilation of stage2 is very slow. Is this intended or not? If not, did I made some mistakes in configure options and caused this?

0 votes

My static library is present on path /root/xxx/lib and contains libabc.a libefg.a liblmn.a file and my shared library is present in /root/xxx named as libshared.so

I want to link shared library with static library. Please share the gcc command for the same.

+1 vote

I wonder how one could get the compiler to generate the "movdqu" instruction, since the vector extensions always seem to assume that everything will be aligned to 16 byte.
I tried using a packed struct and this dint help much. Of course one can always resort to inline assembly but this should not be necessary

Compile with:

gcc -O2 -S -msse2 testvecs.c

Using built-in specs.

COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i486-linux-gnu/4.7/lto-wrapper
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.7.2-5' 
--with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs 
--enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr 
--program-suffix=-4.7 --enable-shared --enable-linker-build-id 
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext 
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu 
--enable-libstdcxx-debug --enable-libstdcxx-time=yes 
--enable-gnu-unique-object --enable-plugin --enable-objc-gc 
--enable-targets=all --with-arch-32=i586 --with-tune=generic 
--enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu 
--target=i486-linux-gnu
Thread model: posix
gcc version 4.7.2 (Debian 4.7.2-5)
...