关于MinGW GCC编译C++程序动态链接到libgcc_s_dw2-1.dll的问题

如果你使用MinGW GCC 4.4.0默认选项编译C++程序,就会动态链接到libgcc_s_dw2-1.dll,编译后的执行文件运行时会出现错误:

关于MinGW GCC编译C++程序动态链接到libgcc_s_dw2-1.dll的问题_第1张图片

 

其中的原因:

Dynamic linking with libgcc_s_dw2-1.dll is necessary to throw exceptions between different modules, such as between two DLLs or a DLL and an EXE. Consequently, it is the default for all languages other than C.

 

解决办法:

To disable this dynamic linking, use -static-libgcc. To enable this dynamic linking in C, use-shared-libgcc.

 

Eclipse中参数设置方法:
To add this flag in Eclipse, go to Project->Properties. Under "C++ Build", select "Settings". Under "MinGW C++ Linker", select "Miscellaneous". Add "-static-libgcc" to the "Linker flags" field. You may have to do this for your other build configurations and projects.

你可能感兴趣的:(跨平台)