[SOLVED] Problem with external library linking under Windows
-
Hi,
I'm trying to link BerkeleyDB library (libdb), which I have compiled using MinGW, inside my Qt W32 App (using QtCreator 3.4.1 (MinGW)).
Unfortunately, I'm getting the error "error: cannot find -llibdb-6.1.dll", after compiling, and I'm still not finding any way to solve this issue.This is the library configuration code in the .pro file:
@ win32: LIBS += -LC:/msys/1.0/local/lib/ -llibdb-6.1.dll
else:unix: LIBS += -llibdb @Thanks for your help.
-
Hi, welcome to devnet.
.dll is a shared library loaded at runtime. The compiler and linker need know nothing about it.
LIBS should contain a path to the compile time library (.lib for MSVC and .a for MinGW) and you don't need to specify the file extension so in this case it should be
LIBS += -LC:/msys/1.0/local/lib -llibdb-6.1
, assuming a fileC:/msys/1.0/local/lib/libdb-6.1.a
exists at that location. -
@Chris-Kawa said:
Hi, welcome to devnet.
.dll is a shared library loaded at runtime. The compiler and linker need know nothing about it.
LIBS should contain a path to the compile time library (.lib for MSVC and .a for MinGW) and you don't need to specify the file extension so in this case it should be
LIBS += -LC:/msys/1.0/local/lib -llibdb-6.1
, assuming a fileC:/msys/1.0/local/lib/libdb-6.1.a
exists at that location.Well, I used -llibdb-6.1.dll instead of -llibdb-6.1, because the static library was generated as libdb-6.1.a while the dynamic one was generated as libdb-6.1.dll.a (and I'm using the dynamic one). But, the library file libdb-6.1.dll.a already exists in the C:/msys/1.0/local/lib directory.
-
Ok, tle .dll part got me off track. Hm, if the file is there then it should work.
If I remember correctly the gcc linker (so I guess MinGW too) prepends "lib" automatcally so could you try-ldb-6.1.dll
instead?
Also, just to prove it's not a name problem could you rename it to something like "test.a" and link to-ltest
? -
@Chris-Kawa said:
Ok, tle .dll part got me off track. Hm, if the file is there then it should work.
If I remember correctly the gcc linker (so I guess MinGW too) prepends "lib" automatcally so could you try-ldb-6.1.dll
instead?
Also, just to prove it's not a name problem could you rename it to something like "test.a" and link to-ltest
?Sorry for the late reply.
Yes, It works fine now after changing to -ldb-6.1.dll. Thanks a lot!