Qt Creator "No such file or directory" - c++

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

Related

Qt can't find my shared library - no really it cant

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.

Qt using .dll in .dll

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.

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.

Using libraries in Qt

My questions may seems like it is a real duplicate, but however I checked many related questions, my problem still remains.
I found and compiled a project called SMTPEmail, so I have my .dll and .lib files under the directories Libraries/SMTPClient/debug and Libraries/SMTPClient/release.
When I try to include the header files in example in case of emailadress.h: #include <emailaddress.h> or #include <SMTPEmail/emailaddress.h>, I got the error Cannot open include file 'emailaddress.h'. The Q_DECL_EXPORT modifier is used in the header files.
SMTPEmail.pro:
...
QT += core network
TARGET = SMTPEmail
TEMPLATE = lib
DEFINES += SMTP_BUILD
win32:CONFIG += dll
QMAKE_CXXFLAGS += -fPIC
...
MyProject.pro:
...
INCLUDEPATH += ./Libraries/SMTPClient/debug
DEPENDPATH += ./Libraries/SMTPClient/debug
win32:LIBS += ./Libraries/SMTPClient/debug/SMTPEmail.lib
...
I also tried:
LIBS += -L./Libraries/SMTPClient/debug/ -lSMTPEmail
and
LIBS += -L$$_PRO_FILE_PWD_/Libraries/SMTPClient/debug/ -lSMTPEmail
and
LIBS += -L$$PWD_/Libraries/SMTPClient/debug/ -lSMTPEmail
and
LIBS += -L./MyProject/Libraries/SMTPClient/release/ -lSMTPEmail
The only thing that I didn't do is copying or linking the header files which are inside the library to my app?
I have the strong feeling that I missed a small step somewhere, can you help me pointing out what I am doing wrong?
I think your problem is (at least) this line:
INCLUDEPATH += ./Libraries/SMTPClient/debug
I am almost certain that this is not the right path to the include path where the headers can be found including emailadress.h.
You have explained the LIBS values that you have tried as well as the lib path in great length, but you are getting an include error from the compiler rather than a linkage problem with the libraries from the linker. I would suggest to figure out where the headers are located and add it to the include path as follows:
# This is just pseudo code, but you need something like this
INCLUDEPATH += $$PWD/Includes/SMTPClient
Answering your question of:
The only thing that I didn't to is copying the header files which should be inside the library, is that right?
It depends on what you mean. If you mean whether the library should be self-contained, then the answer is no, unless you are using dynamic library loading with manual symbol resolution and the like, which I do not recommend for simple cases.
If you mean, it is shipped with the project that you are trying to reuse, then sure, and that is why you would need to specify the includepath in your project to that path.

Qt Linking with Firmata

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.