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
Related
I'm building a set of libraries on Mac M1 (arm64 architecture), Big Sur and use GNU11 compilers (gcc, gfortran, g++), as well as openmpi 4.1.2 for multi-processing. All is done as a command-line using a Terminal.app, which is running as Apple native, and NOT using Rosetta Translation. The steps taken: 1) GCC, g++, gfortran are installed using "brew install gcc#11", then symbolic links created in /opt/homebrew/bin/ for gcc -> gcc-11, g++ -> g++-11 ; 2) openmpi 4.1.2 installed, with mpicc based on gcc, mpixx based on g++, and mpifort/mpif90 based on gfortran; 3) command-line tools installed as "xcode-select --install".
Getting the problem with finally linking of the libraries:
...
/Users/Natalie/openmpi/bin/mpifort -L/opt/homebrew/opt/openssl#3/lib -fallow-argument-mismatch -fallow-invalid-boz -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk -mmacosx-version-min=11.6 CMakeFiles/cmTC_9a888.dir/testFortranCompiler.f.o -o cmTC_9a888
Undefined symbols for architecture arm64:
"_sgemm_", referenced from:
_MAIN__ in testFortranCompiler.f.o
ld: symbol(s) not found for architecture arm64
collect2: error: ld returned 1 exit status
make[1]: *** [cmTC_9a888] Error 1
make: *** [cmTC_9a888/fast] Error 2 ```
I'm having trouble compiling a project requiring OpenMP using CMake and clang, I set my CMakeLists.txt like this
cmake_minimum_required(VERSION 3.20)
project(cmat C)
set(CMAKE_C_STANDARD 11)
include_directories("/usr/local/include" "/usr/local/opt/llvm/include")
link_directories("/usr/local/lib" "/usr/local/opt/llvm/lib")
add_library(cmat SHARED cmat.c Calculation/_Basic_Calculate_.c Calculation/_Basic_Calculate_.h)
And when I started to build my project, it gave error
Undefined symbols for architecture x86_64:
"_omp_get_thread_num", referenced from:
_NmMulMat in _Basic_Calculate_.c.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[3]: *** [libcmat.dylib] Error 1
make[2]: *** [CMakeFiles/cmat.dir/all] Error 2
make[1]: *** [CMakeFiles/cmat.dir/rule] Error 2
make: *** [cmat] Error 2
I've tried some of the other answers like this and this, but they just don't work for me.
The clang version for my Mac is 13.0.0 and CMake is of 3.21.3_1, I'm using Clion as IDE, and such command will work when compiling files by shell
clang -Xpreprocessor -fopenmp -I/usr/local/include -L/usr/local/lib -lomp filename.c -o output
Great appreciate for your help.
You need to add -fopenmp to the linker flags as well by providing -DCMAKE_EXE_LINKER_FLAGS=-fopenmp [and any other options like -g].
In CLion (which I don't use) this would be specified in Preferences ->
Build, Execution, Deployment -> CMake -> CMake options as far as I understand the documentation.
Also please note that explicitly linking with -lomp is probably the wrong strategy, that happening should be a side-effect of specifying -fopenmp.
So bear with me as I am very new to coding. I'm trying to compile a Fortran file but I keep getting this issue in my terminal.
I am using GNU Fortran (GCC) 9.2.0 and I believe I have all other prerequisites updated Xcode and atom. Appreciate any and all help spent went way too long just to say hello world.
% gfortran -o myprog hello.f90
ld: library not found for -lSystem
collect2: error: ld returned 1 exit status
We are migrating some very simple C++ programs from AIX Server to Linux. The code is compiling fine on AIX server.
I tried to compile the C++ code in the Linux server. But the command line below failed:
g++ map2key.cpp -o map2key -nodefaultlibs -lstdc++ -lm -lgcc_s -lc -Xlinker -bmaxdata:0x8000000
With the error message:
/bin/ld: invalid BFD target `maxdata:0x80000000'
collect2: error: ld returned 1 exit status
The C++ program should be compiled and executable file should be generated
If you can help, I would very much appreciate it.
I'm having trouble getting the sandboxed_server example from RInside/examples/sandboxed_server working on xcode. I have OS X Yosemite 10.10.1.
I get the following error:
clang++ server/rinsideserver.o common/binarystream.o datatypes/bar.o datatypes/foo.o example_server.o -F/Library/Frameworks/R.framework/.. -framework R -llzma -lz -licucore -lm -liconv -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/Library/Frameworks/R.framework/Resources/lib -lRlapack /Library/Frameworks/R.framework/Versions/3.1/Resources/library/RInside/lib/libRInside.a -o example_server
Undefined symbols for architecture x86_64:
"RInside::set_callbacks(Callbacks*)", referenced from:
_main in example_server.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: *** [example_server] Error 1
Command /usr/bin/make failed with exit code 2
I have not been able to get any example that uses callbacks to work. Examples (from standard examples) that don't use callbacks do work.
I've uncommented #define RINSIDE_CALLBACKS in RInsideConfig.h. I've reinstalled the source files through R/CRAN from source- as was suggested on another post.
I did modify the code in sandboxed_server to get CLOCK_MONOTONIC to work on mac- but nothing other than that.
I'd really like to get this example working. Any help would be greatly appreciated!