Recently I tried to compile a simple program test.cpp with clang17 but got an error: linker command failed with exit code 1
What i have followed
step1:
firstly compiled clang17 with old libc++ using the old compiler clang15
step2:
secondly compiled new clang17 with new libc++ using the new clang compiler obtained in step1
step3:
Now I am trying to compile a simple program test.cpp with the compiler obtained in step2
//test.cpp
#include<iostream>
int main(){
std::cout<<"Hello world";
return 0;
}
I am trying to compile through terminal with command
${PWD}/clang++ test.cpp -o a.out
above command to compile test.cpp by clang17 is giving error
…./binutils/binutils-latest/bin/ld: cannot find -lc++
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
but if i add directory ‘${PWD}/../lib’ to library search path then clang17 is compiling test.cpp well with command ${PWD}/clang++ **-L ${PWD}/../lib** test.cpp -o a.out
I got the idea to add above directory to library search path by checking the verbose of compile test.cpp by clang15
Can anyone please help how can i resolve above issue?
I have tried to go through the CMakeLists.txt of clang15 and clang17 as well as CMakeCache.txt of clang15 and clang17 to find any hints or solutions for above problem but did not find any solutions.
also i found a difference in CMakeLists.txt of clang17 and clang15
LLVM_ENABLE_RUNTIMES=”libcxx;libcxxabi;libunwind” has been added to the CMakeLists.txt of clang17, “libcxx;libcxxabi;libunwind” are not present in LLVM_ENABLE_PROJECTS now
while in clang15 CMakeLists.txt “libcxx;libcxxabi;libunwind” were present in LLVM_ENABLE_PROJECTS
Pandey Tejpratap is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.