Compile and use with mingw

Hello,
May I ask a question about using libraw with mingw?
My OS is Windows 7 and I installed MSYS and mingw492_32.
I download LibRaw-0.17.2.zip and extract it.
On command prompt, I executed
sh ./configure
mingw32-make -f Makefile.mingw
and could get lib\libraw.a

I tried to test this static library with simple_dcraw.cpp in samples folder.
g++ simple_dcraw.cpp -o simple.exe -Ilibraw -Llib -lraw

I got the following error messages:

C:\Users\ssd\AppData\Local\Temp\ccQ5HLLa.o:simple_dcraw.cpp:(.text+0x6e): undefined reference to `_imp___ZN6LibRawC1Ej'
C:\Users\ssd\AppData\Local\Temp\ccQ5HLLa.o:simple_dcraw.cpp:(.text+0x82): undefined reference to `_imp___ZN6LibRaw11cameraCountEv'
C:\Users\ssd\AppData\Local\Temp\ccQ5HLLa.o:simple_dcraw.cpp:(.text+0x8b): undefined reference to `_imp___ZN6LibRaw7versionEv'
C:\Users\ssd\AppData\Local\Temp\ccQ5HLLa.o:simple_dcraw.cpp:(.text+0x267): undefined reference to `_imp___ZN6LibRaw10cameraListEv'
C:\Users\ssd\AppData\Local\Temp\ccQ5HLLa.o:simple_dcraw.cpp:(.text+0x2f7): undefined reference to `_imp___ZN6LibRaw9open_fileEPKcx'
C:\Users\ssd\AppData\Local\Temp\ccQ5HLLa.o:simple_dcraw.cpp:(.text+0x315): undefined reference to `_imp__libraw_strerror'
C:\Users\ssd\AppData\Local\Temp\ccQ5HLLa.o:simple_dcraw.cpp:(.text+0x363): undefined reference to `_imp___ZN6LibRaw6unpackEv'
C:\Users\ssd\AppData\Local\Temp\ccQ5HLLa.o:simple_dcraw.cpp:(.text+0x37e): undefined reference to `_imp__libraw_strerror'
C:\Users\ssd\AppData\Local\Temp\ccQ5HLLa.o:simple_dcraw.cpp:(.text+0x3d0): undefined reference to `_imp___ZN6LibRaw12unpack_thumbEv'
C:\Users\ssd\AppData\Local\Temp\ccQ5HLLa.o:simple_dcraw.cpp:(.text+0x3eb): undefined reference to `_imp__libraw_strerror'
C:\Users\ssd\AppData\Local\Temp\ccQ5HLLa.o:simple_dcraw.cpp:(.text+0x4b5): undefined reference to `_imp___ZN6LibRaw18dcraw_thumb_writerEPKc'
C:\Users\ssd\AppData\Local\Temp\ccQ5HLLa.o:simple_dcraw.cpp:(.text+0x4d3): undefined reference to `_imp__libraw_strerror'
C:\Users\ssd\AppData\Local\Temp\ccQ5HLLa.o:simple_dcraw.cpp:(.text+0x51d): undefined reference to `_imp___ZN6LibRaw13dcraw_processEv'
C:\Users\ssd\AppData\Local\Temp\ccQ5HLLa.o:simple_dcraw.cpp:(.text+0x533): undefined reference to `_imp__libraw_strerror'
C:\Users\ssd\AppData\Local\Temp\ccQ5HLLa.o:simple_dcraw.cpp:(.text+0x60c): undefined reference to `_imp___ZN6LibRaw21dcraw_ppm_tiff_writerEPKc'
C:\Users\ssd\AppData\Local\Temp\ccQ5HLLa.o:simple_dcraw.cpp:(.text+0x62a): undefined reference to `_imp__libraw_strerror'
C:\Users\ssd\AppData\Local\Temp\ccQ5HLLa.o:simple_dcraw.cpp:(.text+0x661): undefined reference to `_imp___ZN6LibRaw7recycleEv'
C:\Users\ssd\AppData\Local\Temp\ccQ5HLLa.o:simple_dcraw.cpp:(.text+0x684): undefined reference to `_imp___ZN6LibRawD1Ev'
C:\Users\ssd\AppData\Local\Temp\ccQ5HLLa.o:simple_dcraw.cpp:(.text+0x699): undefined reference to `_imp___ZN6LibRawD1Ev'
C:/Qt/Qt5.6.2/Tools/mingw492_32/bin/../lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/bin/ld.exe: C:\Users\ssd\AppData\Local\Temp\ccQ5HLLa.o: bad reloc address 0xd in section `.text$_ZNSt8auto_ptrISt15basic_streambufIcSt11char_traitsIcEEEC2ERS4_[__ZNSt8auto_ptrISt15basic_streambufIcSt11char_traitsIcEEEC2ERS4_]'
C:/Qt/Qt5.6.2/Tools/mingw492_32/bin/../lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/bin/ld.exe: final link failed: Invalid operation
collect2.exe: error: ld returned 1 exit status

Did I set something incorrectly? And I saw Qt project files on buildfiles. I
tried to compile in Qt, but only gives error messages.

ST

Forums: 

Sorry, could not help

Sorry, could not help

I've tried to install Qt+mingw package (Qt 5.8.0-mingw), it installed, but no make(.exe) in this package.
MSYS/mingw setup looks made for someone who is already 'in context' and know what to do to install it.

Your error messages looks like no libraw library is linked. This may be because you've specified wrong library or library path:
g++ simple_dcraw.cpp -o simple.exe -Ilibraw -Llib -lraw
I assume you're already in samples folder, so right path is -L../lib, not -Llib

To use .pro files you may need to edit .pro files to specify (or disable) jpeg library and rawspeed library

-- Alex Tutubalin @LibRaw LLC

sample code with mingw

Thank you for the response.
You may qt-opensource-windows-x86-mingw492-5.6.2.exe. It has mingw32-make.exe.
I installed it and installed MSYS 1.0.11 where I referenced mingw directory.
After setting the paths to mingw and MSYS, in windows 7 command prompt I compiled libraw by
sh ./configure
mingw32-make -f makefile.mingw
I could get libraw.a (994kb), but not sure whether it is properly compiled or
not.

Because the line
#include "libraw/libraw.h"
in simple_dcraw.cpp suggests that it would be better to put simple_dcraw.cpp to
the parent of samples (../samples), I copied simple_dcraw.cpp to the parent of
samples(../sample) and executed
g++ simple_dcraw.cpp -o simple.exe -Ilibraw -Llib -lraw
at there(../samples). So I think "-Ilibraw -Llib -lraw" seems OK.

1) I've Installed Qt-5.6.2

1) I've Installed Qt-5.6.2-mingw-492
2) Run Qt/Mingw prompt (Qt 5.6 desktop from Start menu), than bash in this window
3) cd /path/to/LibRaw-0.17.2
4) mingw-32-make -f Makefile.mingw (no need to run ./configure, but it does not change Makefile.mingw, so it does not matter).
several bin/*.exe created after that, so both library and samples compiles OK.

The proper command line for samples creation (from Makefile.mingw):

g++ -O4 -I. -w -DLIBRAW_NODLL -DLIBRAW_NOTHREADS -o bin/raw-identify samples/raw-identify.cpp -L./lib -lraw -lws2_32 -lm

(or change to -L../lib if you're compiling within samples folder).

-- Alex Tutubalin @LibRaw LLC

Thank you

I folllowed you instruction, and it works. I have LibRaw-0.17.2\lib\libraw.a
(996KB) and also have several .exe files at LibRaw-0.17.2\bin folder.
When I executed
simple_dcraw.exe -e myfile.raw
I could get myfile.thumb.jpg
So it works properly now. Thank you very much. As you indicated, I think the mistake I did was that I did not put needed compile options like -DLIBRAW_NODLL
-DLIBRAW_NOTHREADS.

ST