Compile libraw on windows 7



  • Hi,

    Since Qt does not support raw image file, I downloaded LibRaw-0.17.2.zip and
    tried to compile on Windows 7. I installed mingw32 which comes with Qt5.6.2
    and installed MSYS.
    As instruction said, I did
    sh ./configure
    make
    when I compile by 'make', I got the following error message.

    src/libraw_c_api.cpp: In function 'int libraw_get_color_maximum(libraw_data_t*)':
    src/libraw_c_api.cpp:333:12: warning: 'int libraw_get_color_maximum(libraw_data_t*)' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
    make: *** [src/libraw_c_api.lo] Error 1

    I just see warnings, but it spew error at the end.
    Does anyone who compiled libraw on Windows encountered the similar problem?



  • @samdol

    Inside LibRaw-0.17.2 directory, I found a script called "Makefile.mingw" Using
    this file I excuted
    mingw32-make -f makefile.mingw
    And I could got libraw.a under lib directory.
    Now I intend to use libraw.a to make qtraw plugin.
    I downloaded qtraw-master.zip from github
    https://github.com/mardy/qtraw
    and extract it and move to the
    directory. I created "libraw" directory inside and put header files(libraw.h,
    libraw_const.h...) and put libraw.a to "libraw/win32" directory.

    But when I try to build the libraw plugin, I got the message
    Project ERROR: libraw development package not found
    It seems
    PKGCONFIG += libraw
    in .pro file cause this problem.
    So if I remove that line and build again, I got another error message
    undefined reference to '_imp__ZTV26LibRaw_abstract_datastream'
    I have no idea what to do next.
    The following is my .pro file
    include(../common-config.pri)

    TARGET = qtraw
    TEMPLATE = lib
    CONFIG +=
    link_pkgconfig
    plugin
    DESTDIR = imageformats

    PKGCONFIG +=
    libraw

    HEADERS +=
    datastream.h
    raw-io-handler.h
    SOURCES +=
    datastream.cpp
    main.cpp
    raw-io-handler.cpp
    OTHER_FILES +=
    raw.json

    target.path += $$[QT_INSTALL_PLUGINS]/imageformats
    INSTALLS += target

    kde_desktop.files = raw.desktop
    kde_desktop.path = $${INSTALL_KDEDIR}/share/kde4/services/qimageioplugins/
    INSTALLS += kde_desktop

    unix:!macx:!symbian: LIBS += $$PWD/libraw/linux/libraw.a
    else:macx: LIBS += $$PWD/libraw/macx/libraw.a
    else:win32: LIBS += $$PWD/libraw/win32/libraw.a
    QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6


  • Lifetime Qt Champion

    Hi,

    You need to pass the include dir as well as library dir when you are compiling the plugin inside the sources.



  • @SGaist
    It seems the line
    PKGCONFIG +=
    libraw
    in src.pro causes the problem. I don't know exactly what PKGCONFIG means but
    after googling it seems setting system library. So I commented out those two lines and compiled again, then I got another error message,

    release/datastream.o:datastream.cpp:(.text+0x1): undefined reference to _imp___ZTV26LibRaw_abstract_datastream' release/datastream.o:datastream.cpp:(.text+0x117): undefined reference to_imp___ZTV26LibRaw_abstract_datastream'
    c:/Qt/Qt5.6.2/Tools/mingw492_32/bin/../lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/bin/ld.exe: release/datastream.o: bad reloc address 0x0 in section `.rdata$_ZTI26LibRaw_abstract_datastream[__ZTI26LibRaw_abstract_datastream]'
    collect2.exe: error: ld returned 1 exit status
    Makefile.Release:68: recipe for target 'imageformats/qtraw.dll' failed
    mingw32-make[2]: Leaving directory 'd:/qqes/qtraw-master/build-qtraw-Desktop_Qt_5_6_2_MinGW_32bit-Release/src'
    Makefile:34: recipe for target 'release' failed
    mingw32-make[1]: Leaving directory 'd:/qqes/qtraw-master/build-qtraw-Desktop_Qt_5_6_2_MinGW_32bit-Release/src'
    mingw32-make[2]: *** [imageformats/qtraw.dll] Error 1
    mingw32-make[1]: *** [release] Error 2
    makefile:39: recipe for target 'sub-src-make_first' failed
    mingw32-make: *** [sub-src-make_first] Error 2

    I don't know what to do with this.


  • Lifetime Qt Champion

    It's for the pkg-config tool that is not standard on Windows but that you can install.

    Hence you need to add to LIBS the path and library to link to for libraw.



  • @SGaist

    I think I added the path and library to LIBS as
    else:win32: LIBS += $$PWD/libraw/win32/libraw.a


  • Lifetime Qt Champion

    LIBS += -L$$PWD/libraw/win32/ -lraw



  • @SGaist
    The contents of libraw.pc.in is

    prefix=@prefix@
    exec_prefix=@exec_prefix@
    libdir=@libdir@
    includedir=@includedir@

    Name: libraw
    Description: Raw image decoder library (non-thread-safe)
    Requires: @PACKAGE_REQUIRES@
    Version: @PACKAGE_VERSION@
    Libs: -L${libdir} -lraw -lstdc++@PC_OPENMP@
    Cflags: -I${includedir}/libraw

    so I set
    INCLUDEPATH += $$PWD/libraw
    LIBS += -L$$PWD/libraw/win32/ -lraw -lstdc++
    but that gives me the same error.


  • Lifetime Qt Champion

    Which version of MinGW did you use to build libraw ?



  • @SGaist
    I used mingw 4.9.2.


  • Lifetime Qt Champion

    The one provided with Qt ?



  • This post is deleted!


  • @SGaist
    Yes, It came with 5.6.2


  • Lifetime Qt Champion

    Can you check against the latest version of LibRaw ?

    There might be a problem with their handling of the imported/exported symbol.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.