I tried to make a simple demo program that use zlib to compress & decompress files, but when I link the file, Visual Studio 2010 linker gave me this error:
Error 2 error LNK1313: ijw/native module detected; cannot link with pure modules
When I tried to change /clr:pure to just /clr. the program compiles and runs, but gave me a run time error:
“The application was unable to start correctly(0xc000007b). Click OK to close the application.”
This is my code so far for just getting zlib version in balloon tip:
String^ info = gcnew String(reinterpret_cast<const char*>(zlibVersion()));
notify->ShowBalloonTip(20000, "Zlib Version", info, ToolTipIcon::Info );
Can you help me figure out what happened to zlib and what is that error. Thanks
If you’re targeting the CLR I strongly recommend using a native (to the CLR) Zipping/Zlib library, such as DotNetZip, rather than trying to shoehorn a native library into doing what you want.
I’m not a C++/CLI expert, so this might be entirely wrong, but I believe
String^ info = gcnew String(reinterpret_cast<const char*>(zlibVersion()));results in undefined behavior. The reason is that the
System::Stringconstructor expects an array ofSystem::Charobjects, not C++’schardata type.System::Charis two bytes wide,charis a single byte wide (System::Stringsupports Unicode; zlib does not). (In any case,reinterpret_castis a major red flag — why are you using that cast here?)Also, error 0x7B is
(The 0xC is there probably because it’s an NTSTATUS code) Make sure that if you’re using the dynamically linked version of Zlib that the DLL is available for your program to open somewhere.