mingw和gnuplot冲突--win32
今天写了一个C++程序,按照以往的习惯编译,Windows报“XXX.exe已停止工作”,gdb单步执行的时候,在一条声明语句处出现了下面的信息:
Program received signal SIGSEGV, Segmentation fault.
0x6fc89edc in libstdc++-6!_ZNSsC1Ev ()
from d:\Program Files\gnuplot\bin\libstdc++-6.dll
原来是编译时链接的dll和运行时的dll不是同一个,这个地方应该是mingw下的c++库,结果却变成了gnuplot下的库了
解决办法:
(1)用静态链接,g++用选项-static-libgcc -static-libstdc++
(2)把gnuplot从环境变量path中去掉
Actually, Eclipse linked against C:\mingw\bin\libstdc++-6.dll but when executing, another one was used (i.e. C:\Program Files\gnuplot\bin\libstdc++-6.dll >_<) because gnuplot (that I installed a long time ago, nice piece of software by the way ;) ) added its installation directory to the PATH (even though C:\mingw\bin was in the PATH too) (it added some other environment variables as well)
http://stackoverflow.com/questions/6404636/libstdc-6-dll-not-found
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, so I've found this approach the quickest and cleanest solution to creating Windows binaries.
--
顺便发现了一个小工具