Visual Studio 2010 and MinGW

2019-05-25 14:10发布

问题:

I have a bunch of old C code, which I compiled using MinGW, and copied the generated library files to a VS C++ DLL (C++/CLI) Project (named NBIS) directory and added them to the Linker->Input Files setting. The content of this field for each configuration is listed below.

Release Configuration

liban2k.a;libbozorth3.a;libcblas.a;libclapck.a;libf2c.a;libfet.a;libfft.a;libihead.a;libimage.a;libioutil.a;libjpegb.a;libjpegl.a;libmindtct.a;libmlp.a;libnfiq.a;libnfseg.a;libpca.a;libpcautil.a;libutil.a;libwsq.a;libgcc.a;libmingwex.a;libmoldname.a;libmsvcr100.a

Debug Configuration

liban2k.a;libbozorth3.a;libcblas.a;libclapck.a;libf2c.a;libfet.a;libfft.a;libihead.a;libimage.a;libioutil.a;libjpegb.a;libjpegl.a;libmindtct.a;libmlp.a;libnfiq.a;libnfseg.a;libpca.a;libpcautil.a;libutil.a;libwsq.a;libgcc.a;libmingwex.a;libmoldname.a;libmsvcr100d.a

When I compile and run using the debug configuration, it succeeds. When I compile and run using release configuration, I get this error: "Unhandled Exception: System.IO.FileLoadException: A procedure imported by 'NBIS.dll' could not be loaded."

If I change the release configuration's C/C++->Code Generation->Runtime Library to "Multi-threaded Debug DLL (/MDd)", the release configuration is able to successfully compile and run. Has anyone run into a similar issue and has a solution or any guidance on how to troubleshoot this?

回答1:

According to http://msdn.microsoft.com/en-us/library/xe4t6fc1(v=vs.71).aspx, "the Generate Debug Info (/DEBUG) option changes the defaults for the /OPT option from REF to NOREF and from ICF to NOICF." This could be removing symbols that you really need. Set it to NOREF and see what happens (Configuration Properties/Linker/Optimization page).