Linker Error PPC - macos

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.

Related

What is the meaning of 'ld: library not found for -lm'

I'm a beginner at Fortran code. I install gfortran from the homebrew to my apple silicon mac. The path show in the terminal when I type which fortran is /opt/homebrew/bin/gfortran
I try to use bash shell to run a 'hello world' fortran file on the Desktop (.f90 file). I typed the following command in the terminal. gfortran prog01_01.f90. But it does not work. The error says: ld: library not found for -lm and collect2: error: ld returned 1 exit status. I have no idea how to deal with this problem.
Can anyone please help me this out?
This means that the compiler cannot find the basic mathematical library libm. It should normally be included in your GLIBC or other standard C library installation and be available in the appropriate library directories and I would expect that your package manager would complain that something is missing.
Anyway, you simply have to fix your software installation, we cannot tell you more without details about your system and your software packages. You can try to install GLIBC if you did not install it yet.

Error while trying trying to run make command

I am trying to install a program and when I run make or make -f Makefile (following the installation instructions) I get the following output:
g77 -O5 -Wall -c prep_output.f -o prep_output.o
dyld: Symbol not found: ___keymgr_global
Referenced from: /usr/local/bin/g77
Expected in: /usr/lib/libSystem.B.dylib
make: *** [prep_output.o] Abort trap: 6
I am working on a macOS Mojave 10.14.6. Following some other proposed solutions in similar problems, I've already installed Command line tools in my Xcode but that didn't do the trick. Any suggestions please??
Thanks in advance
EDIT:
I got rid of g77 and installed a compatible version of gcc (gcc8) through MacPorts. After running the make command I get the following:
g77 -O5 -Wall -c prep_output.f -o prep_output.o
make: g77: No such file or directory
make: *** [prep_output.o] Error 1
So I guess the program still needs the g77 setup? This is the program btw ([http://www.cfht.hawaii.edu/~arnouts/LEPHARE/install.html]). Is there a way to rely to the gfortran compiler for building the program?
Thanks in advance
P.S. I noticed that when I install g77 I get the following error:
x usr/local/: Can't set user=0/group=0 for usr/local`
`tar: Error exit delayed from previous errors.
However it still installs g77..
The error message indicates that your installation of g77 is broken. This has nothing to do with make or the particular project you're trying to build, except inasmuch as the project is trying to use g77 in the first place. That is a bit surprising, actually, since g77 has been obsolete for years (gfortran is the current GNU Fortran compiler), but I'm uncertain what exactly to expect from XCode in this area.
On the other hand, since the full path to the binary is /usr/local/bin/g77, I'm further inclined to think that you're not using XCode for this at all. Possibly you've dumped a g77 built on some other system into your /usr/local/bin, and it's not compatible with your Mojave system.
Your best bet is probably to
Get rid of your broken g77 installation.
Install Fink or MacPorts, or a similar project.
Install the Fink / MacPorts / whatever package for gfortran (maybe gcc-gfortran or similar in some of those) to get a working Fortran compiler.
Rely on that compiler to build your project.

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.

Compiling WxWidgets on Mac OSX 10.10

I'm trying to compile WxWidgets 3.0.2 on my mac OSX 10.10
and I get the following message:
Blockquote
...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [/Users/.../wxWidgets-3.0.2/build_rel/lib/libwx_osx_cocoau-3.0.0.2.0.dylib] Error 1
I'm compiling using these flags
../configure --with-osx_cocoa --with-macosx-version-min=10.7 --with-macosx-sdk=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk --prefix="$(pwd)" --with-opengl CC=clang CXX=clang++ CXXFLAGS="-stdlib=libc++ -std=c++11" OBJCXXFLAGS="-stdlib=libc++ -std=c++11" LDFLAGS=-stdlib=libc++ --enable-universal-binary=x86_64 --enable-monolithic --enable-unicode --with-expat=builtin --with-zlib=builtin --with-libtiff=builtin --with-regex=builtin --with-libpng=builtin --with-libjpeg=builtin
As you can see I added the enable-universal-binary=x86_64 as suggested in other topics.
If you can suggest other flags that I might have not added or I should remove
that would be great..
Thanks
The other way:
brew install wxwidgets
you will get compiled wxWidgets in /usr/local/Cellar.
In principle, this should work, but what is the point of using --enable-universal-binary=x86_64? It's not universal if there is only a single architecture... You probably wanted to use --enable-macosx_arch=x86_64 instead.
BTW, I think the various stdlib-related options are unnecessary as well, clang is the default compiler under 10.10. And --enable-unicode is definitely superfluous.
If you need wx3.0.0 osx 10.7+ monolitic, shared library can get it from here wxphp stub bundle
Library is included in app/contents/resources , use it if you want. but you need headers c++, get it from wx side.
As posted here, you can use --with-macosx-sdk=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/ as a workaround. There is an fixed issue about it and will probably be released on 3.0.3.

Help on Compiling on AIX

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.

Resources