0

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
}
David Levy
  • 430
  • 5
  • 18
  • Which compiler is Qt using on Linux? – txtechhelp Nov 28 '16 at 21:08
  • It's using g++ (see tag) – David Levy Nov 28 '16 at 21:09
  • 1
    A few misconceptions to clear up: the `#include` files for a C library (like SQLite) are different from the library itself, which is a `.a` or `.so` file probably in `/usr/lib` somewhere. Neither SQLite nore libiodbc are standard system libraries so they are unaffected by `-nostdinc++`. I'm not really sure what you mean by "force" the compiler to use libiodbc—normally, you just pass the linker and preprocessor flags for libiodbc and you're set. – Dietrich Epp Nov 28 '16 at 21:09
  • See http://stackoverflow.com/questions/3840218/how-to-specify-the-library-version-to-use-at-link-time or http://stackoverflow.com/questions/828053/how-do-you-link-to-a-specific-version-of-a-shared-library-in-gcc – txtechhelp Nov 28 '16 at 21:10
  • The library are indeed in /usr/lib. But nowhere in the project I give any information regarding sql libraries, it just uses this one. I'll edit my post with my .pro file and try to actually adding the required library – David Levy Nov 28 '16 at 21:18
  • What are you actually trying to accomplish here? Are you getting an error message when you try to do something, or are you trying to use a library, or what? I think this is really an instance of the XY problem, where you are telling us how you're trying to solve the problem (Y) instead of telling us what problem you actually have (X). – Dietrich Epp Nov 28 '16 at 21:23
  • It's using a typedef from sqlite instead of a typedef from libiodbc, causing several other issues – David Levy Nov 28 '16 at 21:27
  • Perhaps you could swap the order the directories are included from? – Mark Ransom Nov 28 '16 at 21:30
  • What is "it"? Is *your* code using a typedef from sqlite? – Dietrich Epp Nov 28 '16 at 21:30
  • The code has `SQLPrepare( *this, (SQLWCHAR *)aQuery.utf16(), SQL_NTS )` and SQLWCHAR is a typedef to WCHAR in sqlite and to wchar_t in libiodbc – David Levy Nov 28 '16 at 21:33
  • SQLite3 does not contain a definition for `SQLWCHAR` anywhere. There is something else going on. – Dietrich Epp Nov 28 '16 at 21:34
  • @MarkRansom Im not including them anywhere, and if I include only the one I want, it doesnt change anything – David Levy Nov 28 '16 at 21:34
  • So, we've ruled out that SQLite3 has anything to do with this. It's possible that your include paths are set up wrong for your project, it's possible that you've installed things in weird places, it's possible that you have multiple versions of a library installed, and it's hard to tell which one applies here because the information provided is a bit vague—we can't see what errors you're getting and we don't know how your system is set up. Hopefully this will give you a starting point. – Dietrich Epp Nov 28 '16 at 21:43
  • Well, thanks for your help, I'll keep investigating. The person that installed everything on this computer is long gone, so its hard to know how things are – David Levy Nov 28 '16 at 21:49

0 Answers0