Reputation: 53
When I try to run my C++ project in Code::Blocks IDE
, it'll run the program in Windows CMD without any problem. If I try to run the program via Explorer it'll also run in CMD without any problem.
However, if I try to run the exactly SAME program via CLion
, it'll run fine in CLion
itself (CLion
has a builtin terminal, while Code::Blocks
uses Windows CMD). But if I try to run the program via Explorer I get this weird error:
If I press OK:
Anyone knows what the problem is? How do I fix this?
More information:
Code::Blocks
comes as a package with MinGW
. With CLion
I had to manually download a Toolchain. I downloaded and installed MinGW-w64
, because I didn't know anything else and that's what Code::Blocks also used.
The weird part about this is that MinGW-w64 is installed in "Program Files (x86)" and not in "Program Files".
Upvotes: 3
Views: 2795
Reputation: 2660
Add the following to your CMakeLists.txt file in CLion:
set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} "-static")
This will work for gcc, which mingw is based upon. For other linkers, you would have to search for their particular switch for static linking.
Upvotes: 5