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??
Related
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.
While running npm install in one of my project I'm getting this following error:
CMake Error at /usr/local/Cellar/cmake/3.19.4/share/cmake/Modules/CMakeTestCCompiler.cmake:66 (message):
The C compiler
"/Library/Developer/CommandLineTools/usr/bin/cc"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: /Users/user.name/.nvm/versions/node/v8.17.0/lib/node_modules/#devicefarmer/stf/node_modules/#julusian/jpeg-turbo/build/CMakeFiles/CMakeTmp
Run Build Command(s):/usr/bin/make cmTC_e8f1f/fast && /Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/cmTC_e8f1f.dir/build.make CMakeFiles/cmTC_e8f1f.dir/build
Building C object CMakeFiles/cmTC_e8f1f.dir/testCCompiler.c.o
/Library/Developer/CommandLineTools/usr/bin/cc -isysroot /Users/user.name/Library/Android/sdk -o CMakeFiles/cmTC_e8f1f.dir/testCCompiler.c.o -c /Users/user.name/.nvm/versions/node/v8.17.0/lib/node_modules/#devicefarmer/stf/node_modules/#julusian/jpeg-turbo/build/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_e8f1f
/usr/local/Cellar/cmake/3.19.4/bin/cmake -E cmake_link_script CMakeFiles/cmTC_e8f1f.dir/link.txt --verbose=1
/Library/Developer/CommandLineTools/usr/bin/cc -isysroot /Users/user.name/Library/Android/sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names -L/usr/local/opt/openssl#1.1/lib CMakeFiles/cmTC_e8f1f.dir/testCCompiler.c.o -o cmTC_e8f1f
ld: library not found for -lSystem
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [cmTC_e8f1f] Error 1
make: *** [cmTC_e8f1f/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:1 (project)
-- Configuring incomplete, errors occurred!
Tried uninstalling and installing CMake but no luck.
OS : MacOS Catalina 10.15.7
Node: v8.17.0
CMake: v3.19.4
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
My iOS simulator build failed with errors:
ld: 21318 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
how do I give the -v to xcode? I'd want to see more details but when I give -v to Other linker flags, nothing more comes out
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!