AnsweredAssumed Answered

SQLiteCpp cross compile error: cannot find a given function in sqlite3.c

Question asked by 才俊欧 on Oct 9, 2017
Latest reply on Oct 22, 2017 by 才俊欧

I came across a compile error that cannot find the function defined in a given file when I try to add SQLiteCpp source to my qt application. It cost me a half day and I hope some one can kindly help me. Thanks a lot!

1. build libSQLiteCpp.a and libsqlite3.a

{

get src:
git clone https://github.com/SRombauts/SQLiteCpp.git
cd SQLiteCpp
git submodule init
git submodule update

build libs:
cd /home/ocean/test/qt5_all/sqltest/XLIBS/SQLiteCpp/ \
&& . /opt/fsl-imx-x11/4.1.15-2.0.0/environment-setup-cortexa9hf-neon-poky-linux-gnueabi \
&& ./build.sh

}

2. edit qt app and its project file

{

QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = sqltest
TEMPLATE = app

SOURCES += main.cpp\
mainwindow.cpp

HEADERS += mainwindow.h

INCLUDEPATH += /home/ocean/test/qt5_all/sqltest/XLIBS/SQLiteCpp/include/
INCLUDEPATH += /home/ocean/test/qt5_all/sqltest/XLIBS/SQLiteCpp/include/SQLiteCpp/
INCLUDEPATH += /home/ocean/test/qt5_all/sqltest/XLIBS/SQLiteCpp/sqlite3/

LIBS += /home/ocean/test/qt5_all/sqltest/XLIBS/SQLiteCpp/build/sqlite3/libsqlite3.a
LIBS += /home/ocean/test/qt5_all/sqltest/XLIBS/SQLiteCpp/build/libSQLiteCpp.a

FORMS += mainwindow.ui

}

3. qt app cross compile error: can not find the function defined in sqlite3.c

{

arm-poky-linux-gnueabi-g++ -march=armv7-a -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 --sysroot=/opt/fsl-imx-x11/4.1.15-2.0.0/sysro
ots/cortexa9hf-neon-poky-linux-gnueabi -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-O1 -o sqltest main.o mainwindow.o moc_mainwi
ndow.o /home/ocean/test/qt5_all/sqltest/XLIBS/SQLiteCpp/build/sqlite3/libsqlite3.a /home/ocean/test/qt5_all/sqltest/XLIBS/SQLiteCpp
/build/libSQLiteCpp.a -lQt5Widgets -lQt5Gui -lQt5Core -lGLESv2 -lEGL -lpthread
/home/ocean/test/qt5_all/sqltest/XLIBS/SQLiteCpp/build/libSQLiteCpp.a(Column.cpp.o): In function `SQLite::Column::getName() const':
/home/ocean/test/qt5_all/sqltest/XLIBS/SQLiteCpp/src/Column.cpp:44: undefined reference to `sqlite3_column_name'
/home/ocean/test/qt5_all/sqltest/XLIBS/SQLiteCpp/build/libSQLiteCpp.a(Column.cpp.o): In function `SQLite::Column::getOriginName() con
st':
/home/ocean/test/qt5_all/sqltest/XLIBS/SQLiteCpp/src/Column.cpp:51: undefined reference to `sqlite3_column_origin_name'
/home/ocean/test/qt5_all/sqltest/XLIBS/SQLiteCpp/build/libSQLiteCpp.a(Column.cpp.o): In function `SQLite::Column::getInt() const':
/home/ocean/test/qt5_all/sqltest/XLIBS/SQLiteCpp/src/Column.cpp:58: undefined reference to `sqlite3_column_int'

}

4. more info

{

ocean@mhc:~/test/qt5_all/sqltest/sqltest$ grep -rns "sqlite3_libversion" /home/ocean/test/qt5_all/sqltest/XLIBS/SQLiteCpp/build/
/home/ocean/test/qt5_all/sqltest/XLIBS/SQLiteCpp/build/SQLiteCpp_example1
/home/ocean/test/qt5_all/sqltest/XLIBS/SQLiteCpp/build/SQLiteCpp_tests
/home/ocean/test/qt5_all/sqltest/XLIBS/SQLiteCpp/build/sqlite3/libsqlite3.a
/home/ocean/test/qt5_all/sqltest/XLIBS/SQLiteCpp/build/sqlite3/CMakeFiles/sqlite3.dir/sqlite3.c.o
/home/ocean/test/qt5_all/sqltest/XLIBS/SQLiteCpp/build/libSQLiteCpp.a
/home/ocean/test/qt5_all/sqltest/XLIBS/SQLiteCpp/build/CMakeFiles/SQLiteCpp.dir/src/Database.cpp.o

}

Can somebody tell me why why XLIBS/SQLiteCpp/src/Column.cpp cannot read sqlite3_column_origin_name() from libsqlite3.a (sqlite3.c)? I have built XLIBS/SQLiteCpp/build/sqlite3/libsqlite3.a and then the XLIBS/SQLiteCpp/build/libSQLiteCpp.a !!

Outcomes