Qt Windows 64-bit link fails with many errors

I'm porting my image processing application to Windows 10 with Qt 5.14. The port is complete, everything is functional, except for libraw, where I'm having problems linking the static library.

In your windows native building instructions, you say:

if static linking is necessary, one should link applications with library libraw_static.lib and set the preprocessor option /DLIBRAW_NODLL during compilation.

I downloaded the 64 bit archive with the windows binaries; in the lib folder, I found libraw_static.lib, and linked to it. I also set the preprocessor option, trying both "/DLIBRAW_NODLL" and "DLIBRAW_NODLL." In both cases, the link fails with many, many similar errors. For instance...

undefined reference to '__security_check_cookie' demosaic_packs_st.obj
...
collect2.exe: error: ld returned 1 exit status

In my mac build, I link to "libraw.a" and it all works fine. I'm just trying to get the windows build to do the same.

Here's what the Qt project file has as of now...

LIBS += ../LibRaw-0.19.5/lib/libraw_static.lib
DEFINES += DLIBRAW_NODLL

...I also tried...

LIBS += ../LibRaw-0.19.5/lib/libraw_static.lib
DEFINES += /DLIBRAW_NODLL

The build is definitely finding the library, and the preprocessor options should be getting set. And again, static linking works fine under OSX -- it's just the windows linking that's failing.

Can you help?

Forums: 

Libraries built with

Libraries built with different compilers are *not* compatible under windows (esp. if C++ library is used).

You need either recompile LibRaw from source with your compiler or use precompiled dll (+MSVC runtime)

-- Alex Tutubalin

thank you

I was really trying hard to avoid having to build libraw, but I will give it a shot. Thank you.

We provide both Makefile.msvc

We provide both Makefile.msvc and qmake .pro files, so rebuilding should be easy.

-- Alex Tutubalin

qt .pro file fails

I loaded the .pro file into qt, told it I wanted a 64 bit build, and got errors. I have a screencap of them, but there appears to be no way to attach an explanatory image to a comment here?

libraw/libraw.h: No such file or directory - dcraw_emu.cpp, dcraw_half.c,prostprocessing_benchmark.cpp
jpeglib.h: No such file or directory - defines.h
...

There are more errors, but they are similar. Basically, it isn't finding the includes where they are supposed to be.

On attempting to build

I have the latest MSVC, community edition, installed under Windows 10. I am attempting to build libraw inside a vanilla Windows 10 powershell.

Your directions:

  1. Unpack the distribution package (if you have got no tar+gzip, take the LibRaw distribution package in the .ZIP format) and go to folder LibRaw-X.YYY.
  2. Set the environment parameters so that the compiler/linker would find the libraries and include-files. For Visual C++, this is done by running vcvars32.bat.
  3. Run
    nmake -f Makefile.msvc

There is no "vcvars32.bat" file in the distribution in the base folder, or in the buildfiles folder. Should I be looking somewhere else?

"Makefile.msvc" is present. However, "nmake -f Makefile.msvc" returns an error:

The term "nmake" is not recognized as the name of a cmdlet, function, script file, or operable program

You said:

You need either recompile LibRaw from source with your compiler or use precompiled dll (+MSVC runtime)

A dll imposes issues I wish to avoid. I want the code securely inside the app with no install issues. Hence my desire to build a compile-time linkable library.

soldiering on...

nmake -f returns the following:

fatal error: LNK1112: module machine type 'x86' conflicts with target machine type 'x64'

I don’t see what you are

I don’t see what you are doing and therefore it’s hard to help you.

You need to set-up visual studio build environment corresponding to your build architecture. It could be done via several ways:
- vcvars32/vcvars64 on older Microsoft Visual Studio
- vcvarsall.bat x64 or x86 on newer Visual Studio
- visual studio shell

.bat files mentioned are *not* part of LibRaw but provided with Visual Studio.

I do not know what Visial Studio you use ('latest' is NOT version specification), I do not have Community Edition installed (so I do not know how it differ from other versions), etc, etc,etc.

-- Alex Tutubalin