I want to use functionality of a math library ALGLIB and it's offered in .h and .cpp files. So I build it and added all the .o files to alglib.a. I copied it to my source directory and added these lines to my .pro file:
INCLUDEPATH += /path/to/ALGLIB/cpp/src
LIBS += -Lalglib
Well - I still get those "undefined reference to ..." errors when trying to build.
-L sets a directory in which the linker should search for libraries.
-l sets a library file to link in the following way: -lalglib will look for a file named libalglib.a in all directories that are set with -L
Adding a file to LIBS without anything will link that exact file.
So either:
LIBS += alglib.a
or, provided that the alglib file name is libalglib.a:
LIBS += -Lalglib-directory -lalglib
Related
I download libharu.zip, try to include it into QT creator c++.
But I don't have lib*.a files in libharu. What do I need to do? It has some makefiles etc.
I find some info about makefile, but don`t understand how it works in QT creator.
nmake -f Makefile.win
What do I need to run this command?
You will need a .so or a .a for linking, in qt creator edit your .pro:
INCLUDEPATH += <path_to_lib>/your_lib_include
When you have a .so for linking:
LIBS += -L<path_to_lib> -l<libname>
When you have a .a for linking:
LIBS += <path_to_lib>/libname.a
I want to use tensorflow_cc library in QT creater
I tried linking the libtensorflow_cc.so in .pro file but I'm still unable to access the header files.
test.pro file:
LIBS += -L/usr/local/lib/ -ltensorflow_cc
INCLUDEPATH += /usr/local/lib/
test.cpp file:
#include <tensorflow/core/platform/env.h>
error :
tensorflow/core/platform/env.h: No such file or Directory
I have added the path of the .so file to LD_LIBRARY_PATH. Is there anyway to include the tensorflow library and use the header files in QT.
This is a similar question but it didn't quite help me.
Thanks!
Add this to the .pro file:
LIBS += /usr/lib/libtensorflow_cc.so
In my .pro file in Qt project, I have used these two lines for adding necessary LIBS.
LIBS += -L "../../lib/bin/libname.a"
LIBS += -L "../../rfm2g/winver/libname.lib"
error: ../../rfm2g/winver/libname.lib: No such file or directory
The compiler found the file libname.a, but could not find the libname.lib, although the relative path for both files is correct. Does anybody have an idea?
The -L option wants a directory for -l to search, not the path to the actual library.
So you should either write e.g.
LIBS += -L../../lib/bin -lname
LIBS += -L../../rfm2g/winver -lothername
Or link with them directly
LIBS += ../../lib/libname.a
LIBS += ../../rfm2g/winver/libname.lib
Also make sure that the paths actually are correct. If you change to the build directory, and try to list the files (using ls or dir depending on platform) using the paths you have, can you list both files?
I have referenced the following libraries, but Qt Creator v3.0.1 can't seem to find them.
LIBS += -lueye_api \
-lcv \
-lhighgui
Is it that the libraries have been deprecated? Are there any replacements for these three libraries?
I've google searched my problem and found what may be a start. Is -lopencv_core a suitable replacement for -lcv and is -lopencv_highgui a suitable replacement for -lhighgui?
When the library the project refers to cannot be found in the same directory as .pro file it is practical to refer to other libraries somehow relative to project file directory.
LIBS += -L$$PWD/../third-party -lother
Where the project file directory is located relative to third-party like that:
../project
../third-party
and the other.lib is in:
../third-party/other.lib
Or you just need to provide the path to libraries you use somehow.
I'm using Qt Creator 2.7.0 on ubuntu 13.04.
I've just recently ran into the idea of using libraries, and they're a whole new thing for me.
I've just figured that I need to have the following in my application's .pro file to use a library of my own:
LIBS += -L<lib's dir> -l<lib's name>
INCLUDEPATH += <headers' dir>
// for example:
LIBS += -L$$PWD/../MyLib/release/ -lMyLib
INCLUDEPATH += $$PWD/../MyLib/src/
As you see, I have all my projects in a folder called Programming (the .. in this case)
Each of my project have .pro and .pro.user files in the root, source files in a sub folder /src and the release in an other sub folder /release.
So, this is what my Programming folder looks like:
Programming
MyLib
MyLib.pro
MyLib.pro.user
src
myclass.h
myclass.cpp
release
libMyLib.a
Makefile
myclass.o
MyApp
MyApp.pro
MyApp.pro.user
src
main.cpp
release
main.o
Makefile
MyApp
However, I figured that I could create a folder Programming/libs/, and add libMyLib.a and myclass.h files inside that libs folder.
I would do the same for all of my libraries, and then I could always include them like this:
LIBS += -L$$PWD/../lib/ -lMyLib
INCLUDEPATH += $$PWD/../lib/
The problem is, I'd get include path for every library stored on my computer and the libs folder would become a mess, especially if there are two headers with same name on different libraries.
I'm really new to using libraries, is there a general solution on how they should be located on your computer, and how to include them into your projects?
You could mimic libraries like Boost and have a directory tree like this:
MyLib
build
Makefile, .pro or .sln file here
lib
MyLib
// your .so / .a here
include
MyLib
// your .h here
src
// your .cpp here
CMake or qmake file here
This way you have an out-of-source build tree (in build/) so that your binary files are not mixed up with your source files.
The lib/ and include/ directories are handy because you can then define an install build target. If you then type
make install
it will copy everything to usr/local/lib and user/local/include so that your App can simply do #include <MyLib/some_header.h> and you can link directly against your library binaries (because you copied everything to a location in your system wide path). There is also no danger of name clashes because you wrapped it inside your own MyLib subdirectory.