Help on Compiling on AIX - gcc

Is there a site where I can find the symbols used in a particular library and its version.
For e.g. I m trying to compile some code on AIX using gcc, and it throws me a lot of undefined symbol errors
For example, here is an output:
ld: 0711-317 ERROR: Undefined symbol: .__fixdfdi
ld: 0711-317 ERROR: Undefined symbol: .__divdi3
ld: 0711-317 ERROR: Undefined symbol: .__moddi3
ld: 0711-317 ERROR: Undefined symbol: .__floatdidf
ld: 0711-317 ERROR: Undefined symbol: .__umoddi3
ld: 0711-317 ERROR: Undefined symbol: .__udivdi3
ld: 0711-317 ERROR: Undefined symbol: .__fixunsdfdi
Where do I go to find where these symbols are.
If I run the same gcc command on Linux, it runs fine.
I tried including -lgcc also but then again it throws undefined symbols for some register_frame ...blah blah...
and I m getting sick of AIX.
Any help on this would be appreciated..and please don't bother Googling on this issue.
You will end up no where.
Many have asked this kind of questions but no answers.
Thanks

It's been a long time since I compiled anything on AIX (thankfully) and I do feel your pain having spent a good year or so trying to get our company's JNI and other software libraries built on AIX.
I do seem to remember that GCC never worked particularly well as it always came up with similar errors. Is there any option to use the native compiler (xlC)?
Failing that I would check the ordering of your libraries, it plays a big part in making stuff work properly..
I take it that you have use the nm utility to iterate through every library in /usr/lib (etc) to find where the missing symbols are located?

Those are math symbols. Try adding -lm to your link line.

This is because you used the gcc to compile a library you want to link to a code compiled with xlc. Or at least is my case
You have 2 options:
use the xlc instead of gcc for all the compilation (don't mix gcc and xlc)
compile with xlc but calling also the gcc libraries, for instance:
sudo find / -name libgcc.a
/opt/freeware/lib/gcc/powerpc-ibm-aix6.1.0.0/4.2.0/libgcc.a
/opt/IBM/xlC/13.1.0/bin/xlC -g -o MyBIN MyBIN.o -L/usr/etctera -
L/opt/freeware/lib/gcc/powerpc-ibm-aix6.1.0.0/4.2.0/ -lgcc -letcetera

Mostly questions:
Which version of GCC?
Which version of AIX are you on?
Which version of AIX was your copy of GCC built for?
What exactly is the link line you are using?
I've seen that sort of error when using a version of GCC compiled on a down-version of AIX. For example, if the GCC was compiled for AIX 4.3.3 and is being run on AIX 5.x. Usually, if GCC was compiled on an up-version of AIX, it won't run on the down-version, so that is unlikely to be the problem.
One other (rather unlikely) possibility: is your GCC installed where it was compiled to expect to be installed? When you build it, you specify (possibly implicitly) the install location (by default, under /usr/local). If you have your copy installed somewhere else, but there's an old GCC in /usr/local and your copy expects to be installed in /usr/local, then you can run into this sort of problem. This is much less likely than version mismatching.

Listed external symbols are from libgcc so add of -lgcc is correct. And register_frame also is part of libgcc but only for 32-bit. Check if you use the same bit depth mode for you compiler, linker and libraries.

Related

MSYS2 gcc undefined reference _assert, what library am i missing?

Im trying to link with a game library that has already been compiled using mingw, called Raylib. However; whenever I use MSYS's gcc 10.2 it gives me the following undefined reference error:
gcc main.c -Iraylib-3.7.0_win64_mingw-w64/include -Lraylib-3.7.0_win64_mingw-w64/lib -lraylib -lopengl32 -lgdi32 -lwinmm
/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/bin/ld: raylib-3.7.0_win64_mingw-w64/lib/libraylib.a(core.o):core.c:(.text+0x1f6e): undefined reference to '_assert'
It seems that I maybe missing a library? This is just one of many similar errors. The majority of these undefined references are for assert like the one listed above. Some deal with GLFW and other libraries. Has anyone experienced something like this on MSYS?
Looks like I needed to be directly in MSYS2 mingw64 environment (cmd prompt). I was using the regular MSYS2 MSYS environment.

Boost logging - getting unresolved symbol

I am a novice to cmake and boost so this question might be missing something obvious:
I am building a project with cmake on linux (ubuntu) and I am trying to use boost logging in that project. Here is what I do to generate the Makefile:
rm CMakeCache.txt
cmake ../ -DCMAKE_EXE_LINKER_FLAGS="-lboost_log -lboost_log_setup -lpthread -std=c++11" -DCMAKE_SHARED_LINKER_FLAGS="-lboost_log_setup -lboost_log -lpthread" -DCMAKE_MODULE_LINKER_FLAGS="-lboost_log_setup -lboost_log -lpthread" -DCMAKE_CXX_FLAGS="-DBOOST_LOG_DYN_LINK -std=c++11"
Compile goes through fine. (Some of these flags may be overkill -- I should only need the CMAKE_EXE_LINKER_FLAGS).
When I run the executable, I get the following unresolved reference:
-- ImportError: /home/mranga/gr-msod-sensor/gr-msod_sensor/build/lib/libgnuradio-msod_sensor.so: undefined symbol: _ZN5boost3log11v2_mt_posix3aux25unhandled_exception_countEv
What flags am I missing? My boost library is set up and LD_LIBRARY_PATH points to the right location.
When I manually built a test program using the same linker flags, it compiles and runs fine so boost is installed correctly. I hope I have not missed the obvious.
(Moved question from the GNU Radio mailing list -- sorry if you are reading this post for a second time).
I believe the order of libraries in the linker command line in -DCMAKE_EXE_LINKER_FLAGS is incorrect. boost_log_setup depends on boost_log, so boost_log_setup should go first.
You seem to be linking against the non-multithreaded version:
-lboost_log
but the run-time linker seems to explicitely look for the multithreaded variant (the Boost doc site on that):
_ZN5boost3log11v2_mt_posix3aux25unhandled_exception_countEv
^^
My guess hence is that you should try linking with
-lboost_log_mt
but the question whether that is right or not depends too much on your individual project to make it possible for me to clearly answer this.

Linker Error PPC

I'm trying to compile a c++11 code under a IBook G4.
I'm using a g++-4.9 installed with brew
However, I get stuck with this error:
/usr/bin/ld: can't locate file for: -lcrt0.o
Found nothing in the net about crt. Maybe, someone has better experience dealing with dinosaurs..
Frustration of having a compiler able to run on multiple architectures with the flip of a command line switch. Use -arch and specify either native or target cpu.

Building a program (sscep) against OpenSSL: undefined reference to '[...]'

I am trying to build a tool called sscep (http://www.klake.org/~jt/sscep/) for Windows. It does not run natively and I have a "patch" that changes sscep to make it compile on Windows.
After applying the patch, it does compile perfectly but the linker screws. I am using gcc in minGW/msys
The original messsage was that it couldn't find the crypto lib so I added the library with "-L../openssl-mingw/lib" which then didn't create any more errors. I also have the command line switch -lcrypto in my command: gcc -L../openssl-mingw/lib -lcrypto sscep.o init.o net.o sceputils.o pkcs7.o ias.o fileutils.o -o sscep.In this directory is a libcrypto.a. OpenSSL itself was compiled with the exact same compiler just running ./config && make && make test && make install. Also the sources were extracted using the minGW tar and not 7-zip.
After following all documentation this is my (truncated) output:
sscep.o:sscep.c:(.text+0x83): undefined reference to `WSAStartup#8'
sscep.o:sscep.c:(.text+0xa5): undefined reference to `WSACleanup#0'
sscep.o:sscep.c:(.text+0x3d5): undefined reference to `BIO_new_mem_buf'
sscep.o:sscep.c:(.text+0x3e0): undefined reference to `ASN1_INTEGER_new'
sscep.o:sscep.c:(.text+0x414): undefined reference to `a2i_ASN1_INTEGER'
sscep.o:sscep.c:(.text+0x432): undefined reference to `ASN1_INTEGER_to_BN'
sscep.o:sscep.c:(.text+0x448): undefined reference to `BN_bn2dec'
sscep.o:sscep.c:(.text+0xb7e): undefined reference to `EVP_des_cbc'
sscep.o:sscep.c:(.text+0xbaf): undefined reference to `EVP_bf_cbc'
sscep.o:sscep.c:(.text+0xbda): undefined reference to `EVP_des_cbc'
sscep.o:sscep.c:(.text+0xc02): undefined reference to `EVP_des_ede3_cbc'
sscep.o:sscep.c:(.text+0xc48): undefined reference to `EVP_md5'
sscep.o:sscep.c:(.text+0xc79): undefined reference to `EVP_md5'
sscep.o:sscep.c:(.text+0xca1): undefined reference to `EVP_sha1'
This goes on for every file in there and supposedly every function called.
Searching here and google resulted in a missing library but omitting the -L directive from above I get another error about not finding libcrypto. So I assume that the library is actually found but somewhat with wrong addresses or something?
Here my compiler/linker knowledge actually ends.
If it is possible that the patch is responsible for that (which I do not believe since these are all openssl functions and the compiling works) then I can provide you with it.
Edit: Is there any information that I should provide so someone can help me? The version of openssl is 1.0.1 if this makes any difference.
On this topic: If it does make a difference, could this error occur because of a wrong version. As far as I understand linker theory, this error should not originate from a wrong version unless all of the below functions were replaced by differently named ones (but then the compiler would have complained, I guess?).
Another addition: Since I am on a 64 bit Windows 7, I tried to compile it with -m32 flag but that did not help. I assume since mingw is already 32 bit only, I can't even build x64. Another question is whether it is a problem that I am running in a virtualized environment on an AMD Opteron while openssl is built with the command "-march=i486"?
With some help I could finally figure this out! It was a problem of the order AND a problem of missing libraries. The combination killed me.
The libraries had to be -lcrypto -lws2_32 -lgdi32 not just -lcrypto. Furthermore, I had to append the libraries after the object files, so: $(CC) $(CFLAGS) $(OBJS) -lcrypto -lws2_32 -lgdi32 -o $(PROG) was the right make line.
Finally with this, it compiles fine. I didn't even need any architecture flags and such.

Problem linking with Boost.Filesystem

I am trying to use the functions from boost::filesystem to change my current working directory (and create it if necessary). I am getting linking errors:
SBDir.cpp:(.text+0x23): undefined reference to `boost::system::generic_category()'
SBDir.cpp:(.text+0x2f): undefined reference to `boost::system::generic_category()'
SBDir.cpp:(.text+0x3b): undefined reference to `boost::system::system_category()'
But I am linking against the boost libraries??!? I use the following:
-lboost_system -lboost_system-mt -lboost_filesystem -lboost_filesystem-mt
And I know it can find them because with -Wl, -t I get:
-lboost_system (/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/libboost_system.so)
-lboost_system-mt (/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/libboost_system-mt.so)
-lboost_filesystem (/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/libboost_filesystem.so)
-lboost_filesystem-mt (/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/libboost_filesystem-mt.so)
FWIW: I'm using gcc Ubuntu 4.4.3-4ubuntu54.4.3.
I had this same error message with boost 1.46 (standard with Ubuntu 11.10) and I had to add -lboost_system which I didn't need in 11.04 and boost 1.42. It doesn't answer your question but possibly of interest to others brought here by googling the error message.
So I couldn't figure out what went wrong -- so I tried un-installing the Ubuntu boost package and building it from scratch. I upgraded to 1.45.0 & now everything links. Not sure whether this was a version specific problem or not, but if I learn more later I'll come back and update.

Resources