I am trying to link winpcap into my QT creator project.
For that I've added this to my .pro file:
INCLUDEPATH += C:/WpdPack/Include
LIBS += -LC:/WpdPack/Lib -lwpcap - lpacket
When I type #include <pcap.h> the code assistant autocompletes but on compile I get Error:C1083: Cannot open include file: 'pcap.h': No such file or directory.
Any help would be very appreciated.
Typically the solution pops up after asking the question:
I've found a workaround
INCLUDEPATH += C:/WpdPack/Include
LIBS += C:/WpdPack/Lib/wpcap.lib
LIBS += C:/WpdPack/Lib/Packet.lib
CONFIG += no_lflags_merge
And it builds.
Related
I'm new to Qt and I'm trying to implement a simple shared library for use in another application. I've read the wiki and other docs, but even after carefully following the steps, the compiler will always throw an error saying it can't find my header files.
I'm using Qt MinGW on Windows 10. Here's what I did:
Created and compiled a shared library called libgx
In another project (hello), added the generated liblibgx.a file, using the "Add Library" wizard.
Pulled my hair over this error I get when I try to include the library's header into hello's main.cpp
The wiki is not helpful here at all. It tells me, "MinGW compiled linking libraries are in .a, but you will need to add it manually (as of Qt Creator 2.7). You could also try simply linking the .dll directly cause it would probably work." I'm like WHAT?
hello's .pro file
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = hello
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp\
C:/Users/sagar.JARVISAIO/Documents/libgx/libgx.cpp
HEADERS += mainwindow.h\
C:/Users/sagar.JARVISAIO/Documents/libgx/libgx.h
FORMS += mainwindow.ui
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../build-libgx-Desktop_Qt_5_5_0_MinGW_32bit-Release/release/ -llibgx
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../build-libgx-Desktop_Qt_5_5_0_MinGW_32bit-Release/debug/ -llibgx
else:unix: LIBS += -L$$PWD/../build-libgx-Desktop_Qt_5_5_0_MinGW_32bit-Release/ -llibgx
INCLUDEPATH += $$PWD/../build-libgx-Desktop_Qt_5_5_0_MinGW_32bit-Release/release
DEPENDPATH += $$PWD/../build-libgx-Desktop_Qt_5_5_0_MinGW_32bit-Release/release
I manually added the headers and the library files in the .pro file using the procedure here. Never going to bother with that "wizard" again. It was unnecessarily adding a $$PWD variable in all my paths which I think was causing my problem.
I want to use one .dll file in another. But it seems like I'm doing something wrong with it. I have two library project ScaraControlGUI and ScaraLogic, and I want to use ScaraLogic into ScaraControlGUI, so I added appropriate lines in ScaraControlGUI's .pro file:
DEPENDPATH += . ../ScaraLogic
INCLUDEPATH += ../ScaraLogic
LIBS += -L../ScaraLogic/debug -lScaraLogic
And I receive:
scaralogic.h: No such file or directory
When I want to include this file. I'm sure that this file exist so I bet that I'm doing something wrong around .pro files.
What I'm doing wrong ? Adding ScaraControlGUI .dll to main executable project works fine like this.
Thanks in advace for help.
As your header is in ScaraLogic/Headers directory, you have to include it as #include <Headers/scaralogic.h>, or, which is better, set INCLUDEPATH as
DEPENDPATH += . ../ScaraLogic
INCLUDEPATH += ../ScaraLogic/Headers
LIBS += -L../ScaraLogic/debug -lScaraLogic
in the project file, and still use #include <scaralogic.h>.
I resolved my problem. My ScaraControlGUI subproject was building properly. Problem was in my main project ScaraControl and to solve this I needed to add LIBS and INCLUDEPATH too.
Environment
I am on Windows 7 64bit
Qt Creator 3.4.2 (opensource)
Based on Qt 5.5.0 (MSVC 2013, 32 bit)
Goal
I am using a 3rd party library. I need to #include the library files like that since that is how the library files include their dependencies.
What I have tried
in myFunction.h (in same directory as .pro file)
#include <lib_header.h>
...
in .pro file
LIBS += -L"$$PWD/Debug/" -llib_name
SUBDIRS += "$$PWD/Include"
DEPENDPATH += "$$PWD/Include"
INCLUDEPATH += "$$PWD/Include"
DEPENDPATH += "C:/Users/Steves Laptop/UX3D/Include"
INCLUDEPATH += "C:/Users/Steves Laptop/UX3D/Include"
VPATH += "$$PWD/Include"
VPATH += "C:/Users/Steves Laptop/UX3D/Include"
...
lib_header.h is in /Include
Results
I get tool tip when hovering over the #include line of the exact location of the file. On compile it says it can't be found. I expect this is a newbie mistake but have spent 3 hrs wasted so far. If in my files I do it like this #include <Include/lib_header.h> it works. I need a way to reference them directly though in order for the rest of the library to work.
Even if someone could provide a link or reference source file that documents Qt's implementation of the #include <> tag that would be sufficient.
I know it's a quite common issue but I haven't found a comprehensive answer on the following question.
I have Qt 5.4.1 MSVC2013 build running on Windows 8.1.
Here is a look on my project files:
And here is what my .pro file looks like:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = Vfp
TEMPLATE = app
QMAKE_CXXFLAGS = - std=c++11
SOURCES += main.cpp\
Views/mainview.cpp
HEADERS += Views/mainview.h
FORMS += Views/mainview.ui
The problem is, unless I add INCLUDEPATH += Views/ to the .pro file, I cannot include mainview.h in main.cpp file.
Why? Shouldn't HEADERS += Views/mainview.h be enough?
If you're including the header file this way:
#include "mainview.h"
Then yes, you need to add that include path since the compiler (not the IDE) doesn't know where mainview.h is.
Otherwise, you need to specify the relative path to the file, like:
#include "Views/mainview.h"
Documentation doesn't say that HEADERS is for specifying include paths to the compiler. HEADERS is used for generating dependency information and checking whether moc is necessary.
If you add below command to .pro file you will able to compile it.
INCLUDEPATH += ...path/Views/
I am running on a Windows 7 with Qt SDK(C++), Firmata, and Arduino Softaware
I was wondering why the firmata.h is not working
#ifndef Firmata_Boards_h
#define Firmata_Boards_h
#include <inttypes.h>
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h" // for digitalRead, digitalWrite, etc
#else
#include "WProgram.h"
#endif
the problem is when i try to compile using Qt it says
D:\SGU\Semester 8\Program\OpenCVMultithreaded\Boards.h:9: error: Arduino.h: No such file or directory
can we really use firmata on Qt? because in the internet I only found Arduino software using firmata, not on Qt itself.
I tried :
INCLUDEPATH += "D:\opencv\build\include"
INCLUDEPATH += "D:\opencv\build\include\opencv"
INCLUDEPATH += "C:\Program Files (x86)\Arduino"
INCLUDEPATH += "C:\Program Files (x86)\Arduino\hardware"
INCLUDEPATH += "C:\Program Files (x86)\Arduino\lib" I
INCLUDEPATH += "C:\Program Files (x86)\Arduino\libraries"
INCLUDEPATH += "C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino\Arduino.h"
But it doesnt work.
This is not a linking issue but a compilation issue, and has nothing to do with the specific library you are using. You probably haven't specified where to find the header files nor the library files.
In your project file (.pro) add
INCLUDEPATH += PATH_TO_ARDUINNO_HEADERS
for example PATH_TO_ARDUINNO_HEADERS can be C:/Arduino/include.
To specify libraries you need to use the LIBS variables, for example
LIBS += "-Lc:/Arduino/lib" -larduinnoshared
See the qmake reference for a complete guide on including\linking to external items
Edit:
The include path is what is going to be prefixed to find "Arduino.h".
So if the file is at
"C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino\Arduino.h"
you need to use
INCLUDEPATH += "C:\Program Files (x86)\Arduino\hardware\arduino\cores\arduino"
All the other paths you posted are invalid for this file. You put only directories containing header files in the includepath.