libstdc++-6.dll is missing

Answered

I have just downloaded CLion and tried to test it. My code runs without any errors. 

I would like to execute the test.exe file without CLion. So I build it with Strg+F9 and then I find the test.exe file in: C:\Users\name\CLionProjects\opl\cmake-build-debug

The problem is if I execute that file, I will get an error from Windows that the file libstdc++-6.dll is missing. What am I doing wrong?

5 comments
Comment actions Permalink

If you are using MingW to compile C++ code on Windows, you may like to add the options -static-libgcc and -static-libstdc++ to link the C and C++ standard libraries statically and thus remove the need to carry around any separate copies of those. Version management of libraries is a pain in Windows.

0
Comment actions Permalink

Thank you for your answer. How exactly do I add -static-libgcc and -static-libstdc++? Sorry, I am very new to this.

0
Comment actions Permalink

You can add them to `CMAKE_<LANG>_FLAGS` (See e.g here https://ecrafter.wordpress.com/2012/04/24/cmake-tutorial-part-2/) or add `<path_to_mingw>\bin` to the PATH before running binary.

 

1
Comment actions Permalink

i had the same problem

adding

set(CMAKE_EXE_LINKER_FLAGS "-static")    

to the cmakelists fixed it .

5
Comment actions Permalink

For CMake3.X+, use this instead

target_link_libraries(your_target_name -static)

 

0

Please sign in to leave a comment.