Qt Linking with Firmata - c++

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.

Related

Qt automatically generated .rc file cannot open include file 'windows.h'

In my Qt 5.9.1 project, I wanted to add version info to the executable to help with debugging. So, I added VERSION = 1.0.0 to the 'Project.pro' file, which automatically generated a 'Project_resource.rc' file, as expected from Qt Version.
However, the project now fails to compile, giving the error RC1015: cannot open include file 'windows.h' on the line #include <windows.h> in 'Project_resource.rc'. I know that windows.h is known by the compiler at another point in the program, because in main.cpp I #include <windows.h> and use a function from there, and that successfully compiles. I just can't figure out why the 'Project_resource.rc' can't find that same file.
Note: I have the following above the VERSION = 1.0.0 line in 'Project.pro', which is how my main.cpp can find <windows.h>.
INCLUDEPATH += "C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/ucrt"
LIBS += -L"C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10240.0/ucrt/x64"
INCLUDEPATH += "C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/um"
LIBS += -L"C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10240.0/um/x64"
INCLUDEPATH += "C:/Program Files (x86)/Windows Kits/10/Include/10.0.10240.0/shared"
Remember .rc files have their own AdditionalIncludeDirectories.
It's possible that your project had set the Windows SDK properly set as one of the Include Directories values (hence your .cpp file resolves the windows.h header file) but not the .rc file (which would explain why windows.h can't be resolved from it).
If you're using Visual Studio 2019, try this:
Right click your .rc file on the Solution Explorer
Go to Resources -> General
Edit the Additional Include Directories
Include $(WindowsSDK_IncludePath) Macro
Be sure to accept and save the change.
You should stop seeing this error right after having done this.
If the ".rc file cannot open include file" was referring to a different file, just try the same but use the proper macro/path value on step 4.

Qt won't recognize headers from sub directory /Include

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.

Qt include Class of another Project (Cannot open include file: 'foo.h')

I just started with Qt and some issues came up. I'm sure it must be a simple solution but I just can't find it.
I have two Projects, ProjectOne and ProjectTwo. I'd like you use the class foo from ProjectOne in main.cpp from ProjectTwo. When I run my Programm The Files are copied/referenced into ProjectTwo, but when i try to include foo in my main.cpp (#include "foo.h") i recieve the following error:
> main.cpp:3: error: C1083: Cannot open include file: 'foo.h':
> No such file or directory
Here's my Structure:
-ProjectOne
-ProjectOne.pro
-Headers
-foo.h
-Source
-foo.cpp
-Other files
-ProjectOne.pri
-ProjectTwo
-ProjectTwo.pro
-ProjectOne
-ProjectOne.pri
-Headers
-foo.h
-Sources
-foo.cpp
-Sources
main.cpp
Here's what i edited on my .pro and .pri files
**ProjectOne.pri**
INCLUDEPATH += $$PWD
SOURCES += $$PWD/foo.cpp
HEADERS += $$PWD/foo.h
**ProjectTwo.pro:**
include(../ProjectOne/ProjectOne.pri)
QT += core
SOURCES += foo.cpp
HEADERS += foo.h
I'm using Qt Creator 3.1.2 on Windows 7. My Programming Language is C++ and I'm compiling with VisualStudio 10 Express.
Any help is greatly appreciated!
When including a file that isn't directly in you project folder you need to include it with full or relative path.
i.e.
#include "bar/foo.h"
or
#include "../../bar/foo.h"

Cannot open include file pcap.h in QT creator (C1083)

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.

Qt Creator "No such file or directory"

Let me start off by saying I'm fairly new to Qt. That being said, I'm having dependency issues.
I am trying to use mclmcrrt.h in the Matlab directory. From my *.pro file I right click->add library->external library->browse, etc. and I get the following:
win32: LIBS += -L$$PWD/../../../Program Files (x86)/MATLAB/MATLAB Compiler Runtime/v714/extern/lib/win32/microsoft/ -lmclmcrrt
INCLUDEPATH += $$PWD/../../../Program Files (x86)/MATLAB/MATLAB Compiler Runtime/v714/extern/include
DEPENDPATH += $$PWD/../../../Program Files (x86)/MATLAB/MATLAB Compiler Runtime/v714/extern/include
This looks similar to what I've seen in other places using the INCLUDEPATH, etc. Also, in my included header file that's calling mclmcrrt.h I have:
#include "mclmcrrt.h"
No matter what, I can't get rid of the error: "mclmcrrt.h: No such file or directory"
I looked around and tried a lot of things. I got this working in Visual Studio, but can't seem to get it here.
Thanks in advance!
Spaces in paths break the parser, try this:
win32: LIBS += -L$$PWD/../../../"Program Files (x86)/MATLAB/MATLAB Compiler Runtime"/v714/extern/lib/win32/microsoft/ -lmclmcrrt
INCLUDEPATH += $$PWD/../../../"Program Files (x86)/MATLAB/MATLAB Compiler Runtime"/v714/extern/include
DEPENDPATH += $$PWD/../../../"Program Files (x86)/MATLAB/MATLAB Compiler Runtime"/v714/extern/include