1

I am creating a small Qt Application which uses an external library. I have the header file and lib file. My pro file is

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = IndexCreator
TEMPLATE = app


SOURCES += main.cpp\
        mainwindow.cpp

HEADERS  += mainwindow.h


win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../ExternalLibrary/ -lHASHLIB
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../ExternalLibrary/ -lHASHLIBd

INCLUDEPATH += $$PWD/../ExternalLibrary
DEPENDPATH += $$PWD/../ExternalLibrary

And I get this error:

12:01:11: Running steps for project IndexCreator...
12:01:11: Configuration unchanged, skipping qmake step.
12:01:11: Starting: "C:\Qt\Qt5.2.1\Tools\mingw48_32\bin\mingw32-make.exe" 
C:\Qt\Qt5.2.1\5.2.1\mingw48_32\bin\qmake.exe -spec win32-g++ -o Makefile ..\IndexCreator\IndexCreator.pro
C:/Qt/Qt5.2.1/Tools/mingw48_32/bin/mingw32-make -f Makefile.Release
mingw32-make[1]: Entering directory 'G:/Projects/PDT/IndexCreator/build-IndexCreator-Desktop_Qt_5_2_1_MinGW_32bit-Release'
g++ -Wl,-s -Wl,-subsystem,windows -mthreads -o release\IndexCreator.exe release/main.o release/mainwindow.o release/moc_mainwindow.o  -lglu32 -lopengl32 -lgdi32 -luser32 -lmingw32 -lqtmain -LG:/Projects/PDT/IndexCreator/IndexCreator/../ExternalLibrary/ -lHASHLIB -LC:\Qt\Qt5.2.1\5.2.1\mingw48_32\lib -lQt5Widgets -lQt5Gui -lQt5Core 
G:/Projects/PDT/IndexCreator/IndexCreator/../ExternalLibrary//HASHLIB.lib: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status
Makefile.Release:80: recipe for target 'release\IndexCreator.exe' failed
mingw32-make[1]: *** [release\IndexCreator.exe] Error 1
mingw32-make[1]: Leaving directory 'G:/Projects/PDT/IndexCreator/build-IndexCreator-Desktop_Qt_5_2_1_MinGW_32bit-Release'
makefile:34: recipe for target 'release' failed
mingw32-make: *** [release] Error 2
12:01:13: The process "C:\Qt\Qt5.2.1\Tools\mingw48_32\bin\mingw32-make.exe" exited with code 2.
Error while building/deploying project IndexCreator (kit: Desktop Qt 5.2.1 MinGW 32bit)
When executing step 'Make'
12:01:13: Elapsed time: 00:02.

I need to use the function from this library.

Mike
  • 47,263
  • 29
  • 113
  • 177
A.J
  • 725
  • 10
  • 33
  • are you sure HASHLIB.lib is created with the mingw toolset and not with a Microsoft toolset? – stijn Mar 16 '14 at 08:14
  • @stijn: I think it is with Microsoft... It is able use the library in visual studio. If so what should i do? – A.J Mar 16 '14 at 08:17
  • http://stackoverflow.com/questions/1138170/use-libraries-compiled-with-visual-studio-in-an-application-compiled-by-g-min – stijn Mar 16 '14 at 08:21
  • @Abin: no, it is not recommended. Cannot you get a mingw variant? – László Papp Mar 16 '14 at 08:29
  • @stijn: links in the above are mostly expired... if i could get the link : If the library is a DLL with a C interface: yes, but you'll have to create your own import library. – A.J Mar 16 '14 at 08:30
  • @LaszloPapp: No, i dont have a source for it – A.J Mar 16 '14 at 08:31
  • 1
    @Abin: you do not necessarily need to have the source. Where does it come from? Don't they offer a mingw variant? If not, you better drop mingw. – László Papp Mar 16 '14 at 08:37
  • @LaszloPapp : Since the HASHLIB.lib was build with RX C compiler, not with Microsoft toolset I was not able to add to the Visual Studio project. And also I am not able to get the mingw variant for the same. So I am writing code myself instead of including HASHLIB.lib. – A.J Mar 22 '14 at 05:55
  • @Abin: you have 6 questions, and no selected answers. This site works the way that if someone provides a correct answer, the people asking questions usually accept one of them. – László Papp Mar 22 '14 at 05:57
  • Is this still unresolved one year later?? – László Papp Dec 21 '14 at 11:14
  • @lpapp: No.. and I left it unresolved. and made my own logic instead of using that lib file... So let me set heading as closed? – A.J Dec 21 '14 at 11:27

1 Answers1

2

It seems that you are mixing mingw (your toolchain setup) and msvc (how hashlib is built). This should be avoided at almost all cost if possible on Windows, even the latest versions.

As you do not seem to have access to the source code, if you cannot get the vendor to supply a mingw version, you either better drop mingw for your project, or hashlib as a dependency.

László Papp
  • 51,870
  • 39
  • 111
  • 135