Qt Linking with Firmata

2019-09-04 09:07发布

问题:

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.

回答1:

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.