I'm trying to port a project of mine on Mac OS-X.
As I developed my project using C++0X I needed a more recent version of GCC than the one provided with Xcode (even Xcode4), so I compiled GCC 4.6 on my Snow Leopards Mac.
My project does compile fine and it does start too on the computer I compiled it (OS-X 10.6.7) but when I transfer it to my MacBook (OS-X 10.5.8) it doesn't works.
It returns the following errors:
dyld: lazy symbol binding failed:
Symbol not found:
__ZNSo9_M_insertImEERSoT_ Referenced from:
/Users/zu/Desktop/OgreApp.app/Contents/MacOS/OgreApp
Expected in:
/usr/lib/libstdc++.6.dylib
dyld: Symbol not found:
__ZNSo9_M_insertImEERSoT_ Referenced from:
/Users/zu/Desktop/OgreApp.app/Contents/MacOS/OgreApp
Expected in:
/usr/lib/libstdc++.6.dylib
I understand that the program needs the libstdc++.6.dylib of the GCC 4.6.0 as this file contains the C++0x functions (despite the fact that my current test doesn't use any C++0x function) instead of the standard libstdc++.6.dylib usually included in the OS-X system.
So I tried the following:
to specify -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 in order to ensure backward compatibility with OS-X 10.5. But the error remains the same.
to verify the libstdc++.6.dylib path using otool -L and changing the shared library path using install_name_tool -change /opt/local/lib/gcc46/libstdc++.6.dylib #executable_path/../Libraries/libstdc++.6.dylib OgreApp (with a copy of the gcc 4.6.0 libstdc++.6.dylib in the Libraries folder) as suggested as answer of my previous question. But the error remains the same.
to statically link libstdc++ and libgcc using -static-libgcc - static-libstdc++. But it still returns the same error.
As my program use the Ogre framework, I applied the above manipulations to the Ogre executable embedded in the Ogre.framework too, but it doesn't change anything.
Does anyone can explain me how I'm supposed to deploy an application created with a non standard libstdc++ on another Mac computer installed with an older version (I guess the problem is the same with a computer running Snow Leopard as the program use the GCC 4.6.0 libstdc++) ?
Mac OS X 10.5 does not include a compatible copy of the GCC standard library. If you want your code to run on Leopard, you'll have to either modify it to compile under an older version of GCC, or you'll have to... well, really that's your only option.
Related
I'm building 32 bit c++ library that will run on old system on modern Ubuntu machine. Application works fine on Ubuntu, but when I moved to old Centos 6.9 machine I got error:
Failed to open my lib: /usr/lib/libstdc++.so.6: version 'GLIBCXX_3.4.21' not found (required by /home/aaa/bbb/libme.so)
How to solve this problem? How to build for older glibc?
The only way to tell the compiler and linker to use older symbol
versions is by using linker scripts. However, this requires you to
specify the version for each and every symbol, which is an undoable
task.
You can use Holy Build Box
Holy Build Box solves the glibc symbol problem by providing a
tightly-controlled build environment that contains an old version of
glibc.
I am currently writing a c++ game using allegro 5.0 and c++. I will eventually get it working on mac, linux, windows, and possibly android and iPhone. Currently it compiles and runs on linux (tested on arch linux latest), but on mac there is a slight problem:
Using the apple provided g++, it complains about a linking error, _main not defined. However, I have checked and checked, and main is definitely defined in my file. It must be anyway because it compiles and runs on linux, but I can't figure it out.
I have googled many many days and many many terms (too many to list) and haven't found anything to do with mac and main not being defined. Could there be something I'm missing? Something i need to do special on mac? One last thing to note is when I link with allegro_main.a it links, but then crashes. Linking with this library is not necessary on linux. I am using allegro5 through macports. It is also useful to note that the sh script used to compile on mac is comp_mac.sh, and linux is simply comp.sh. Note that you may need to modify the sh script(s) to compile on your environment. These are only tested on my environment (macports) so far.
My code can be found here: http://github.com/2mb-solutions/horseshoes/
Thanks for all the help I can get.
-Michael.
The "_main" undefined symbol error is occurring because you are not linking with the allegro_main addon.
As the Allegro 5 manual specifies, in C and C++ projects, the file containing your main() function must include the core header allegro5/allegro.h. Additionally, you must link with the allegro_main addon.
It might be easiest to use pkg-config:
pkg-config --cflags --libs allegro-5 allegro_ttf-5 allegro_audio-5 allegro_acodec-5 allegro_font-5 allegro_main-5
You can place that command within backticks ( ` ) to include the output of pkg-config in your build command.
Like many others, I'm taking the CS106B class on iTunes and, although the class is old, I am attempting to use the Stanford C++ libraries that are current. They are found here: http://www.stanford.edu/class/cs106b/.
During the Build Phase of projects, I have inserted into "Link Binary with Libraries" the files "random.h" and "libStanfordCPPlib.a". When I do this, I get the following error messages:
Check dependencies
warning: skipping file '/Users/lewis/Documents/Think Like a Programmer/CS106/VotingSimulation/../../../Programming Abstractions/Assignment 1/Assignment1-xcode/0 - Warmup/StanfordCPPLib/random.h' (unexpected file type 'sourcecode.c.h' in Frameworks & Libraries build phase)
ld: warning: ignoring file /Users/lewis/Documents/Programming Abstractions/Assignment 1/Assignment1-xcode/0 - Warmup/StanfordCPPLib/libStanfordCPPLib.a, file was built for archive which is not the architecture being linked (x86_64): /Users/lewis/Documents/Programming Abstractions/Assignment 1/Assignment1-xcode/0 - Warmup/StanfordCPPLib/libStanfordCPPLib.a
Undefined symbols for architecture x86_64:
"randomChance(double)", referenced from:
_main in main.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 am using Mac OS X 10.7.5 and XCode 4.6.2. I have set the Build Settings Base SDK to OS X 10.7 for both the Project and the Target.
It appears to me that the "libStanfordCPPlib.a" file may be an archive file that I have to unarchive before I can link the implementation code for the header files. Is this what I need to do, and if so, how do I do it? Am I doing something else wrong in linking the files?
I'm a noob and I'd appreciate help from anyone who has been successful in getting the current Stanford CS106B C++ libraries to work in XCode 4.6.2.
I just ran into this problem myself after upgrading to the newest version of xcode (ver. 5.0, OSX ver. 10.8.5).
Try switching the architecture of the project to 32-bit Intel (i386). The default is "Standard Architectures 64-bit Intel (x86_64)".
I'm currently using xcode 6.4 and trying to work through the cs 106b course work, I had the same issue of not being able to run the sample files and assignment files (can be found here btw http://web.stanford.edu/class/archive/cs/cs106b/cs106b.1136/ ). After changing the Architectures for both the Project and Target to 32-bit-intel as listed above I still received errors. I had to take the additional step of changing the OSX deployment target from 10.10 to 10.8 under the Project info.
This allowed the program to build but I received a notification that i needed to install the Java Runtime Environment, and there was no consult output. Installing this did not resolve the issue. I was only able to fully execute the code after installing the Java Development Kit. I am now able to compile all files for the course.
I hope this update helps more recent attempts to access this info.
I hope you've found an answer to your problem by now, but as I was suffering from a similar problem, trying to get xcode 5.1 to compile Warmup.cpp, I thought I'd post my solution for those others trying to get xcode to work with the cs106b libraries.
After struggling with xcode 5.1.1 and 5.0.2, I downloaded xcode 4.6.3 off of the apple dev site, www.developer.apple.com, and trashed the later versions. After installing 4.6.3, I still got errors, but after switching the Architecures for the Project and for the Target, to "32-bit-Intel", as messysaurus suggests, the warmupp.cpp compiled fine. Trying this same technique with xcode 5.1.1 and 5.0.2 yielded no results.
Hope this helps anyone else running into problems.
I develop a CGI C++ application that I compiled under Debian. Running this app on an Ubuntu system I am getting the error:
relocation error: /lib32/libresolv.so.2: symbol strlen, version GLIBC_2.0 not defined in file libc.so.6 with link time reference
What can I do now? Should I recomile on the Ubunto system? Can I replace a library?
Edit
I link my application with -static.
Running the command ldd --version on the Ubuntu system showed my that EGLIB is used there.
What this error means is that your program was compiled/linked against an older version of GNU libc, which is not supported on the system where you want to run your executable.
You have few options to solve it:
Make sure you use the same or compatible version of libc when compiling and running.
Link against a static runtime.
Install older version of libc on Ubuntu system to match the Debian's environment.
I'm having trouble using libpng with Xcode 4.2 on OS X 10.7.1.
My program fails to launch with the error:
dyld: Library not loaded: /usr/X11/lib/libpng15.15.dylib
and:
Reason: Incompatible library version: glsl_test requires version 20.0.0 or later,
but libpng15.15.dylib provides version 17.0.0
All I'm doing is adding /usr/X11/libpng.dylib to the linked libraries, so where is this 'version 20' requirement coming from? Why isn't Xcode just requiring the version that's available? How do I go about telling my program that it's OK to use version 17?
Without knowing much about the intricacies of Xcode, it sounds like something else in your program requires a later version of the libpng library. This could even be something that is implicitly included by the build environment.
I'd double-check that you have a build environment that is compatible with your intended target. I'd also double-check that you're specifying the inclusion of the library using appropriate syntax (e.g., using -lpng vs. an explicit "/usr/X11/libpng.dylib").