I am trying to run a program that uses the command -lgfortran on a mac. In the terminal, I run the .sh file using sh myFile.sh. When it runs I get the following error:
ld: library not found for -lifcoremt
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ld: library not found for -lifcoremt
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I installed fortran and C compilers here: https://software.intel.com/en-us/compilers
I also did some digging and read that I should locate the libgfortran.a file and replace the -lgfortran command with the file path to that file (/usr/local/Cellar/gcc/9.2.0_3/lib/gcc/9/libgfortran.a).
I run my code and I get the following error:
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have no idea how any of the fortran compiler stuff works and am new to using the terminal. How do I go about fixing this?
EDIT
gcc --version gives:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.17)
Target: x86_64-apple-darwin19.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
and gfortan --version gives:
GNU Fortran (Homebrew GCC 9.2.0_3) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Related
I upgraded my macOS to Monterey 12.3 and my gfortran code no longer compiles. Initially, running:
gfortran -o executable make_executable1.o make_executable2.o
gave this error message:
ld: library not found for -lSystem
collect2: error: ld returned 1 exit status
make: *** [fm3d] Error 1
I then added the path to the Library by running:
export LIBRARY_PATH="$LIBRARY_PATH:/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib"
and I now get this error:
ld: unsupported tapi file type '!tapi-tbd' in YAML file '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/libSystem.tbd' for architecture x86_64
collect2: error: ld returned 1 exit status
make: *** [fm3d] Error 1
I assume it is a problem with my CommandLine, but I have reinstalled everything to their latest version and I can't get it to work.
macOS Monterey 12.3
Apple clang version 13.1.6 (clang-1316.0.21.2)
GNU Fortran (GCC) 11.2.0
CommandLine Tools version: 13.3.0.0.1.1645755326
Any advice on the next step to take would be appreciated!
gfortran # Monterey 12.6.2 works well with Xcode 14.1 and Command_Line_Tools_for_Xcode_13.dmg (However, it did not work with the latest Command_Line_Tools_for_Xcode_14.1.dmg resulting in the same error as you describe)
I am using GNU fortran compiler and I am compiling the code using command prompt in MacOS. I am getting an error which says that the
ld: library not found for -lSystem
collect2: error: ld returned 1 exit status
I have tried reinstalling the xcode and it did not work
gfortran -o executable try.o
Should be getting an executable file
I am trying to compile simple C code on my system. I am running gcc version (4.9.2) on macOS 10.11.6.
ld: library not found for -lgcc
collect2: error: ld returned 1 exit status
I am unable to fix this issue. This problem is not letting me install any ./configure packages as well since they require gcc to work.
Even if there is a program called gcc under macOS, it is not a real gcc compiler. It is just a Clang compiler, as you can prove easily:
gcc --version
will print:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin17.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
You should be able to compile and link your program by omitting the -lgcc flag from the command line.
I already have gcc and g++ install:
$ which gcc
/usr/bin/gcc
$ which g++
/usr/bin/g++
$ brew install gcc
Warning: gcc-6.2.0 already installed
I follow Compile OpenMP programs with gcc compiler on OS X Yosemite to reinstall gcc via HomeBrew:
$ brew reinstall gcc --without-multilib
then
$ /usr/bin/g++ openmp.cpp
openmp.cpp:12:10: fatal error: 'omp.h' file not found
#include <omp.h>
^
1 error generated.
with -fopenmp
$ /usr/bin/g++ openmp.cpp -fopenmp
clang: error: unsupported option '-fopenmp'
clang: error: unsupported option '-fopenmp'
What's happening with this redirection? How could I use gcc/g++?
Though involved, it's not about OpenMP.
brew installs tools in /usr/local/bin. Use /usr/local/bin/g++6:
$ /usr/local/bin/g++-6 --version
g++-6 (Homebrew gcc 6.2.0) 6.2.0
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I am trying to execute a lex and yacc program using vi editor on the macbook terminal. However while compiling with command:
$ gcc lex.yy.c -o rvr
I get the errorld:
symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
Why this error happening??