2

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?

aleroot
  • 71,077
  • 30
  • 176
  • 213
Kevin Mangold
  • 1,167
  • 8
  • 21
  • 1
    If I am not wrong, MS VS compiled files (binary or library) are not compatible with MinGW and the some for MinGW. – SIFE Mar 12 '12 at 19:11
  • You're linking files compiled with GCC using VC++? That's gutsy, and I would have said impossible. Sounds like the cause of your problem is that MinGW compiled with the debug DLL for both your release and debug configurations. It's Undefined Behavior if any of the files are compiled with different settings/libraries/compilers. – Mooing Duck Mar 12 '12 at 19:13
  • This works just fine, in both Release/Debug mode on VS2008 using libmsvcr90(d).a. This debug/release inconsistency is new to 2010. – Kevin Mangold Mar 12 '12 at 19:24
  • I would agree not possible if I was using VS compiled files within GCC/MinGW, but this is the other way around. GTK+ and Qt are both compiled using MinGW and are able to be used by VS, so it's definitely possible... – Kevin Mangold Mar 12 '12 at 19:37

1 Answers1

2

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).