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
}
Related
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
Am trying to build the project found # uconfig
, the project requires poppler and the author provided pre-built links
headers and DLLS
I have downloaded them and this is structure of the project
dll folder contains all the DLLS and poppler contains header files,
the pdf_extract.pro has the following content
QT += core gui widgets xml
TARGET = pdf_extract
TEMPLATE = lib
DEFINES += DATASHEET_EXTRACTOR_EXPORT_LIB
DESTDIR = "$$PWD/../../bin"
CONFIG(release, debug|release) {
CONFIG += optimize_full
}
SOURCES += \
$$PWD/datasheet.cpp \
$$PWD/datasheetpackage.cpp \
$$PWD/datasheetpin.cpp \
$$PWD/datasheetbox.cpp \
$$PWD/pdfdebugwidget/pdfdebugwidget.cpp \
$$PWD/pdfdebugwidget/pdfdebugviewer.cpp \
$$PWD/pdfdebugwidget/pdfdebugscene.cpp \
$$PWD/pdfdebugwidget/pdfdebugitempage.cpp \
$$PWD/pdfdebugwidget/pdfdebugitempin.cpp \
$$PWD/pdfdebugwidget/pdfdebugitemtextbox.cpp \
$$PWD/model/pdfdatasheet.cpp \
$$PWD/model/pdfpage.cpp \
$$PWD/model/pdftextbox.cpp \
$$PWD/model/pdfpin.cpp \
$$PWD/model/pdfcomponent.cpp \
$$PWD/controller/pdfloader.cpp
HEADERS += \
$$PWD/pdf_extract_common.h \
$$PWD/datasheet.h \
$$PWD/datasheetpackage.h \
$$PWD/datasheetpin.h \
$$PWD/datasheetbox.h \
$$PWD/pdfdebugwidget/pdfdebugwidget.h \
$$PWD/pdfdebugwidget/pdfdebugviewer.h \
$$PWD/pdfdebugwidget/pdfdebugscene.h \
$$PWD/pdfdebugwidget/pdfdebugitempage.h \
$$PWD/pdfdebugwidget/pdfdebugitempin.h \
$$PWD/pdfdebugwidget/pdfdebugitemtextbox.h \
$$PWD/model/pdfdatasheet.h \
$$PWD/model/pdfpage.h \
$$PWD/model/pdftextbox.h \
$$PWD/model/pdfpin.h \
$$PWD/model/pdfcomponent.h \
$$PWD/controller/pdfloader.h
LIBS += -L"$$PWD/../../bin"
LIBS += -L"$$PWD/dll/jpeg62.dll"
LIBS += -L"$$PWD/dll/libfreetype-6.dll"
LIBS += -L"$$PWD/dll/libopenjp2.dll"
LIBS += -L"$$PWD/dll/libpng12.dll"
LIBS += -L"$$PWD/dll/libpoppler-80.dll"
LIBS += -L"$$PWD/dll/libpoppler-qt5.dll"
LIBS += -L"$$PWD/dll/libtiff3.dll"
LIBS += -L"$$PWD/dll/zlib1.dll"
INCLUDEPATH += $$PWD/../../
LIBS += -lkicad
macx {
LIBS += -L /usr/local/lib
INCLUDEPATH += /usr/local/include
}
yet when I try to build the project I get these errors... am not sure what am doing wrong or missing
According to qmake documentation, using unix standards to specify linked libraries will work on Windows, too. Anyway, instead of
LIBS += -L"$$PWD/dll/jpeg62.dll"
I would try
LIBS += "-L$$PWD/dll" - ljpeg62
or just use Windows style:
LIBS += $$PWD/dll/jpeg62.dll
2 years late but i've also been wondering,
#include <QLibrary>
place your *.dll in your Debug/Release folder. e.g:
build-test-Desktop_Qt_6_1_2_MinGW_64_bit-Debug/debug
now simply:
QLibrary lib("myLibrary.dll");
if (!lib.load())
qDebug() << lib.errorString();
if (lib.load())
qDebug() << "library loaded";
alternatively, rather than placing the DLL in debug folder you can set the location of the dll to
c:/path/to/dll/yourdll.dll
I am trying to generate a c++ project using qmake and compiling it under visual studio.
this project as a dependency to itk.
I made a .pri with a MyITK project in it:
MyITK {
CONFIG_FOUND += MyITK
INCLUDEPATH += $${PACKAGE_SOURCES}/Shared/MyITK
QMAKE_LIBDIR += $${PACKAGE_LIB}/MyITK
win32:LIBS += ITKIONIFTI-4.13.lib \
ITKCommon-4.13.lib \
ITKBiasCorrection-4.13.lib \
ITKBioCell-4.13.lib \
etc
in the .pro of my project is like that:
CONFIG += staticlib MyITK
HEADERS += \
myowncode.h \
myowncode2.h \
myowncode3.h \
SOURCES += \
myowncode.cpp \
myowncode2.cpp \
when I try to compile my project, it find the .h only if I put them directly in $${PACKAGE_SOURCES}/Shared/MyITK
if I "copy past" the source code form itk, which is organized like that:
/Modules/ModuleNames/SubModulesNames/include
is there a way to make QMake looking for .h in all subdirectories ?
according to Matt answers I tried:
ITKModules = Core Filtering IO Numerics Registration Segmentation
Core.submodules = Common FiniteDifference
IO.submodules = NIFTI ImageBase
Numerics.submodules = Eigen FEM NarrowBand NeuralNetworks
Registration.submodules = Common FEM
Segmentation.submodules = BioCell ConnectedComponents KLMRegionGrowing
MyITK {
CONFIG_FOUND += MyITK
for(foo, ITKModules): for(bar, $${foo}.submodules) {
INCLUDEPATH += $${PACKAGE_SOURCES}/Shared/MyITK/Modules/$${foo}/$${bar}/include
}
QMAKE_LIBDIR += $${PACKAGE_LIB}/MyITK
win32:LIBS += ITKIONIFTI-4.13.lib \
ITKCommon-4.13.lib \
ITKBiasCorrection-4.13.lib \
ITKBioCell-4.13.lib \
}
but it still can't link to the .h at VS compilation.
is there a way to make QMake looking for .h in all subdirectories ?
Actually you're trying to make your compiler look into all subdirectories, not qmake.
qmake itself has no built-in function to generate subdirs list. But you can prettify your pro a bit using loops:
modules = x1 x2 x3
x1.submodules = y1 y4
x2.submodules = y2 y5
x3.submodules = y3 y6
for(foo, modules): for(bar, $${foo}.submodules) {
INCLUDEPATH += /Modules/$${foo}/$${bar}/include
}
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}