using zlib with Visual Studio 2010
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::String
constructor expects an array of System::Char
objects, not C++'s char
data type. System::Char
is two bytes wide, char
is a single byte wide (System::String
supports Unicode; zlib does not). (In any case, reinterpret_cast
is a major red flag -- why are you using that cast here?)
Also, error 0x7B is
The filename, directory name, or volume label syntax is incorrect.
(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.
精彩评论