I have a Qt project which I want to include all of my source files bar one.
SOURCES += $$files(*.cpp)
SOURCES -= excluded.cpp
I have tried using the wildcard directly
SOURCES += *.cpp
The strange thing is that if i print out the value of SOURCES the file is not printed, however it is still built with the rest of the project:
message($$SOURCES) # doesn't show excluded.cpp
Any help would be greatly appreciated!
EDIT:
Here is my full .pro:
TEMPLATE = app
CONFIG += console c++17
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += $$files(../compiler/src/*.cpp)
SOURCES -= ../compiler/src/main.cpp
SOURCES += test.cpp
INCLUDEPATH = ../compiler/include
HEADERS += $$files(../compiler/include/*.h)
LIBS += -lgtest -lgmock -pthread
QMAKE_CXXFLAGS += -std=c++1z
Related
I have created a project in qt creator with multiple subdirs and am deploying/running it on a beaglebone. Compiles fine, deploys fine, etc.
My issue is that when I try to debug, the only files I can set breakpoints in or step into are those in the same subdir where main.cpp is. Just to test, I duplicated the project with a flat folder structure and can set breakpoints and step into everything.
When the debugger starts up, the debug log tries to set the breakpoints and fails seemingly because it can't find the .cpp files:
"No source file named projectdir/dir1/myclass.cpp.\n"
8045^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="",pending="\"projectdir/dir1/myclass.cpp\":7",times="0",original-location="\"fullpathofprojectdir/dir1/myclass.cpp\":7"}
Whereas it says this for breakpoints in main:
8046^done,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0x0001831c",func="main(int, char**)",file="projectdir/dir2/main.cpp",fullname="fullpathofprojectdir/dir2/main.cpp",line="27",thread-groups=["i1"],times="0",original-location="fullpathofprojectdir/dir2/main.cpp:27"}
Additionally, myclass.cpp doesn't show up in the source files panes either. How can I resolve this?
Here is the setup of my *.pro files:
Top level project file:
TEMPLATE = subdirs
SUBDIRS += \
dir1 \
dir2
unix {
target.path = /home/debian
INSTALLS += target
}
Project file of library (dir1, myclass.cpp, etc):
QT -= gui
TARGET = Common
TEMPLATE = lib
DEFINES += COMMON_LIBRARY
SOURCES += \
myclass.cpp
HEADERS += \
common_global.h \
myclass.h
unix {
target.path = /home/debian/lib
INSTALLS += target
}
CONFIG += debug
Project file containing main:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = Test
TEMPLATE = app
SOURCES += \
main.cpp
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../Common/release/
-lCommon
else:win32:CONFIG(debug, debug|release): LIBS += -
L$$OUT_PWD/../Common/debug/ -lCommon
else:unix: LIBS += -L$$OUT_PWD/../Common/ -lCommon
INCLUDEPATH += $$PWD/../Common
DEPENDPATH += $$PWD/../Common
target.path = /home/debian
INSTALLS += target
Let me know if there's any other relevant data I forgot to provide. Qt Creator version is 4.5.0 and I'm running it on a 64 bit VM of ubuntu 16.04 if that's relevant.
I am trying to follow qt creators instructions to create static libraries.
https://wiki.qt.io/How_to_create_a_library_with_Qt_and_use_it_in_an_application
it shows the below for lines to include in my libraries .pro
TEMPLATE = lib
CONFIG += staticlib
# Input
HEADERS += test.h
SOURCES += test.cpp
and for the apps .pro
TEMPLATE = app
TARGET =
CONFIG += console
# Input
SOURCES += main.cpp
INCLUDEPATH += ../staticLibrary
LIBS += -L../staticLibrary/debug -lstaticLibrary
I have
library's .pro
QT -= gui
TARGET = test
TEMPLATE = lib
CONFIG += staticlib
SOURCES += test.cpp
HEADERS += test.h
unix {
target.path = /usr/lib
INSTALLS += target
}
app's .pro
QT += core
QT -= gui
CONFIG += c++11
TARGET = TestLink
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += ../test // ADDED BY ME
LIBS += -L../test/debug -ltest //ADDED BY ME
// LIBS += -L../test/debug -ltest.a //ALSO TRIED .a
My library is test. Both folder, the main app and the library are in the same folder. When I now include the .h
#include "test.h"
I get
C:\CPP\Test\TestLink\main.cpp:3: error: C1083: Cannot open include file: 'test.h': No such file or directory
It seems I am following the isntructions here. What am I missing?
This here also suggests the two lines I added should do the job
Using a static library in Qt Creator
Have tried to "link" two projects together. So one project knows the other ones classes. One project is the program, the other project is a test program for the first one. So i want the test program to have access to the other ones classes so i can test them.
Both projects are sub projects.
They are placed under header project, there folders are beside each other.
Have tried many different ways but with no result.
Head.pro
TEMPLATE = subdirs
SUBDIRS += \
MT \
Test
MT.pri same folder as the program.
INCLUDEPATH += $$PWD
SOURCES += $$PWD/parser.cpp
HEADERS += $$PWD/parser.h
MT.pro
QT += core bluetooth gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = MT
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG += mobility
SOURCES += main.cpp\
mainwindow.cpp \
t.cpp \
parser.cpp \
devicediscovery.cpp
HEADERS += mainwindow.h \
parser.h \
devicediscovery.h \
t.h \
typedefs.h
FORMS += mainwindow.ui
MOBILITY =
INSTALLS += target
DISTFILES += \
MT.pri
Test.pro
include(../MT/MT.pri)
QT += widgets testlib core bluetooth gui
TARGET = tst_testmttest
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
HEADERS += parser.h
SOURCES += tst_testmttest.cpp / parser.cpp
DEFINES += SRCDIR=\\\"$$PWD/\\\"
Use in Test Project:
include(Path/to/OtherProject/file.pri)
Use in Other project
QT += xml
INCLUDEPATH += $$PWD
SOURCES += $$PWD/parser.cpp
HEADERS += $$PWD/parser.h
works fine
I've made a C++/OpenGL application using the Qt framework, but I cannot to run *.exe file. I always get errors with libwinpthread-1.
I already read articles about that, but all dll's are in the Qt folder, so I don't understand what the problem is. Please take a look at my *.pro file:
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += main.cpp \
sliceobj.cpp
unix|win32: LIBS += -lOPENGL32
unix|win32: LIBS += -L$$PWD/../../../../5.0.2/mingw47_32/lib/ -lglut32
QMAKE_LFLAGS += -static-libgcc -static-libstdc++
QMAKE_CXXFLAGS_WARN_ON += -Wno-unknown-pragmas
INCLUDEPATH += $$PWD/../../../../5.0.2/mingw47_32/include
win32 {
message("* Using settings for windows")
INCLUDEPATH += "C:\\opencv\\build\\include" \
"C:\\opencv\\build\\include\\opencv" \
"C:\\opencv\\build\\include\\opencv2"
LIBS += -L"C:\\opencv\\build\\x86\\vc11\\bin" \
-lopencv_core247\
-lopencv_highgui247\
-lopencv_imgproc247\
-lopencv_video247\
LIBS += -L"C:\\opencv\\build\\x86\\vc11\\staticlib" \
-lopencv_core247\
-lopencv_highgui247\
-lopencv_imgproc247\
-lopencv_video247\
}
Use Dependency Walker to see what exactly your code links against + Which libraries are loaded in runtime. Open your executable with DW and you will see DLL's that are linked against. They need to be present in PATH or beside your executable. Press F7 to start profiling to see which libraries are loaded in runtime. Here as snapshot:
Ok, i know that's not good, but i'm just added this files into debug directory .
I am trying to run some of the sample example code from CGAL as a Qt project, to run in Qt Creator. I expect that I will have to modify the .pro file. How should it be modified to use CGAL libraries?
I'm not familiar with CGAL specifically, but in general, you would need to add the following to your .pro file:
INCLUDEPATH += /path/to/cgal/headers
LIBS += -Lpath/to/cgal/libraries -lcgal_dll_name
You may also need to add some DEFINES if CGAL requires it, i.e.
DEFINES += SOME_MACRO_THAT_CGAL_REQUIRES
If you were looking for help on CGAL specifically, please clarify your question and I will delete this answer.
Although this is an old question, just for the sake of having a more complete answer, this is what I had to do in the .pro file:
INCLUDEPATH += /usr/include/
LIBS += -L/usr/include/
LIBS += -lCGAL
LIBS += -lgmp
LIBS += -lmpfr // not really needed for me, but added since gmp had to be added too
QMAKE_CXXFLAGS += -frounding-math -O3
Do NOT add stuff like the following, it will get you into trouble with weird error messages, as discussed in this link.
INCLUDEPATH += /usr/include/CGAL # do NOT add this!
LIBS += -L/usr/include/CGAL # do NOT add this!
I'm using Qt 4.8.6, gcc and Fedora 24, and here is my .pro for Qt-CGAL projects :
#-------------------------------------------------
#
# Project created by QtCreator 2017-01-08T14:50:29
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = My CGAL_test
TEMPLATE = app
LIBS += -lgmp -lmpfr -lCGAL
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui