i'm trying to make a QT Widgets project. I have to use a "libpng" library, but i'm having a trouble including it. Here is the config .pro file.
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = coursework2
TEMPLATE = app
DEFINES += QT_DEPRECATED_WARNINGS
CONFIG += c++11
SOURCES += \
main.cpp \
mainwindow.cpp \
INCLUDEPATH += $(LIBRARY_SHARE)/libpng/include
LIBS += -L$(LIBRARY_SHARE)/libpng/lib -lpng
HEADERS += \
mainwindow.h
FORMS += \
mainwindow.ui
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
This is the solution, which worked for lots of people (found it somewhere), but has no result for me. When i try to include it in main.cpp file, this error pops up:
'png.h' file not found
#include "png.h"
^~~~~~~
How can i fix it?
The solution was pretty simple. I made a mistake in the root to "libpng".
I had to change my 2 lines of code:
INCLUDEPATH += /usr/local/include
LIBS += -L/usr/local/lib/libpng
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 request your knowledge about QT.
Do you know why during the compilation a moc file cannot find include from QT ?
I currently have this problem in Qt Project, the error is
"moc_SettingsDialog.cpp:9: In file included from moc_SettingsDialog.cpp:9:
SettingsDialog.h:12: error : 'QDialog' file not found".
This my pro file:
#-------------------------------------------------
#
# Project created by QtCreator 2018-12-04T14:58:35
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = cashRegister
TEMPLATE = app
message($${INCLUDEPATH})
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
CONFIG += c++11
SOURCES += \
main.cpp \
cashRegister.cpp \
sources/settings.cpp \
sources/settingsBuilder.cpp \
sources/parseConfFile.cpp \
sources/SupplyList.cpp \
sources/Item.cpp \
sources/SettingsDialog.cpp \
sources/TpeNetwork.cpp \
sources/ManagerNetwork.cpp \
sources/BillNetwork.cpp \
sources/PaymentServerNetwork.cpp \
sources/NetworkFactory.cpp \
sources/Customer.cpp \
sources/Cart.cpp
HEADERS += \
cashRegister.h \
includes/settings.h \
includes/settingsBuilder.h \
includes/parseConfFile.h \
includes/SupplyList.h \
includes/Item.h \
includes/Mybutton.h \
includes/SettingsDialog.h \
includes/TpeNetwork.h \
includes/ManagerNetwork.h \
includes/BillNetwork.h \
includes/PaymentServerNetwork.h \
includes/NetworkFactory.h \
includes/NetworkCode.h \
includes/networkabstract.h \
includes/networkinterface.hpp \
includes/Customer.h \
includes/Cart.h
FORMS += \
cashRegister.ui \
SettingsDialog.ui
macx {
_BOOST_PATH = /usr/local/Cellar/boost/1.68.0
INCLUDEPATH += "$${_BOOST_PATH}/include/"
LIBS += -L$${_BOOST_PATH}/lib -lboost_regex
}
unix:!macx {
LIBS += -L"/usr/lib/x86_64-linux-gnu" -lboost_regex
INCLUDEPATH += /usr/include/boost
DEPENDPATH += /usr/include/boost
DEFINES += QT_NO_VERSION_TAGGING
}
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
RESOURCES += \
config.qrc
Qt Version : 5.12.0
OS: MacOS 10.14 and Ubuntu
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 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
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}