I updated my Mac to OS X 10.9 GM, then I found that gfortran does not work.
When building any program, it shows:
ld: library not found for -lcrt1.10.5.o
collect2: ld return 1
Does anyone know how I might solve this?
This problem is because OS X 10.9 has removed the /Developer directory completely where the library crt1.10.5.o used to locate. The libraries have been moved to the new Xcode directory (make sure that Xcode is also updated to the latest version 5.0.1+). I found that crt1.10.5.o is actually hidden deep in here /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/lib. I believe there should be a way to redirect ld automatically, but I do not know how. So for now I am using the -L flag to compile.
gfortran ... -L /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/lib/
This works for me as a temperary solution. I am also waiting for better solutions to come up.
Gfortran has already been compiled for Mac OS X Mavericks 10.9 by http://hpc.sourceforge.net/
First, cd to the root of your Mavericks installation so the files extract recursively into the proper folders
cd /
sudo wget http://prdownloads.sourceforge.net/hpc/gcc-4.9-bin.tar.gz
tar -xvf gcc-4.9-bin.tar.gz
gfortran --help
I had similar problems (ld: library not found for -lcrt0.o) but I discovered that they went away when I stopped using the -static flag with the gfortran command. The -static-libgcc flag seems to be OK.
Related
I'm having an issue running KING on Mac OS X . It has to do with a dyld link error, I think. Does anybody have any suggestions on how to fix this error?
Thanks in advance.
> ./king -b ./ex/ex.bed
Returns:
dyld: Symbol not found: __ZdaPvm
Referenced from: /Users/gaelgarcia/Downloads/./king (which was built for Mac OS X 10.13)
Expected in: /usr/local/lib/libstdc++.6.dylib
in /Users/gaelgarcia/./king
Abort trap: 6
I had similar issues trying to use the provided precompiled Mac version. I was able to get a running version built from source running the following in the unzipped source directory:
clang++ -L /opt/local/lib/libomp/ -lm -lz -O2 -fopenmp -o king *.cpp
having first installed libomp in the above directory. I use Macports, so I did this with
port install libomp
For Homebrew users, the recommendation seems to be to simply install llvm, which now includes openmp support directly.
EDIT: Having installed llvm via Homebrew (brew install llvm), the command that got KING properly built and running on my Mac OS 10.12 was:
/usr/local/Cellar/llvm/6.0.0/bin/clang++ -I /usr/local/Cellar/llvm/6.0.0/include -L /usr/local/Cellar/llvm/6.0.0/lib -O2 -fopenmp -lm -lz -o king *.cpp
Running the newly built executable with the example .bed file provided:
> ./king -b ../ex/ex.bed
KING 2.1.3 - (c) 2010-2018 Wei-Min Chen
The following parameters are in effect:
Binary File : ../ex/ex.bed (-bname)
For anyone like me looking for an answer years later, I managed to solve this problem by installing gcc with Homebrew.
brew install gcc
which includes libgfortran. Probably unnecessary, since I had dyld installed in Anaconda, but I found it was the easiest way to get King working on my mac.
Edit: I also had to set my DYLD_LIBRARY_PATH in my bash profile, as well, by going
nano ~/.bash_profile
and adding
export DYLD_LIBRARY_PATH=/opt/local/lib/libgcc/
or wherever the dynamic library libgcc_s.1.dylib is when you search for it on your computer.
this question has been asked before, but none of the answers seem to be currently working.. whether that's because they are incomplete, or things have changed, I don't know.
I build my code for a deployment target of 10.7 (my clients use their machines for music production, so they often prefer to stick with what they know works rather than updated with every new OS release).
I'm using boost.
So when I buid I get a bunch of warnings
ld: warning: object file (/usr/local/lib/libboost_filesystem.a(path.o)) was built for newer OSX version (10.10) than being linked (10.7)
ld: warning: object file (/usr/local/lib/libboost_system.a(error_code.o)) was built for newer OSX version (10.10) than being linked (10.7)
and so on.
So, I want to build boost (version 1.58 currently, unfortunately cmake is usually a couple of versions behind in what it can find) for a deployment target of 10.7
It seems the magic instruction is
macosx-version-min=10.7
except I can't make it work.
./bootstrap.sh
sudo ./b2 -a macosx-version-min=10.7 install
Just doesn't do it, nor do any of the other things I've tried (I'm not familar with how b2 works, so I'm grasping in the dark).
I expect I'm missing something simple, but some help would be much appreciated
regards
Jon
I ran into the same issue and could only fix it by building boost with the 10.7 library. I've used XCode 8.2.1. Here is what I did:
Modifying "Darwin.Jam". Look for this line: feature macosx-version-min : : propagated optional ;
and add this line below feature.extend macosx-version-min : 10.7 ;
Modify "Info.plist" in /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform and set <key>MinimumSDKVersion</key>
<string>10.11</string>
Make sure your XCode.app has the 10.7 SDK installed. This is the right location: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs You can extract or copy it from an earlier version of XCode.
Now build boost with these options: cxxflags="-stdlib=libc++ -std=c++11 -mmacosx-version-min=10.7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk"
E.g. ./b2 -a cxxflags="-stdlib=libc++ -std=c++11 -mmacosx-version-min=10.7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk"
The solution above will build Boost with the 10.7 SDK instead just setting the Target SDK to 10.7
I mostly work on linux and have no problems but want to occasionally use a Mac for work. Somehow gfortran does not work there, though. I installed it as instructed but when I try to compile something, this happens:
gfortran -o m_g_matrix2.x m_g_matrix.f90
ld: entry point (start) undefined. Usually in crt1.o for architecture x86_64
collect2: error: ld returned 1 exit status
I have no idea what this means and google search did not help. Did someone manage to get gfortran to work on Mac?
Thanks for the help!
I installed gcc binaries for yosemite from http://hpc.sourceforge.net
and also installed Xcode command-line tools as directed there.
gcc contains the gfortran compiler.
Seems to work well on macbook air with Yosemite.
JTN
The issue I'm having is that gcc (and family) don't appear to be properly setup. I have a 10.7.4 machine that I just installed Xcode on (from the app store). I've done no prior development on this machine.
Working w/in Xcode seems to work fine. I can build and compile no problem. However, trying to execute gcc command line fails.
First, I gcc wasn't on my path ... no big deal. I located it and ran as:
/Applications/Xcode.app/Contents/Developer/usr/bin/gcc -dynamiclib -fno-common -o s.dylib s.c
(I'm working on a lib w/some functions...). Anyways, it fails.
s.c:1:19: error: stdio.h: No such file or directory
s.c:2:20: error: stdlib.h: No such file or directory
s.c:3:20: error: string.h: No such file or directory
Surprise! hah, well I searched my machine for stdio.h and I can't find it anywhere. Since I've been out of the OSX game for a bit, I'm assuming I'm missing something -
Basically I want to be able to continue using Xcode but I want to be able to build C/C++/etc on the command line with all the dependencies (.h) in the correct place.
Any thoughts?
There are two main ways to run the compiler from the command line: the Command Line Tools package, and xcrun.
xcrun is particularly good if you just need this occasionally. Just stick "xcrun" at the start, like you'd do with sudo:
xcrun gcc -dynamiclib -fno-common -o s.dylib s.c
This will find the correct version of gcc and set the needed directories, etc. You can specify a specific SDK with --sdk.
If you do this a lot, download and install the Command Line Tools package (Xcode>Open Developer Tool>More Tools...; it also may be available in Preferences>Downloads). This installs a full copy of everything in /usr.
Probably xcrun is not enough if you are using 10.8.
Looking in to the clang documentation I found that you need to include the system root because you do not have your libraries in the standard place but inside Xcode.
using:
xcrun gcc -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk
or:
xcrun clang -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk
I'd like to compile a fortran code with gfortran so that it will work on both Mac OS X 10.5 and 10.6. Is there a way to do this? I tried compiling on 10.6 and get this message when I run the executable on 10.5:
dyld: unknown required load command 0x80000022
Trace/BPT trap
What version of 10.5 are you on? According to this (0x22) is a dynamic load function that got added at 10.5.6. You could try upgrading to >10.5.6 and see if the problem persists.
Also where did you get your gfortran from? In the numpy community the ones from att.com are highly recommended and the builds from hpc are generally to be avoided.
The application was incorrectly built on OS X 10.6 machine for a 10.5 machine. The developer can fix this by considering three things:
Using the correct compiler parameters:
gcc-4.2 -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk ...
Using the correct linker settings (setting environment variable before link command). This is required, so that the OS X 10.6 linker will not use the loader command 'LC_DYLD_INFO_ONLY' (=0x80000022), because OS X 10.5 does not understand this command:
export MACOSX_DEPLOYMENT_TARGET=10.5
(or setenv MACOSX_DEPLOYMENT_TARGET=10.5)
After this is fixed, one can check if the application was correctly built for OS X 10.5 by running 'otool':
otool -l binary
The correct binary should not contain any 'LC_DYLD_INFO_ONLY' load commands (only 'LC_DYLD_INFO' commands).
(also see my blog article http://grauonline.de/wordpress/?p=71 )