How do I pass arugments to the compile in Clion?
已回答
I have looked over the internet, forums and even asked chatGPT and nothing seems to work? How do I add those flags
-fsanitize=address,undefined -Wall -Werror
I originally added to the Cmakelist.text
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address, undefined")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
However, it throws an error cause undefined is there? removing undefined fixes the error but when I try to get an index out of bounds error nothing happens ;'C
Also please let me know if you would recommend other flags lets the compiler tell you something is wrong.
请先登录再写评论。
Db988
1) The second point of the instruction states "Set Architecture to x86_amd64". According to the provided screenshot, you haven't done it.
2) According to
"C:\Program Files\JetBrains\CLion 2022.3.1\bin\cmake\win\x64\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug
you still use the Debug profile, while you need to use the Release profile.
Please select the Release profile in the Run/Debug configuration switcher:
3) Remove the following line from the CMakeLists.txt
4) Add the following line to the CMakeLists.txt
You need to remove the space between `address` and `undefined`.
Thank you Andy for getting back to me, I truly appreciate it.
I have followed your advice however, I get a different kind op error when I try to run my program
The error I get.
Also, I wanted to double check that I must be using Clang Cli instead of GCC, as sanitization isn't available on GCC on windows, is that. correct?
Thank you!
OK so you need to link against the `asan` library in order to find those symbols. See target_link_libraries.
Db988 please take a look at our web help article - https://www.jetbrains.com/help/clion/google-sanitizers.html. On Windows it's possible to use Google sanitizers only in the two following cases:
Okay, thank you for clarifying Anna, I am using MSVC+Clang-cl Toolchain, however I have no idea what the error above means, would you mind helping me?
Db988 please follow the corresponding instruction - https://www.jetbrains.com/help/clion/google-sanitizers.html#clang-cl-configure
Anna Falevskaya I have followed it, which meant I add these new lines into the Cmakelists.txt file
The flags work fine, they give me errors when I am not doing what I am supposed to do. However building and running the projects gives me these errors
I don't know how to fix it? Why is this more difficult than it should be: C, is there and IDE has a simple button I can click 🥺😭
Db988
Anna Falevskaya
"C:\Program Files\JetBrains\CLion 2022.3.1\bin\cmake\win\x64\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug "-DCMAKE_MAKE_PROGRAM=C:/Program Files/JetBrains/CLion 2022.3.1/bin/ninja/win/x64/ninja.exe" "-DCMAKE_C_COMPILER=C:/Program Files/LLVM/bin/clang-cl.exe" "-DCMAKE_CXX_COMPILER=C:/Program Files/LLVM/bin/clang-cl.exe" -DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32 -G Ninja -S C:\Users\danie\CLionProjects\untitled -B C:\Users\danie\CLionProjects\untitled\cmake-build-debug-1
-- The C compiler identification is Clang 15.0.7 with MSVC-like command-line
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/LLVM/bin/clang-cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
CMAKE_CXX_COMPILER
CMAKE_CXX_FLAGS
-- Build files have been written to: C:/Users/danie/CLionProjects/untitled/cmake-build-debug-1
[Finished]
Anna Falevskaya
Thank you so much it works now but there is a problem, nothing is printing at all.
the console became read only as well?
As you can see, there is the error - "Process finished with exit code -1073741515 (0xC0000135)". The 0xc0000135 error indicates that the application failed to find a DLL file required for the program to operate correctly, so the program could not start.
There are several ways to solve the issue:
Run | Edit Configurations ...
, select your run/debug configuration and try adding C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/Llvm/x64/lib/clang/15.0.1/lib/windows to thePATH
environment variable in theEnvironment Variables
field (likePath=xxx;$Path$
, wherexxx
is the path to that directory).set(CMAKE_EXE_LINKER_FLAGS "-static")
to the CMakeLists.txt.Anna Falevskaya, I have followed the steps you mentioned above and, now I get a different error code.
I have applied all methods and the only one that seems to work (changing the error code) is step 2. Attached below are screenshots of me applying each method.
I have also searched the error code online and found that it could be cause by my office 360 not update, or corrupted windows files both of which I have checked and restarted my computer after. I just wanted to say I appreciate you helping me, and honestly putting the time and effort out of your day just to help me 😊
In the "Environment Variables" window the second column is called "Value". It means you need to specify only the value of the variable in this column, without Path= :
The format
Path=xxx;$Path$
should be used only if you specify it right in the "Environment variables" field:Anna Falevskaya Thank you for replying,
I did just that, but I still get the same error code. I also updated my graphics driver, but it still wont work. I retried doing the same steps on a second computer with a clean install of windows but it also wont work.
Here is the error on my second computer. I know its a path issue, I even tried adding the path of that file to system variables which then became grayed out??