PDA

View Full Version : Adding an existing library to a project.



cashnir
21st April 2017, 20:30
Hello everyone.

I am trying to create a project assosiated wtih the SimConnect SDK.

I am new to QT, and in Visual Studio, i just had a SimConnect.h file, a .lib file, and a .dll file, and i managed to make it work.
Now I am trying to create a c++ widget project, using the same SDK, but in QT.

I put the header file in my QT project's folder, where the other default code and header files are located, and then I went to the project and added them as existing files, as I read in google.
Im having problems with the actual library.

I've been searching Google all day long for a guide on how to add a library file to the project, I did some things i saw on the internet, like the LIBS line for example, but I probably did it wrong, even though it looked very simple.
I am not sure where to drop my dll/library files in the project directory, maybe the problem is I always put them in the wrong spot.
The closest I got to, was an error message saying "Unresolved external symbol" on every function i tried to use from the SimConnect functions, which probably means QT couldnt find my library/dll file.

I also tried to add the libraries from the "Add library" option in the project, but that didnt work too.

Usualy I would add some code to the thread, but there actualy is no real code to add.

I will open a new widget project, and will follow anything you guys say :)
Thanks!

wysota
21st April 2017, 21:57
Assuming you are using qmake to build your project, you need to add a LIBS directive to tell the compiler to link against your library. If the library is placed in a directory not usually looked into by the linker, you need to inform the compiler about that location (by adding a -L<directory> entry to LIBS).

cashnir
21st April 2017, 22:04
Assuming you are using qmake to build your project, you need to add a LIBS directive to tell the compiler to link against your library. If the library is placed in a directory not usually looked into by the linker, you need to inform the compiler about that location (by adding a -L<directory> entry to LIBS).

I think I tried that already, in the .pro page I wrote
LIBS += -L(path to lib file's directory) -llibname
It still writes "unresolved external....."
I guess its something small im missing, hopefully.
Thanks for the reply :)

d_stranz
22nd April 2017, 18:16
(path to lib file's directory)

Does this path have spaces in it? If so, you probably need to put it in quotes. What is the actual name of the library?

wysota
22nd April 2017, 19:09
What is the actual error you are getting? Did you verify the library exports that missing symbol?