PDA

View Full Version : Library woes - can't be found



waynew
22nd November 2010, 23:05
Still trying to get this external library working.
Here is the pro file entry:


LIBS += -L"C:\mingw\msys\1.0\home\wayne\tqsllib\lib"
LIBS += -llibtqsllib


And here is the compile error message:
c:/qt/2010.02.1/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../../mingw32/bin/ld.exe: cannot find -llibtqsllib

And here is the line from the Makefile.Release:
LIBS = -L'c:/Qt/2010.02.1/qt/lib' release/hrlogger_res.o -LC:\cpp\qt_projects\hrlogger_development\debug\bui ld\lib\qserialdevice\release -LC:\cpp\qt_projects\hrlogger_development\debug\bui ld\lib\qserialdevicewatcher\release -lqserialdevice -lqserialdevicewatcher -LC:\mingw\msys\1.0\home\wayne\tqsllib\lib -llibtqsllib -lQtHelp4 -lQtTest4 -lQtSql4 -lQtXml4 -lQtGui4 -lQtNetwork4 -lQtCore4

And the system path variable includes the path to libtqsllib.a
And I have verified the file is there, with that name.

Any ideas?

gowen
22nd November 2010, 23:15
I think that you do not need to put both lines in, it should just be


LIBS += -L"C:\mingw\msys\1.0\home\wayne\tqsllib\lib" -ltqsllib

and you do not need to add the lib before the library name as the -L tells the compiler it is a library.

waynew
23rd November 2010, 01:31
Well, that is the library file name, libtqsllib.a

After reading some other posts, I changed my pro file entry as a test, to:
LIBS += "C:\mingw\msys\1.0\home\wayne\tqsllib\lib\libtqslli b.a"

Now it compiles without error, but I don't think the library is being included because it fails on the first library call with:
./release/lotwupload.o:lotwupload.cpp::-1: error: undefined reference to `_imp__tqsl_init@0'

tqsl_init() is the first function called in the library.

ChrisW67
23rd November 2010, 02:24
When you say "compiles without error" do you mean compiles and links without error but produces a error message at run time, or is that message coming from the linker (i.e. after the compile stage but not at run time).

If tqsllib is a dynamic library the the corresponding DLL must be available in the program directory or on the system PATH of the executing process. Getting this wrong will cause a run time error.

The .a file must be locatable during linking in a standard location (compiler dependent), in a location specified by a -L path, or in an explicitly identified location. When searching the built in or user paths the name specified by -lname will have "lib" prepended and ".a" appended (as gowen pointed out). The libtqsllib.a file does not need to be in the system PATH or available at run time. Getting this wrong will cause a linker error.

waynew
23rd November 2010, 13:48
I get no build issues, the only error is at run time whne my Qt application tries to access a library function.

I compiled the library from source using mingw/msys with the option --disable-shared so being new to libraries, I am assuming it is static.
The compile output produced both files libtqsllib.a and tqsllib2.dll

What makes me wonder whether the library is being included or not is commenting out the LIBS =+ line in my pro file does not change the size of my Qt application executable that is produced. If not, that would account for the run time error.
How can I tell for sure if the library is being included?

What am I doing wrong here?

waynew
23rd November 2010, 23:30
Have changed my pro file entry to : LIBS += -L"C:\mingw\msys\1.0\home\wayne\tqsllib\lib" -ltqsllib
No build errors.
But when I add the code for the first library function I need:
int ret = tqsl_init();

I get the error at linking:
E:\CPP\QT_Projects\HRLogger_Development/lotwupload.cpp:23: undefined reference to `_imp__tqsl_init@0'

But when I change the pro file to:
LIBS += -L"E:\mingw\msys\1.0\home\wayne\tqsllib\bin" -ltqsllib2
It appears to compile and link ok.
But at run time, the application crashes before the main window opens.