I'm trying to add net-snmp lib to my project using win7 + cygwin:
Project file seems to contain valid lib and path entries:
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/C:/usr/lib/
-lnetsnmp else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/C:/usr/lib/ -lnetsnmpd
INCLUDEPATH += $$PWD/C:/usr/include DEPENDPATH += $$PWD/C:/usr/include
But I can't build the project, because include file is not found, also it exists under given directory physically (c:/usr/include/net-snmp/net-snmp-config.h)
../snmptest1221313123/main.cpp:1:38: fatal error: net-snmp/net-snmp-config.h: No such file or directory
#include
I've read all "add external lib" topics, but it doesn't help to solve this.
Re-running qmake, re-opening Qt creator, or running qmake -r from terminal doesn't help neither.
Remove $$PWD/ (both from include and libs) and try again: run qmake and rebuild.
so i m trying to setup a movable folder for a Qt project where I 'll have this structure and everything will be dependent ONLY with that content..
project\
script.dat "script to invoke qmake with just a click"
qmake.exe
moc.exe
mkspec\ "win32-msvc2010" copy
common\ "necessary by qmake" copy
project.pro
sources\
main.cpp
etc...
headers\
etc...
depedencies\
Qt\
include\
lib\
dll\
e.g.Boost\
include\
lib\
dll\
as can be seen i want a decent folder structure where the script will append the path to the dlls and set QMAKESPEC etc with respect to the %cd% (PWD) directory of the .pro file...
However the problem arises when i invoke qmake.exe
C:\Users\ardit\Desktop\test>qmake -v
QMake version 3.0
Using Qt version 5.2.1 in C:\build-essential\Qt\5.2.1\msvc2010_opengl\lib
and after that
qmake -tp vc
creates a project that has everything linked to my Qt installation and NOT the folder specified in the pro
visual studio additional include directories:
"include";".";"........\build-essential\Qt\5.2.1\msvc2010_opengl\include";"........\build-essential\Qt\5.2.1\msvc2010_opengl\include\QtGui";"........\build-essential\Qt\5.2.1\msvc2010_opengl\include\QtCore";"debug";........\build-essential\Qt\5.2.1\msvc2010_opengl\mkspecs\win32-msvc2010;%(AdditionalIncludeDirectories)
I havent put the Qt installation in the Path, but still the qmake.exe knows it somewhow (registry perhaps?)...
example .pro file where include\ has copy of Qt5\include\ , lib\ and dll\ as well
TARGET= test
SOURCES += main.cpp\
mainwindow.cpp \
glwindow.cpp
HEADERS += mainwindow.h \
glwindow.h
INCLUDEPATH=$${PWD}\include $$PWD
DEPENDPATH=$${PWD}\include $$PWD
LIBPATH=$${PWD}\lib
LIBS+=-L$$LIBPATH -lQt5Core -lQt5Gui -lQt5Widgets
Sidenote: I m new here so plz dont bash me...
any help appreciated...
I've got a problem with include in a qmake project. In my .pro file I've got:
INCLUDEPATH += "C:\OpenCV\build\include"
and in my cpp :
#include <opencv\cv.h>
The compiler indicates an error:
Cannot open include file: 'opencv\cv.h': No such file or directory
but if I write this in my cpp:
#include "C:\OpenCV\build\include\opencv\cv.h"
it works!
I build the project from within Qt Creator. What am I doing wrong?
You have to run qmake(build->run qmake) to validate changes in the pro file.
Qt creator Adding external library (still: Cannot open include file: 'GL/glew.h')
Your problem may be related to the fact that having backslashes in naked #include directives is undefined behavior.
Do the following.
Replace your include with
#include <opencv/cv.h>
Note the forward slash!
Remove the shadow build directory that Qt Creator has made for you. You will find it above the project directory, its name begins with build-.
Rebuild the project.
Note that this takes care of rerunning qmake.
here's one of my pro files:
# Blah Application
TEMPLATE = app
CONFIG += qt console staticlib debug_and_release
QT -= gui
QT += network sql xml
TARGET = blah
CONFIG(debug, debug|release){
DESTDIR = debug
LIBS += -L../../../lib/core/debug -lcore
} else {
DESTDIR = release
LIBS += -L../../../lib/core/release -lcore
}
DEPENDPATH += . ../../lib ../../../lib/core
INCLUDEPATH += . ../../lib ../../../lib/core
# Library files
HEADERS += mtBlahRTP.h
SOURCES += mtBlahRTP.cpp
# Input
HEADERS +=
SOURCES += main.cpp
The include path points to the RELATIVE directory of my lib files. mtBlahRTP.h and mtBlahRTP.cpp are in ../../lib
I have the same question, before building or running, you should qmake(Build=>qmake) it.
My configurations for INCLUDEPATH:
INCLUDEPATH+=D:\opencv\opencv\build\include
INCLUDEPATH+=D:\opencv\opencv\build\include\opencv
INCLUDEPATH+=D:\opencv\opencv\build\include\opencv2
I ran into a similar issue and what I found is that the QtCreator IDE is not re-reading the results of qmake and updating the "Cannot open" message. You need to close the offending file and re-open it - then you'll see that it no longer displays the error.
I had to do two steps: (re-)run qmake and rebuild the whole project - only then the INCLUDEPATH setting was considered correctly. (With QtCreator 3.5 and 3.6 (Qt 5.5 and Qt 5.6) on Windows.)
The only problem you are making is incorrectly linking the OpenCV library. The other answers given here may or may not work, but I have posted on another thread a surefire way to solve this problem using the "Add Library" wizard inside Qt Creator: https://stackoverflow.com/a/51914928/10245006
I was getting the error:
canserialcomm.o: In function `CanSerialComm::CanSerialComm()':
canserialcomm.cpp:(.text+0xc1): undefined reference to `vtable for CanSerialComm'
It turns out that the cause was it wasn't able to find canserialcomm.h where that constructor is declared. This was despite me having INCLUDEPATH in the project file point to the directory containing that header file:
INCLUDEPATH += . \
..
What I had to do to fix this is explicitely specify the header file; I added:
HEADER += ../canserialcomm.h
You should use double backslashes when in windows for qt creator with msvc. like this:
INCLUDEPATH += C:\\libcurl\\libcurl-vc-x64-release-dll-ipv6-sspi-winssl\\include
this will fix the problem.
Under windows you have to eliminate the -I before each directory that is added into the INCLUDEPATH variable.
For example:
Under windows:
INCLUDEPATH += "C:\lib\boost_1_61_0" (back-slash)
Under linux & mac:
INCLUDEPATH += -I"$$(HOME)/lib/boost_1_61_0" (note the -I and forward-slash)
I'm not sure whether it depends on different qmake version or not. But after finishing qmake command, I check the Makefile and the double -I is the issue.
You need to do several things. Fist, in the .pro file, you need quotation marks two backslashes at a time, like this:
INCLUDEPATH += "C:\\OpenCV\\build\\include\\opencv\\cv.h"
You alse need a frontslash in the #include in your .cpp file like this:
#include <opencv/cv.h>
When you've done this, delete the build folder. This is the folder with a very complicated name of the type build-untitled-Desktop_Qt_5_7_0_MSVC2015_32bit-Release. Then, in the Build menu, press "Run qmake". When you've done all this, it should compile fine.
Somehow it did not work for when I had several INCLUDEPATH +=.
When I combined the stuff into a single on it suddenly worked.
I'm developing a Qt application in windows. I have created a lib file in visual studio. I have included the header file containing function prototypes in my Qt App and also added lib file in .pro file as follows
win32: LIBS += -L$$PWD/../Lib/ -lCpLib
INCLUDEPATH += $$PWD/../Lib
DEPENDPATH += $$PWD/../Lib
win32: PRE_TARGETDEPS += $$PWD/../Lib/CpLib.lib
I called the functions from my Qt app. It shows compile error as "undefined reference"
Please help me.
Regards....
The specification of your LIBS is passing linker arguments in gcc format (i.e. using -L to specify the directory and -l to specify the library name).
As you have created your lib file in Visual Studio, you'll need to specify the full library name
e.g.
win32: LIBS += yourlibrary.lib
alternatively, recompile the libraries using MinGW
I have a shared library (with no QT dependency) [library B] that links to another shared library (with no QT dependence as well) [library A].
I am using Qmake and QT Creator 1.3. The problem is that when I build library B and run ldd on the executable, it is being linked to QtCore and QtGui, both of which are pulling in lots of unrequired files, resulting in an executable that is taking long to load, and has unwanted dependencies.
I have tried just about everything to stop qmake from linking these libraries to library B.
A snippet of my project file for library B is shown below:
TEMPLATE = lib
LIBS += -L../datelib/bin -ldatelib_release
QT -= gui core
LIBS -= -lQtGui -lQtCore
CONFIG += dll
CONFIG += debug_and_release
CONFIG(debug, debug|release) {
TARGET =targetnameD
}else {
TARGET = targetname
}
I am using QtCreator 3 on Ubuntu 9.10
QT is version 4.5.2
Put CONFIG -= qt in your .pro file.
You can try with
CONFIG += dll
QT -= gui core
LIBS -= -lQtGui -lQtCore
For apps, you do it like this:
TEMPLATE = app
CONFIG = console
More info here:
qmake common projects
I had similar problem.
What I did was to create new library project with out qtcore and qtgui. Removed all unnecessary files that was created by wizard. Added my files to project folder and modified the *.pro file. It started to work correctly.
It was some problem with QtCreator, it not read correctly .pro file generating .pro.user, witch QtCreator use to build, and wizard generate correct .pro.user file.
I did this with Qt 4.7
Wish this help.
As far as I know, Qt creator doesn't take the .pro configurations into consideration if you don't have them set up separately from the IDE.
You should go to the project's settings, clone the debug configuration, rename it release, set the QMake build configuration to release(!) and change other settings as you see fit. Then you can pick which configuration to build from the IDE.
P.S: Try using Qt Creator 1.3.1 as it fixes a lot of bugs and brings interesting new features.