Cryptic link error. Where do I start? - macos

I'm trying to build the basemap toolkit, from source, for matplotlib to run on my MacBook Pro under OS X 10.8. The C and C++ compiler are those included with the latest Xcode package. The package includes the geos-3.3.3 package which needs to be built separately and installed before the main basemap python package is built. When I do this, using the supplied Makefile, I get the following error when the makefile attempts to build the libgeos.dylib library:
Undefined symbols for architecture x86_64:
"std::auto_ptr<geos::geom::Envelope>::auto_ptr(std::auto_ptr_ref<geos::geom::Envelope>)", referenced from:
virtual thunk to geos::geom::GeometryCollection::computeEnvelopeInternal() constin libgeom.a(GeometryCollection.o)
"__ZNSt8auto_ptrIN4geos4geom8EnvelopeEEcvSt12auto_ptr_refIT_EIS2_EEv", referenced from:
virtual thunk to geos::geom::GeometryCollection::computeEnvelopeInternal() constin libgeom.a(GeometryCollection.o)
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
On a Fedora 17 machine, with gcc 4.7, this library builds successfully so there is obviously something going on with the Mac compiler/linker. However, I have no idea how to decode this message. What, for instance, is a "virtual thunk"? Any insight on how I can compile and build this on the Mac?

I used a different compiler and the problem went away. Try:
make CXX=c++
Worked for me. OSX 10.8.3, XCode 4.6.1.

Related

Qt Creator: Undefined symbols for architecture x86_64

I have a program in Qt creator that compiles and runs fine in a Windows machine. But as soon as I tried to compile it in a Mac OS X (10.9) I received these messages:
Undefined symbols for architecture x86_64:
"std::__1::__basic_string_common<true>::__throw_length_error() const", referenced from:
std::__1::enable_if<__is_forward_iterator<char*>::value, void>::type std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::__init<char*>(char*, char*) in libVolumeSelectorLib.a(NetCDFDataSource.o)
...
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [UI.app/Contents/MacOS/UI] Error 1
14:38:02: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project VVSIT (kit: Desktop Qt 5.4.0 clang 64bit)
When executing step "Make"
I have tried cleaning and compiling again in case some file built on Windows had made it to the Mac, but that is not the case, the problem continues happening.
I've checked these posts but their solutions didn't work:
Undefined symbols for architecture x86_64 in QT-creator
https://stackoverflow.com/questions/23806544/undefined-symbols-for-architecture-x86-64-in-qt-creator
Any idea how to solve this error?
After some research I found this thread: Qt5.1/Qt5.2 + XCode 5.0.2 + Mac OS 10.9 (Mavericks), Can’t link to the libraries
That link contains the solution that worked for me, I had to edit the file:
/Applications/Qt/5.4/clang_64/mkspecs/macx-clang/qmake.conf
And change the line that says:
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7
to:
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.9
After that, I cleaned every subproject in my project, and compiled them again, and all is working fine now.
In case you wonder what does that change in the clang++ do, what it does is to change the parameter -mmacosx-version-min=10.7 to -mmacosx-version-min=10.9.

Trying to compile GnuPG-2.1.1 on OS X Yosemite 10.10.1

While trying to build the latest GnuPG (2.1.1 modern), my build fails when trying to link t-stringhelp. make outputs:
ld: warning: ignoring file libcommon.a, file was built for archive which is not the architecture being linked (x86_64): libcommon.a
Undefined symbols for architecture x86_64:
"_compare_filenames", referenced from:
_main in t-stringhelp.o
"_make_absfilename_try", referenced from:
_main in t-stringhelp.o
"_make_filename_try", referenced from:
_main in t-stringhelp.o
"_percent_escape", referenced from:
_main in t-stringhelp.o
"_strconcat", referenced from:
_main in t-stringhelp.o
"_xstrconcat", referenced from:
_main in t-stringhelp.o
I don't know how to fix this as libcommon is part of the source, so it should build fine. When building with CFLAGS="-m64" (-arch x86_64 does nothing), I get this:
ld: warning: ignoring file ../common/libgpgrl.a, file was built for archive which is not the architecture being linked (x86_64): ../common/libgpgrl.a
Undefined symbols for architecture x86_64:
"_gnupg_rl_initialize", referenced from:
_main in gpg.o
I've also rebuilt all the depandancies (as I built them on Mavericks), except pinentry, as it can't find libiconv which is also installed. My configure outputs that its target is Darwin (x86_64-apple-darwin14.0.0), so this should work. I have also got all the latest prerequisites, tried to install everything in its own directory (--prefix=/usr/local/gnupg-2.1.1), build all the dependancies and GnuPG as 32 bits (again, fails on same error), created a separate build folder and tried to build in there, but only one thing so far has solved the error: looking at how libgpgrl.a is being built - it's only component is common/gpgrlhelp.c - so I cd'ed into g10 and tried to build gpg2, replacing ../common/libgpgrl.a with ../common/gpgrlhelp.o, the lib common.a with all of its object files, for all the libraries that didn't work. Then some programs weren't linking to libksba libgcrypt and libassuan, so I changed the Makefiles, so that they could link. I can now compile all the code well, I installed everything, but I get a new error, when I try to run gpg2:
dyld: lazy symbol binding failed: Symbol not found: __gcry_mpi_init
Referenced from: /usr/local/gnupg-2.1.1/lib/libgcrypt.20.dylib
Expected in: flat namespace
dyld: Symbol not found: __gcry_mpi_init
Referenced from: /usr/local/gnupg-2.1.1/lib/libgcrypt.20.dylib
Expected in: flat namespace
I have everything in my path, which is:
/usr/local/gnupg-2.1.1/bin:/usr/local/gnupg-2.1.1/lib:/Library/Frameworks/Python.framework/Versions/3.4/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/local/mysql/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
I could compile GnuPG-2.0.22 on Mavericks, but no version of GnuPG builds on Yosemite.
Please help, I'm really confused.
I’ve been running GnuPG 2.1 on Yosemite 10.10.2 (the latest public beta of as of this writing) for about a week and it’s been fine.
You can follow these directions for using brew tap or you can use the raw URL: brew install https://github.com/mtigas/homebrew-gpg21/raw/master/Formula/gnupg2.rb.
Note this formula installs GnuPG 2.1; not GnuPG 2.1.1, the version originally asked about. I can confirm this bug where gpg2 --refresh-keys fails with some keyservers using 2.1 (apparently fixed in 2.1.1) but it’ll get you 90% there.
It shouldn’t be hard to update the formula to install 2.1.1.
Update
Someone submitted a pull request for GNuPG 2.1.1 support—I just tried it and it worked great. Short answer: brew install https://raw.githubusercontent.com/calebthompson/homebrew-gpg21/2.1.1/Formula/gnupg2.rb.
Personally, I would install homebrew, which is a one-liner pasted from their website (http://brew.sh) then do
brew install gnupg
If therw are any problems, run
brew doctor
and heed the good doctor's advice.
Turns out I had a ranlib in /usr/local/bin/ranlib. It was broken, I don't know how it got there (I did try to build gcc at some point, it doesn't support make uninstall, so that's probably why). I just ran:
sudo mv /usr/local/ranlib /usr/local/ranlib_old
Then I just rebuilt all the dependancies, and it worked!

What does undefined symbols for architecture x86_64 mean?

I am trying to build eigen on my Mac Air with Lion. I downloaded eigen3 (from http://eigen.tuxfamily.org/index.php?title=Main_Page) and have successfully run make install. However, when I try to run make check, I get the following error.
[ 1%] Built target sparse_extra_2
Linking CXX executable openglsupport
ld: warning: ignoring file /System/Library/Frameworks//GLEW.framework/GLEW,
missing required architecture x86_64 in file
Undefined symbols for architecture x86_64:
"_glewExperimental", referenced from:
test_openglsupport() in openglsupport.cpp.o
"_glewInit", referenced from:
test_openglsupport() in openglsupport.cpp.o
"_glBegin", referenced from:
test_openglsupport() in openglsupport.cpp.o
I feel that this issue has to do with glew. I am now trying to install different versions of glew, but that doesn't seem to do anything.
Any advice on how to resolve the error? What does undefined symbols for architecture x86_64 mean anyway?
This probably means your installation of GLEW is incomplete. You can properly disable testing of OpenGL with cmake . -DEIGEN_TEST_NO_OPENGL=ON. Finally, note that Eigen is a header only library, so there is nothing to compile to use it.

Unity project. Undefined symbols for architecture armv7

I make a build for iPhone for the first time and got a problem.
I already checked a lot of posts and didnt find answer.
When i make a build on device a get:
Undefined symbols for architecture armv7:
"RegisterAllStrippedInternalCalls()", referenced from:
RegisterAllInternalCalls() in libiPhone-lib.a(MonoICallRegistration.o)
"RegisterAllClasses()", referenced from:
InitializeEngineNoGraphics() in libiPhone-lib.a(SaveAndLoadHelper.o)
"RegisterMonoModules()", referenced from:
_main in main.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
On simulator ok.
libiPhone-lib.a added to link libraries.
Can somebody tell what it is? Please
Your unity version is not compatible, just download the latest version of unity which I believe is 4.3.1 and try recompiling. Here is the link if you need it. http://unity3d.com/unity/download/download-mac
The new version is compatible with armv7.
ok if anyone else is experiencing the same problem here's a way out:
those 3 methods mentioned are declared in the RegisterMonoModules.cpp in the Libraries folder, usually. so take that cpp file and add it to your target's Build Phases > Compile Sources
then if you have additional SDK's integrated that are not added to the 'Compile Sources' the new build will throw some other errors. just make sure to add the wrapper .mm files from the sdk's to your Compile Sources. Usually one .mm file per sdk. (e.g. for unity facebook sdk it's FbUnityInterface.mm file)
hope this helps

SDL in XCode 4.3.2 SDLMain.o undefined symbols

I have started trying to use SDL in Xcode 4.3.2 so I started up a Cocoa application for Mac OS X and connected all my frameworks : OpenGL, SDL etc. I don't have SDL_Image, SDL_Mixer etc. (Do I need these?) When I try to compile the project that just has SDLmain.h and SDLmain.m I get this error:
Undefined symbols for architecture x86_64: "_SDL_main", referenced from: -[SDLMain applicationDidFinishLaunching:] in SDLMain.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
I was having the same issue with SDL 1.2.15 on Xcode 4.5 and OS X 10.7, turned out the problem was that I added SDLMain.m and SDLMain.h (according to a suggestion on the libSDL website about OS X frameworks) to an existing SDL project which messed up with main. Bottom line is that you don't need those files just because you are using Cocoa -- SDL's own test apps don't use it either and run just fine on OS X.

Resources