I have install llvm 16.0 and make it to get the llvm-config.exe .In my powershell, I can see the llvm-config’ s version is 16.0. Now I want to compile my code named ‘llvm_1.cpp’, so I do this in the powershell : clang++ -g -o3 .\llvm_1.cpp llvm-config --cxxflag
. My error is : clang++: error: unsupported option ‘–cxxflag`’ and clang++: error: no such file or directory: ‘llvm-config’ . I don’t know what to do, please help me . If I do this : clang++ -g -o3 .\llvm_1.cpp, it will success.
You have to escape the llvm-config invocation.
clang++ -g -o3 .\llvm_1.cpp “llvm-config --cxxflag”
Or two separate calls:
llvm-config --cxxflags
clang++ -g -o3 .\llvm_1.cpp “output from last call”
Yes I have escaped the llvm-config invocation, it’ s show problem in this page. When I use the two separate calls, llvm-config --cxxflags, it has error like this : -IC:\Program Files\LLVM\include -std:c++17 /EHs-c- /GR- -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -DUNICODE -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS .
Some people told me it’ s beacuse my c++ configuration, but I think my c++ configuration is right , beacuse when I use g++ .\llvm_1.cpp or clang++ .\llvm_1.cpp , it will success.
Windows powershell doesn’t handle backticks the same way a shell does, so you need to run llvm-config first and then run clang with the flags copied from the output of llvm-config.
I think it’ s the key point. I run this code in windows system, and the tutorials could be linux system. Thus I should run in this way: clang++ -g -o3 .\llvm_1.cpp $(llvm-config --cxxflags) , and this works
We are happy to accept patches towards the documentation that makes it clear that Windows works differently.