I am trying to break my large project into sub directories and run it as a single executable. But when I am executing the code it is giving me the following error:
qtmain_win.cpp:-1: error: undefined reference to `qMain(int, char**)'
collect2: ld returned 1 exit status
Can anyone please explain what is the reason behind these errors...
Thanks in advance!!!!
I have made a .pro file in which all the path to the subdirectories are included. Then each directory has its own .pro and .pri file with a directory which is common in all the directories. This directory is made as a lib. Then there is a main with main.pro and main.cpp. I am pasting all the three files here: Project's pro file:
# build all components recursive
TEMPLATE = subdirs
######## normal build process ########
#
# Make sure your Main.pro is in the last line to ensure correct linking!
#
SUBDIRS =D:/MultiFuncTester/Modes/Start/Build/Start.pro \
D:/MultiFuncTester/Modes/MainMenu/Build/MainMenu.pro \
D:/MultiFuncTester/Modes/Solar/Build/Solar.pro \
D:/MultiFuncTester/Modes/Main/Build/Main.pro\
CONFIG += ordered
Main.pro:
# ################ include pri file #################
!include("Main.pri"):error("Main.pri not found")
# ################ override some pri settings #################
TEMPLATE = app
TARGET = MultiFuncTester
CONFIG =-static
QT +=core\
gui\
# ################ own sources #################
INCLUDEPATH +=D:/MultiFuncTester/
SOURCES +=../Sources/Main.cpp
Project's pri file which is common in all directories made as a lib
######################
# common stuff for all components
######################
TEMPLATE = lib
CONFIG += static \
warn_on \
qt \
QT += gui \
core \
INCLUDEPATH +=D:/MultiFuncTester/Modes \
DEPENDPATH +=D:/MultiFuncTester/Modes \
CONFIG += debug_and_release
CONFIG += build_all
CONFIG(debug, debug|release) {
CONFIG_SUFFIX = dbg
} else {
CONFIG_SUFFIX = rel
DEFINES += QT_NO_DEBUG \
QT_NO_DEBUG_OUTPUT \
NDEBUG
CONFIG(gcov) {
QMAKE_CXXFLAGS_RELEASE += -fprofile-arcs -ftest-coverage
QMAKE_LFLAGS_RELEASE += -fprofile-arcs
QMAKE_CXXFLAGS_RELEASE -= -O2
QMAKE_CXXFLAGS_RELEASE += -O0
}
}
CONFIG(crosstgt) {
#To be able to build Target run qmake as follows:
qmake CONFIG+=crosstgt
CONFIG_SUFFIX = $${CONFIG_SUFFIX}_tgt
DEFINES += TARGET_BUILD
}
OBJECTS_DIR = obj_$${CONFIG_SUFFIX}
MOC_DIR = moc_$${CONFIG_SUFFIX}
DESTDIR = lib_$${CONFIG_SUFFIX}
Related
I am using Qt Creator, Qt6, C++ for my program.
I would like to use the PoDoFo library but I have no knowledge of how to add the library/headers so that I can use it in my project and build it.
I have downloaded the PoDoFo code, just can't find any guidance/tutorials on how to add PoDoFo specifically in Qt Creator.
Edit: I tried "Add Library" to my project and used external library option. Once I finish, I try to compile my code and I get an error "podofo-0.9.7\COPYING.LIB:-1: error: LNK1107: invalid or corrupt file: cannot read at 0x62DC"
I can include the podofo.h file but that will also throw this error:"podofo-0.9.7\src\podofo\base\PdfCompilerCompat.h:44: error: C1083: Cannot open include file: 'podofo_config.h': No such file or directory"
.pro file:
QT += core gui sql printsupport
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++17
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
#QMAKE_CXXFLAGS += -std=c++17
SOURCES += \
addbookdialog.cpp \
addbooksdialog.cpp \
bookdetailswindow.cpp \
bulkdetailsdialog.cpp \
cleanebooksdialog.cpp \
insertlinkdialog.cpp \
inserttabledialog.cpp \
linkcollectiondialog.cpp \
linkmanagerwindow.cpp \
main.cpp \
mainwindow.cpp \
searchnamedialog.cpp \
summarywindow.cpp
HEADERS += \
addbookdialog.h \
addbooksdialog.h \
bookdetailswindow.h \
bulkdetailsdialog.h \
cleanebooksdialog.h \
common.h \
insertlinkdialog.h \
inserttabledialog.h \
linkcollectiondialog.h \
linkmanagerwindow.h \
mainwindow.h \
queries.h \
searchnamedialog.h \
summarywindow.h
FORMS += \
addbookdialog.ui \
addbooksdialog.ui \
bookdetailswindow.ui \
bulkdetailsdialog.ui \
cleanebooksdialog.ui \
insertlinkdialog.ui \
inserttabledialog.ui \
linkcollectiondialog.ui \
linkmanagerwindow.ui \
mainwindow.ui \
searchnamedialog.ui \
summarywindow.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
DISTFILES += \
style.qss
RESOURCES += \
images.qrc \
style.qrc
unix|win32: LIBS += -L$$PWD/3rdparty/podofo-0.9.7/ -lCOPYING
INCLUDEPATH += $$PWD/3rdparty/podofo-0.9.7/src/podofo
DEPENDPATH += $$PWD/3rdparty/podofo-0.9.7/src/podofo
qt creator add library dialog:
Did you take a look on this link: https://doc.qt.io/qt-5/third-party-libraries.html?
I just followed it and my 3rdParty library (https://github.com/cutelyst/simple-mail) was linked and accessible from my application C++.
Basically, your .pro file will look like this after setting everything properly:
TARGET = MyQtApp
TEMPLATE = app
INCLUDEPATH += 3rdparty/CatWhisperer/include
SOURCES += src/main.cpp
LIBS += -L"3rdparty/CatWhisperer/lib" -lCatWhisperer
I have a Qt project using SQL calls. On windows it is using the system library here C:\Program Files (x86)\Windows Kits\8.1\Include\um and its working fine.
However, under Linux (Fedora 20 distribution), there are two availables libraries. sqlite in /usr/includes and libiodbc in /usr/include/libiodbc. And I would like to force QT/The compiler to use libiodbc.
Is there a way to prevent the inclusion of the sqlite header? Or to force the user to have the required headers to be included with a #include
At the moment, there is no #include about any of the header, I've tried to include the libiodbc, but it's still trying to use the sqlite
EDIT : I have found the -nostdinc++, but if I use it, the header that im actually including, for example #include <regex> is not found anymore
EDIT2 : the problematic header are sqltypes.h and sqlext.h
My .pro files
QT -= gui
TARGET = Internal
TEMPLATE = lib
DEFINES += INTERNAL_LIBRARY
CONFIG += c++11
include( ../LSoftware.pri )
SOURCES += \
InDbHandle.cpp \
InDbConnection.cpp \
InDbStatement.cpp \
InGenius.cpp
HEADERS += \
InDefs.h \
InDbHandle.h \
InDbConnection.h \
InDbStatement.h \
InGenius.h
LIBS += -L$$OUT_PWD/$$DESTDIR -lLTech
INCLUDEPATH += $$PWD/../LTech
INCLUDEPATH += $$PWD/../Common
unix {
target.path = /usr/lib
INSTALLS += target
}
and LSoftware.pri
DEFINES *= QT_USE_QSTRINGBUILDER
# Supposed to be there by default, but just to be safe.
CONFIG += precompile_header warn_on
CONFIG(release, debug|release) {
DESTDIR = ../Output/Release$$QMAKE_TARGET.arch
OBJECTS_DIR = Release$$QMAKE_TARGET.arch
}
CONFIG(debug, debug|release) {
DESTDIR = ../Output/Debug$$QMAKE_TARGET.arch
OBJECTS_DIR = Debug$$QMAKE_TARGET.arch
}
MOC_DIR = $$OBJECTS_DIR
RCC_DIR = $$OBJECTS_DIR
# Not documented but seems to work...
PRECOMPILED_DIR = $$OBJECTS_DIR
PRECOMPILED_HEADER = StdAfx.h
LTP_PRODUCTION {
DEFINES += LTP_PRODUCTION
}
I am migrating a project from qt 4.8.6 to qt 5.3.2.
I have a pro file which is like this:
...
#
# External library configuration
#
include(QGCExternalLibs.pri)
#
# Post link configuration
#
include(QGCSetup.pri)
...
and the QGCExternalLibs.pri is simply something like:
#
# Add in a few missing headers to windows
#
WindowsBuild {
INCLUDEPATH += libs/lib/msinttypes \
libs/thirdParty/opencv/include
LIBS += -L$$BASEDIR/libs/thirdParty/opencv/x86/vc10/lib
LIBS += opencv_core231d.lib \
opencv_highgui231d.lib \
opencv_video231d.lib \
opencv_imgproc231d.lib \
opencv_ml231d.lib \
opencv_features2d231d.lib \
opencv_flann231d.lib \
opencv_calib3d231d.lib \
opencv_objdetect231d.lib \
opencv_ts231d.lib
}
However, when I run qmake -tp vc xxxxx.pro the .pro file is qmaked successfully, however, the .pri file is not included at all. What should I do in this case?
i use libxml2 in my Qt project i create it on linux where was everthing ok. Now I trie compile it on windows where i have this error.
C:\Users\Martin\Desktop\Prace-revize\revize\mainwindow.cpp:52: Error: 'xmlReadFile' was not declared in this scope
doc = xmlReadFile(jmenoSouboru.c_str(), NULL, 0);
^
omg every time it write that i must write more details
project file :
#-------------------------------------------------
#
# Project created by QtCreator 2014-03-25T07:37:57
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = revize
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
pridani.cpp
HEADERS += mainwindow.h \
knihovna.h \
miniz.h \
pridani.h \
datum.h
FORMS += mainwindow.ui \
pridani.ui
QMAKE_CXXFLAGS +=-std=gnu++11
win32: LIBS += -L$$PWD/../../../../../knihovny/libxml2/lib/ -lxml2
INCLUDEPATH += $$PWD/../../../../../knihovny/libxml2/include
DEPENDPATH += $$PWD/../../../../../knihovny/libxml2/include
win32-g++: PRE_TARGETDEPS += $$PWD/../../../../../knihovny/libxml2/lib/libxml2.a
everything is in this C:\knihovny\libxml2
Does anyone know if qmake can create a .pc file? I found someone that said it could here: http://www.qtcentre.org/threads/24422-How-can-we-create-.pc-file-automatically. But I have tried it and got the same results as the person having the issue at the bottom of the thread. I was wondering if someone knew anything about this.
TEMPLATE = lib
TARGET = proc_Model
QT += declarative dbus
CONFIG += qt plugin dbus create_pc
DESTDIR = /usr/lib/
OBJECTS_DIR = .obj
MOC_DIR = .moc
TARGET = $$qtLibraryTarget($$TARGET)
INCLUDEPATH += ../common
# Input
SOURCES += ../common/proc_struct.cpp \
listitem.cpp \
listmodel.cpp \
process.cpp \
proc_if.cpp
HEADERS += ../common/proc_struct.h \
listitem.h \
listmodel.h \
process.h \
proc_if.h
headers.path= /usr/include/proc_Model
headers.files = ../common/proc_struct.h \
listitem.h \
listmodel.h \
process.h \
proc_if.h
target.path = /usr/lib
QMAKE_PKGCONFIG_NAME = proc_Model
QMAKE_PKGCONFIG_DESCRIPTION = Model that emits process info
QMAKE_PKGCONFIG_LIBDIR = $$target.path
QMAKE_PKGCONFIG_INCDIR = $$target.path
QMAKE_PKGCONFIG_DESTDIR = pkgconfig
INSTALLS+=headers target
When I make install, I get the following output:
install -m 755 -p "/usr/lib/libproc_Model.so" "/usr/lib/libproc_Model.so"
install: `/usr/lib/libproc_Model.so' and `/usr/lib/libproc_Model.so' are the same file
make: [install_target] Error 1 (ignored)
strip --strip-unneeded "/usr/lib/libproc_Model.so"
install -m 644 -p "/usr/lib/pkgconfig/proc_Model.pc" "/usr/lib/pkgconfig/proc_Model.pc"
install: cannot stat `/usr/lib/pkgconfig/proc_Model.pc': No such file or directory
make: [install_target] Error 1 (ignored)
According to qmake source code, you have to add:
CONFIG += create_prl no_install_prl
create_pc only adds the rule for the .pc file target to the makefile with the command "qmake -prl" and that command only creates the .pc file if the create_prl option is present.
no_install_prl prevents the unneeded .prl file, generated by create_prl, to be installed in ${target.path}.
I made a complete example here:
https://github.com/pvanhoof/dir-examples/blob/master/qmake-example/src/libs/qmake-example/qmake-example.pro
## We get the PREFIX, MAJOR_VERSION, MINOR_VERSION and PATCH_VERSION
## from this project-wide include
include(../../../qmake-example.pri)
## We will use the standard lib template of qmake
TEMPLATE = lib
## We need to set VERSION to a semver.org version for compile_libtool
VERSION = $${MAJOR_VERSION}"."$${MINOR_VERSION}"."$${PATCH_VERSION}
## According https://autotools.io/libtool/version.html, section 4.3
## we should have as target-name the API version in the library's name
TARGET = qmake-example-$${MAJOR_VERSION}"."$${MINOR_VERSION}
## We will write a define in config.h for access to the semver.org
## version as a double quoted string
QMAKE_SUBSTITUTES += config.h.in
## Our example happens to use QDebug, so we need QtCore here
QT = core
## This is of course optional
CONFIG += c++14
## We will be using libtool style libraries
CONFIG += compile_libtool
CONFIG += create_libtool
## These will create a pkg-config .pc file for us
CONFIG += create_pc create_prl no_install_prl
## Project sources
SOURCES = \
qmake-example.cpp
## Project headers
HEADERS = \
qmake-example.h
## We will install the headers in a API specific include path
headers.path = $${PREFIX}/include/qmake-example-$${MAJOR_VERSION}"."$${MINOR_VERSION}
## Here will go all the installed headers
headers.files = $${HEADERS}
## Here we will install the library to
target.path = $${PREFIX}/lib
## This is the configuration for generating the pkg-config file
QMAKE_PKGCONFIG_NAME = $${TARGET}
QMAKE_PKGCONFIG_DESCRIPTION = An example that illustrates how to do it right with qmake
# This is our libdir
QMAKE_PKGCONFIG_LIBDIR = $$target.path
# This is where our API specific headers are
QMAKE_PKGCONFIG_INCDIR = $$headers.path
QMAKE_PKGCONFIG_DESTDIR = pkgconfig
QMAKE_PKGCONFIG_PREFIX = $${PREFIX}
QMAKE_PKGCONFIG_VERSION = $$VERSION
## Installation targets (the pkg-config seems to install automatically)
INSTALLS += headers target