nativeclient ld libstdc++.so.6: invalid DSO for symbol - libstdc++

I'm trying to build a native client application using SDL, and a link error had me stumped. This is the simplest command line that reproduces the error. Has anyone seen this before?
\# nacl_sdk/pepper_25/toolchain/linux_x86_glibc/bin/i686-nacl-gcc -m64 nacl_glue.cc -lSDL -lppapi_cpp
/home/rob/nacl_sdk/pepper_25/toolchain/linux_x86_glibc/bin/../lib/gcc/x86_64-nacl/4.4.3/../../../../x86_64-nacl/bin/ld: /home/rob/nacl_sdk/pepper_25/toolchain/linux_x86_glibc/bin/../x86_64-nacl/lib/libstdc++.so.6: invalid DSO for symbol `std::_List_node_base::hook(std::_List_node_base*)##GLIBCXX_3.4' definition
/home/rob/nacl_sdk/pepper_25/toolchain/linux_x86_glibc/bin/../x86_64-nacl/lib/libstdc++.so.6: could not read symbols: Bad value
collect2: ld returned 1 exit status

I need to use i686-nacl-g++ instead of i686-nacl-gcc.
Digging around a little online, it looks like GCC shouldn't link in the c++ standard library, but my error message looks a little more like it IS linking in the c++ standard library, but is not understanding the symbols it is finding. Weird, but whatever.

Related

What does "ld: mach-o string pool extends beyond end of file" mean?

I am currently trying to make and install a specialist suite of software (https://github.com/scottransom/presto), and am encountering this error:
gfortran -g -fPIC -o /path-to/presto/bin/psrorbit powerplot.o xyline.o psrorbit.o -L/usr/local/Cellar/cfitsio/3.450/lib -lcfitsio -lcurl -L/path-to/presto/lib -lpresto -L/usr/local/lib -lfftw3f -L/usr/local/lib/pgplot -lcpgplot -lpgplot -L/opt/X11/lib -lX11 -L/opt/X11/lib -lpng16 -lm
ld: mach-o string pool extends beyond end of file in /usr/local/lib/libcpgplot.dylib file '/usr/local/lib/libcpgplot.dylib' for architecture x86_64
collect2: error: ld returned 1 exit status
make: *** [psrorbit] Error 1
I don't think it's a problem related to PRESTO per se, as several searches (see this, this, and this) point to something fundamental, perhaps with Xcode. I currently have version 11.3, and I also installed the command line tools. So again, what does the error itself mean? Any help would be useful!
According to my reading of the source code for Apple's version of ld, this error means that the symbol table in an object prematurely ends when the file does.
There appear to be quite a few sanity checks performed on object files when linking. Likely, your copy of /usr/local/lib/libcpgplot.dylib is corrupt.

Linker error: access beyond end of merged section

I've built my code on a machine with gcc 6.3 before. I'm building the same code on another machine with gcc 5.3. I tried using the working oed library from a different location. But still the error persists. I went through suggestions in other questions similar to this on Stackoverflow, but they suggest that the library must be already linked. This is not the case though.
Oed is a fortran library and the code is in C and C++.
I'm at a loss to think how to figure out this problem. Any help is welcome.
/usr/bin/ld: oed__gener_nai_batch.o: access beyond end of merged section (380)
/usr/bin/ld: oed__gener_nai_batch.o: access beyond end of merged section (586)
/usr/bin/ld: oed__gener_nai_batch.o: access beyond end of merged section (580)
/usr/bin/ld: /home/umunipala/gamess/gamess-kris-simgms/simgms/oed/liboed.a(oed__gener_nai_batch.o)(.debug_info+0x203): reloc against `.debug_str': error 2
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
Well, there are two solutions I think.
recompile the .c file with your current library settings.
export a corresponded version LD library.
The problem is basically caused by the disagreement between .o file and your gcc(compiler).

fglut/libfglut.a(freeglut_state.o): undefined reference to symbol 'XGetWindowAttributes'

I am compiling a C++ program using make, this is the error i'm getting.
/usr/bin/ld: fglut/libfglut.a(freeglut_state.o): undefined reference to symbol 'XGetWindowAttributes'
//usr/lib/i386-linux-gnu/libX11.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:55: recipe for target 'morphlines' failed
make: *** [morphlines] Error 1
I'm beginner
/usr/bin/ld: fglut/libfglut.a(freeglut_state.o):
This tells me you link libfglut statically (*.a is just an archive of object files). When you do this, you must link all dependencies as well, because with the object files from the static library actually compiled into your program, your program will depend on them.
Either link libfglut dynamically (this is the default with the GNU toolchain), so your program will depend on libfglut.so which will itself depend on libX11.so -- or add -lX11 after -lfglut on the command line of your final linking step. You might need -Wl,-Bdynamic before -lX11 to switch the linker back to dynamic linking.
If this doesn't directly solve your problem, I suggest you edit your question to include the relevant parts of the Makefile you're using.

linker error hidden symbol `__popcountdi2'

I'm building an application that results in the following error:
hidden symbol `__popcountdi2' in /usr/lib/gcc/x86_64-redhat-linux/4.8.3/libgcc.a(_popcountsi2.o) is referenced by DSO
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
This can be fixed with '-shared-libgcc' linked option, but I would like to understand the issue and what is causing it. Also it appears that others don't observe the issue, although we all run the same Linux distribution (Fedora 20), the same tools and libraries (gcc-4.8.3-7.fc20.x86_64, libgcc-4.8.3-7.fc20.x86_64 and binutils-2.23.88.0.1-13.fc20.x86_64), so I suspect there's something wrong with my platform, may be some libs are missing etc.
I would appreciate if someone could give hints to understand what is going on. Thanks.

What does the compile-time error "Undefined symbols for architecture x86_64" mean?

I'm trying to program a graph class using an adjacent list from an example in my C++ text book, and when I compile using this command:
Code:
g++ -o prog program.cpp
...I get the following error:
Undefined symbols for architecture x86_64:
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
... what in the world does this mean? It may turn out to be an issue with my code, but I feel like it may be deeper than that, because I've gotten this same seemingly inexplicable error for several different projects, many of which were solved in different ways, and unfortunately completely by accident.
I read somewhere that it may have to do with whether I'm using 32 bit or 64 bit libraries, and that the tags -m32 or -m64 may need to be used, but I'm not sure if this applies here. Interestingly enough, when I tried adding the -m64 tag I got the same exact error, but when I tried using the -m32 tag I got the same error, except it said
Undefined symbols for architecture i386:
"_main", referenced from:
start in crt1.10.6.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
instead.
Mainly I just want to know what in the world the error is saying. I'm used to debugging compile-time errors that give a specific line in the code, etc., but I can't discern anything like that from this. Any ideas?
If it helps, I'm using a late 2008 Macbook with Intel Core 2 Duo, (so 64-bit), and I'm running OS X Lion (10.7.2), which I think is the latest version. Also, I'm using gcc version 4.2.1.
When you compile the file, the compiler invokes the linker which tries to generate an executable. But it cannot because you didn't provide a function named main which is the function that will be executed when your program is launched.
Either you don't want to run the linker because you want to compile several files separately then combine then. In that case, use the -c flag to tell the compiler to skip the link stage.
Or either you want to execute the compiled file. Then you need to implement the function main.

Resources