I am using cmake to generate a Eclipse CDT MinGW Project. (Eclipse Version Kepler)

This is my Cmakelist:

project(IMGTODICOM)

find_package(ITK REQUIRED)

include(${ITK_USE_FILE})

add_executable(IMGTODICOM IMGTODICOM.cxx)

target_link_libraries(IMGTODICOM ITKReview ${ITK_LIBRARIES})

The code compile and run without problem in my computer, but in other PC it does not run. Some dll like libgcc_s_dw2-1.dll are required. I looked for this dll in my computer and I found it in C:\MinGW\bin. To solve the problem I copied the content of this folder in the other PC and the exe file finally run. However, I am wondering if there is a better method to run the exe file in any windows pc adding these libraries in the compilation process.

I was reading and I should make that the compiler link to a static library. In Eclipse I tried to add the dll under properties>C/C++ Include Path and Symbols and under project Path>Libraries, but it does not work. I tried to modify the CmakeList but it also does not work.

I don't know why this problem and how can I include the content of C:\MinGW\bin in the exe file.

Many Thanks for any help

有帮助吗?

解决方案

Yes, there is a way. For pure C code:

set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static")

For C++ code:

set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static")
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top