Zlib with LibRaw 18.0.

Hi,

I understand ZLIB is an external dependency for libraw 18.0 (the master branch). I've downloaded and built zlib 1.2.8 from http://www.zlib.net/ following this tutorial:

http://www.tannerhelland.com/5076/compile-zlib-winapi-wapi-stdcall/

except while doing the first and second steps I added /SAFESEH in both masmx86 and masmx64 since I was going to build this for 64 bit windows. Opened .sln with visual studio 13 changed the flags to /MT (for static build), created x64 version of configuration and built it.

Later I added zlibstat.lib and zlibwapi.lib (These were the only two libs that got generated) as dependency for libraw -> built libraw (x64 configuration and /MT flag). The build still asked for zlib.h and zconf.h. So I did the stupid thing and copied the files to libraw directory. This built everything, but when I tried opening libraw.dll with dependency walker (http://www.dependencywalker.com/) to see if all dependencies were built correctly I got that ZLIBWAPI.DLL is missing.

Any idea what may be causing this problem? Any help will be much appreciated. Thanks.

--Karo

Forums: 

zlib.h, zconf.h

I just added include path to build specification, but I'm still getting the same error.

In our Windows programs

In our Windows programs (RawDigger, FastRawViewer) we use zlib build by zlib's win32\Makefile.msc

No extra zlibwapi.lib is used, just zlib.lib (not zdll.lib which points to zlib.dll)

-- Alex Tutubalin @LibRaw LLC

Thank you for your answer,

Thank you for your answer,

if you're using win32\Makefile.msc doesn't that mean that the build will be for 32bit systems? Can you later link to a x64 project?

If not, is there a way around the issue or should I just use the latest release?

I think I managed to overcome my previous problem, and build LibRaw, but when I try to link it to my VS project I g and compile it can't find the definitions of functions I'm trying to use. e.g.

: error LNK2019: unresolved external symbol "__declspec(dllimport) public: __cdecl LibRaw::LibRaw(unsigned int)" (__imp_??0LibRaw@@QEAA@I@Z) referenced in function myFunction

win32\Makefile.msc works ok

win32\Makefile.msc works ok for both 32 and 64 builds. Just use it from corresponding Visual studio shell (32 or 64-bit).

Link error: do you use LibRaw as static or as dynamic (dll) build?

-- Alex Tutubalin @LibRaw LLC

For static build you need to

For static build you need to define LIBRAW_NODLL for both library build and library use.

The trick is in libraw/libraw_types.h (see how DllDef is defined)

-- Alex Tutubalin @LibRaw LLC

I'm not sure I understand, is

I'm not sure I understand, is LIBRAW_NODLL a pre-processor or linker option? The dllDef is defined just as DllDef if LIBRAW_NODLL is defined.

This is preprocessor option,

This is preprocessor option, of course.

Without this define
DllDef is defined as:
__declspec( dllexport ) - for DLL build
and as
__declspec( dllimport ) - for your app build.

So, it works as expected: DLL exports symbols and your app imports it.

If you define LIBRAW_NODLL (for both library build and for your app build)
DllDef is defined as empty string.
So, in library this is 'just' usual functions (without extra dllexport attributes)
And your app expects just usual functions, not dllimport

-- Alex Tutubalin @LibRaw LLC

That resolved several issues.

That resolved several issues. Thanks. I still can't properly compile though. It throws errors such as

libraw.lib(libraw_cxx.obj) : error LNK2019: unresolved external symbol uncompress referenced in function "protected: void __cdecl LibRaw::deflate_dng_load_raw(void)" (?deflate_dng_load_raw@LibRaw@@IEAAXXZ)

\Working-pc-13882-12680-2708-1\RAWTools.dll : fatal error LNK1120: 1 unresolved externals

CreateLibrary::cmperr: Compile error: libraw.lib(libraw_cxx.obj) : error LNK2019: unresolved external symbol uncompress referenced in function "protected: void __cdecl LibRaw::deflate_dng_load_raw(void)" (?deflate_dng_load_raw@LibRaw@@IEAAXXZ)

CreateLibrary::cmperr: Compile error: C:\Users\HP\Documents\rawtools\build\RAWTools\LibraryResources\Windows-x86-64\Working-pc-13882-12680-2708-1\RAWTools.dll : fatal error LNK1120: 1 unresolved externals

Thanks for your patience and

Thanks for your patience and answers. The problem was in zlib. So I decided to do what you said I build zlib by zlib's win32\Makefile.msc using VS x64 Native tools shell. It generated a lot of libs

minizip.lib
miniunz.lib
testzlibdll.lib
zlibstat.lib
testzlib.lib
zlibwapi.lib
zlib.lib
zdll.lib

Now I should add everything except zdll.lib and testzlib.dll to my LibRaw build ?

Thank you very much, it all

Thank you very much, it all worked.

I just noticed that the post about LibRaw 18 is three months old, were there any significant changes to the source since then?

We'll put next 'massive

We'll put next 'massive update' on Github in March or so.

-- Alex Tutubalin @LibRaw LLC