silverqx / TinyORM

Modern C++ ORM library
https://www.tinyorm.org
MIT License
242 stars 25 forks source link

compilation error #14

Closed 13015517713 closed 1 year ago

13015517713 commented 1 year ago

I completed the build of the project and compiled the tinyorm library. When running a test sample, the compilation reports an error. This seems to be related to the qt5 library, perhaps this requires a qmake build. I don't know much about QT applications and I'm not sure which libraries to import. I have built the Qt5 library on ubuntu, but there is no .cmake file. So I chose to import the qt libraries manually. I have seen some people say that qt dependencies need to be built with qmake, I didn't understand those and I used the following way build.

using Orm::DB;

// Ownership of a shared_ptr() auto manager = DB::create({ {"driver", "QMYSQL"}, {"host", qEnvironmentVariable("DB_HOST", "127.0.0.1")}, {"port", qEnvironmentVariable("DB_PORT", "3306")}, {"database", qEnvironmentVariable("DB_DATABASE", "")}, {"username", qEnvironmentVariable("DB_USERNAME", "root")}, {"password", qEnvironmentVariable("DB_PASSWORD", "")}, {"charset", qEnvironmentVariable("DB_CHARSET", "utf8mb4")}, {"collation", qEnvironmentVariable("DB_COLLATION", "utf8mb4_0900_ai_ci")}, {"timezone", "+00:00"}, // Specifies what time zone all QDateTime-s will have {"qt_timezone", QVariant::fromValue(Qt::UTC)}, {"prefix", ""}, {"prefix_indexes", false}, {"strict", true}, {"engine", "InnoDB"}, {"options", QVariantHash()}, }); int main(){ return 0; }


- Makefile

app is cpp filename above

CC = /usr/bin/gcc-11 CXX = /usr/bin/g++-11

Iinclude = -I/home/wcx/gitProject/cpp_interview/TinyORM/include Iinclude += -I/home/wcx/gitProject/cpp_interview/TinyORM/dep/range-v3/include Iinclude += -I/home/wcx/gitProject/cpp_interview/TinyORM/dep/tabulate/include Iinclude += -I/home/wcx/gitProject/cpp_interview/TinyORM/dep/qt5/qt-everywhere-src-5.15.2/qtbase/include Iinclude += -I/home/wcx/gitProject/cpp_interview/TinyORM/dep/qt5/qt-everywhere-src-5.15.2/qtbase/include/QtCore Iinclude += -I/home/wcx/gitProject/cpp_interview/TinyORM/dep/qt5/qt-everywhere-src-5.15.2/qtbase/include/QtSql

INCPATH = -I. -I. -I../TinyORM/dep/qt5/qt-everywhere-src-5.15.2/qtbase/include -I/home/wcx/gitProject/cpp_interview/TinyORM/dep/qt5/qt-everywhere-src-5.15.2/qtbase/include -I../TinyORM/dep/qt5/qt-everywhere-src-5.15.2/qtbase/include/QtGui -I/home/wcx/gitProject/cpp_interview/TinyORM/dep/qt5/qt-everywhere-src-5.15.2/qtbase/include/QtGui -I../TinyORM/dep/qt5/qt-everywhere-src-5.15.2/qtbase/include/QtCore -I/home/wcx/gitProject/cpp_interview/TinyORM/dep/qt5/qt-everywhere-src-5.15.2/qtbase/include/QtCore -I. -I/usr/include/libdrm -I/home/wcx/gitProject/cpp_interview/TinyORM/dep/qt5/qt-everywhere-src-5.15.2/qtbase/mkspecs/linux-g++ Iinclude += $(INCPATH)

Llib = -L/home/wcx/gitProject/cpp_interview/TinyORM/build Llib += -L/home/wcx/gitProject/cpp_interview/TinyORM/dep/qt5/qt-everywhere-src-5.15.2/qtbase/lib

libs = /home/wcx/gitProject/cpp_interview/TinyORM/dep/qt5/qt-everywhere-src-5.15.2/qtbase/lib/libQt5Gui.so /home/wcx/gitProject/cpp_interview/TinyORM/dep/qt5/qt-everywhere-src-5.15.2/qtbase/lib/libQt5Core.so -lGL -lpthread libs += -lTinyOrm -lQt5Sql -lQt5Core

CFLAGS = -Werror -fPIC -Wall -Wextra -pedantic -std=c++20 -O0 $(libs) $(Iinclude) $(Llib)

all: $(app)

$(app): $(app).cpp $(CXX) $(CFLAGS) -o $(app) $(app).cpp


- compilation error information

/usr/bin/g++-11 -Werror -fPIC -Wall -Wextra -pedantic -std=c++20 -O0 /home/wcx/gitProject/cpp_interview/TinyORM/dep/qt5/qt-everywhere-src-5.15.2/qtbase/lib/libQt5Gui.so /home/wcx/gitProject/cpp_interview/TinyORM/dep/qt5/qt-everywhere-src-5.15.2/qtbase/lib/libQt5Core.so -lGL -lpthread -lTinyOrm -lQt5Sql -lQt5Core -I/home/wcx/gitProject/cpp_interview/TinyORM/include -I/home/wcx/gitProject/cpp_interview/TinyORM/dep/range-v3/include -I/home/wcx/gitProject/cpp_interview/TinyORM/dep/tabulate/include -I/home/wcx/gitProject/cpp_interview/TinyORM/dep/qt5/qt-everywhere-src-5.15.2/qtbase/include -I/home/wcx/gitProject/cpp_interview/TinyORM/dep/qt5/qt-everywhere-src-5.15.2/qtbase/include/QtCore -I/home/wcx/gitProject/cpp_interview/TinyORM/dep/qt5/qt-everywhere-src-5.15.2/qtbase/include/QtSql -I. -I. -I../TinyORM/dep/qt5/qt-everywhere-src-5.15.2/qtbase/include -I/home/wcx/gitProject/cpp_interview/TinyORM/dep/qt5/qt-everywhere-src-5.15.2/qtbase/include -I../TinyORM/dep/qt5/qt-everywhere-src-5.15.2/qtbase/include/QtGui -I/home/wcx/gitProject/cpp_interview/TinyORM/dep/qt5/qt-everywhere-src-5.15.2/qtbase/include/QtGui -I../TinyORM/dep/qt5/qt-everywhere-src-5.15.2/qtbase/include/QtCore -I/home/wcx/gitProject/cpp_interview/TinyORM/dep/qt5/qt-everywhere-src-5.15.2/qtbase/include/QtCore -I. -I/usr/include/libdrm -I/home/wcx/gitProject/cpp_interview/TinyORM/dep/qt5/qt-everywhere-src-5.15.2/qtbase/mkspecs/linux-g++ -L/home/wcx/gitProject/cpp_interview/TinyORM/build -L/home/wcx/gitProject/cpp_interview/TinyORM/dep/qt5/qt-everywhere-src-5.15.2/qtbase/lib -o connect connect.cpp /usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/Scrt1.o: In function _start': (.text+0x20): undefined reference tomain' /tmp/cciGGVit.o: In function __static_initialization_and_destruction_0(int, int)': connect.cpp:(.text+0x301f): undefined reference toqEnvironmentVariable(char const, QString const&)' connect.cpp:(.text+0x307f): undefined reference to `qEnvironmentVariable(char const, QString const&)' connect.cpp:(.text+0x30df): undefined reference to qEnvironmentVariable(char const*, QString const&)' connect.cpp:(.text+0x313f): undefined reference toqEnvironmentVariable(char const, QString const&)' connect.cpp:(.text+0x319f): undefined reference to `qEnvironmentVariable(char const, QString const&)' /tmp/cciGGVit.o:connect.cpp:(.text+0x31ff): more undefined references to qEnvironmentVariable(char const*, QString const&)' follow /tmp/cciGGVit.o: In function__static_initialization_and_destruction_0(int, int)': connect.cpp:(.text+0x3430): undefined reference to Orm::DB::create(QHash<QString, QVariant> const&, QString const&)' connect.cpp:(.text+0x3485): undefined reference toQVariant::~QVariant()' connect.cpp:(.text+0x35ec): undefined reference to QVariant::~QVariant()' /tmp/cciGGVit.o:(.qtversion[qt_version_tag]+0x0): undefined reference toqt_version_tag' /tmp/cciGGVit.o: In function QArrayData::data()': connect.cpp:(.text._ZN10QArrayData4dataEv[_ZN10QArrayData4dataEv]+0x4c): undefined reference toqt_assert(char const, char const, int)' /tmp/cciGGVit.o: In function QArrayData::sharedNull()': connect.cpp:(.text._ZN10QArrayData10sharedNullEv[_ZN10QArrayData10sharedNullEv]+0x7): undefined reference toQArrayData::shared_null' /tmp/cciGGVit.o: In function QString::QString(char const*)': connect.cpp:(.text._ZN7QStringC2EPKc[_ZN7QStringC5EPKc]+0x36): undefined reference toQString::fromAscii_helper(char const, int)' /tmp/cciGGVit.o: In function QString::QString(QLatin1String)': connect.cpp:(.text._ZN7QStringC2E13QLatin1String[_ZN7QStringC5E13QLatin1String]+0x41): undefined reference toQString::fromLatin1_helper(char const, int)' /tmp/cciGGVit.o: In function QString::QString(QString const&)': connect.cpp:(.text._ZN7QStringC2ERKS_[_ZN7QStringC5ERKS_]+0x42): undefined reference toqt_assert(char const, char const, int)' /tmp/cciGGVit.o: In function QHashData::willGrow()': connect.cpp:(.text._ZN9QHashData8willGrowEv[_ZN9QHashData8willGrowEv]+0x34): undefined reference toQHashData::rehash(int)' /tmp/cciGGVit.o: In function qt_getQtMetaObject()': connect.cpp:(.text._Z18qt_getQtMetaObjectv[_Z18qt_getQtMetaObjectv]+0x7): undefined reference toQObject::staticQtMetaObject' /tmp/cciGGVit.o: In function std::pair<QString, QVariant>::~pair()': connect.cpp:(.text._ZNSt4pairI7QString8QVariantED2Ev[_ZNSt4pairI7QString8QVariantED5Ev]+0x18): undefined reference toQVariant::~QVariant()' /tmp/cciGGVit.o: In function std::pair<QString, QVariant>::pair<char const (&) [7], char const (&) [7], true>(char const (&) [7], char const (&) [7])': connect.cpp:(.text._ZNSt4pairI7QString8QVariantEC1IRA7_KcS6_Lb1EEEOT_OT0_[_ZNSt4pairI7QString8QVariantEC1IRA7_KcS6_Lb1EEEOT_OT0_]+0x4b): undefined reference toQVariant::QVariant(char const)' /tmp/cciGGVit.o: In function std::pair<QString, QVariant>::pair<char const (&) [9], char const (&) [7], true>(char const (&) [9], char const (&) [7])': connect.cpp:(.text._ZNSt4pairI7QString8QVariantEC1IRA9_KcRA7_S4_Lb1EEEOT_OT0_[_ZNSt4pairI7QString8QVariantEC1IRA9_KcRA7_S4_Lb1EEEOT_OT0_]+0x4b): undefined reference toQVariant::QVariant(char const)' /tmp/cciGGVit.o: In function std::pair<QString, QVariant>::pair<char const (&) [7], char const (&) [1], true>(char const (&) [7], char const (&) [1])': connect.cpp:(.text._ZNSt4pairI7QString8QVariantEC1IRA7_KcRA1_S4_Lb1EEEOT_OT0_[_ZNSt4pairI7QString8QVariantEC1IRA7_KcRA1_S4_Lb1EEEOT_OT0_]+0x4b): undefined reference toQVariant::QVariant(char const)' /tmp/cciGGVit.o: In function std::pair<QString, QVariant>::pair<char const (&) [15], bool, true>(char const (&) [15], bool&&)': connect.cpp:(.text._ZNSt4pairI7QString8QVariantEC1IRA15_KcbLb1EEEOT_OT0_[_ZNSt4pairI7QString8QVariantEC1IRA15_KcbLb1EEEOT_OT0_]+0x50): undefined reference toQVariant::QVariant(bool)' /tmp/cciGGVit.o: In function std::pair<QString, QVariant>::pair<char const (&) [7], bool, true>(char const (&) [7], bool&&)': connect.cpp:(.text._ZNSt4pairI7QString8QVariantEC1IRA7_KcbLb1EEEOT_OT0_[_ZNSt4pairI7QString8QVariantEC1IRA7_KcbLb1EEEOT_OT0_]+0x50): undefined reference toQVariant::QVariant(bool)' /tmp/cciGGVit.o: In function `QTypedArrayData::deallocate(QArrayData)': connect.cpp:(.text._ZN15QTypedArrayDataIcE10deallocateEP10QArrayData[_ZN15QTypedArrayDataIcE10deallocateEP10QArrayData]+0x1e): undefined reference to QArrayData::deallocate(QArrayData*, unsigned long, unsigned long)' /tmp/cciGGVit.o: In functionQTypedArrayData::deallocate(QArrayData)': connect.cpp:(.text._ZN15QTypedArrayDataItE10deallocateEP10QArrayData[_ZN15QTypedArrayDataItE10deallocateEP10QArrayData]+0x1e): undefined reference to `QArrayData::deallocate(QArrayData, unsigned long, unsigned long)' /tmp/cciGGVit.o: In function QHash<QString, QVariant>::QHash()': connect.cpp:(.text._ZN5QHashI7QString8QVariantEC2Ev[_ZN5QHashI7QString8QVariantEC5Ev]+0xf): undefined reference toQHashData::shared_null' /tmp/cciGGVit.o: In function QHash<QString, QVariant>::reserve(int)': connect.cpp:(.text._ZN5QHashI7QString8QVariantE7reserveEi[_ZN5QHashI7QString8QVariantE7reserveEi]+0x56): undefined reference toQHashData::rehash(int)' /tmp/cciGGVit.o: In function QStaticStringData<1>::data_ptr() const': connect.cpp:(.text._ZNK17QStaticStringDataILi1EE8data_ptrEv[_ZNK17QStaticStringDataILi1EE8data_ptrEv]+0x36): undefined reference toqt_assert(char const, char const, int)' /tmp/cciGGVit.o: In function QStaticStringData<2>::data_ptr() const': connect.cpp:(.text._ZNK17QStaticStringDataILi2EE8data_ptrEv[_ZNK17QStaticStringDataILi2EE8data_ptrEv]+0x36): undefined reference toqt_assert(char const, char const, int)' /tmp/cciGGVit.o: In function QStaticStringData<5>::data_ptr() const': connect.cpp:(.text._ZNK17QStaticStringDataILi5EE8data_ptrEv[_ZNK17QStaticStringDataILi5EE8data_ptrEv]+0x36): undefined reference toqt_assert(char const, char const, int)' /tmp/cciGGVit.o: In function QStaticStringData<4>::data_ptr() const': connect.cpp:(.text._ZNK17QStaticStringDataILi4EE8data_ptrEv[_ZNK17QStaticStringDataILi4EE8data_ptrEv]+0x36): undefined reference toqt_assert(char const, char const, int)' /tmp/cciGGVit.o: In function QStaticStringData<3>::data_ptr() const': connect.cpp:(.text._ZNK17QStaticStringDataILi3EE8data_ptrEv[_ZNK17QStaticStringDataILi3EE8data_ptrEv]+0x36): undefined reference toqt_assert(char const, char const, int)' /tmp/cciGGVit.o:connect.cpp:(.text._ZNK17QStaticStringDataILi10EE8data_ptrEv[_ZNK17QStaticStringDataILi10EE8data_ptrEv]+0x36): more undefined references to qt_assert(char const*, char const*, int)' follow /tmp/cciGGVit.o: In functionint qRegisterMetaType(char const, Qt::TimeSpec, QtPrivate::MetaTypeDefinedHelper<Qt::TimeSpec, QMetaTypeId2::Defined&&(!QMetaTypeId2::IsBuiltIn)>::DefinedType)': connect.cpp:(.text._Z17qRegisterMetaTypeIN2Qt8TimeSpecEEiPKcPT_N9QtPrivate21MetaTypeDefinedHelperIS4_Xaasr12QMetaTypeId2IS4_E7DefinedntsrS9_9IsBuiltInEE11DefinedTypeE[_Z17qRegisterMetaTypeIN2Qt8TimeSpecEEiPKcPT_N9QtPrivate21MetaTypeDefinedHelperIS4_Xaasr12QMetaTypeId2IS4_E7DefinedntsrS9_9IsBuiltInEE11DefinedTypeE]+0x32): undefined reference to QMetaObject::normalizedType(char const*)' /tmp/cciGGVit.o: In functionQStaticStringData<17>::data_ptr() const': connect.cpp:(.text._ZNK17QStaticStringDataILi17EE8data_ptrEv[_ZNK17QStaticStringDataILi17EE8data_ptrEv]+0x36): undefined reference to qt_assert(char const*, char const*, int)' /tmp/cciGGVit.o: In functionQStaticStringData<12>::data_ptr() const': connect.cpp:(.text._ZNK17QStaticStringDataILi12EE8data_ptrEv[_ZNK17QStaticStringDataILi12EE8data_ptrEv]+0x36): undefined reference to qt_assert(char const*, char const*, int)' /tmp/cciGGVit.o: In functionQStaticStringData<26>::data_ptr() const': connect.cpp:(.text._ZNK17QStaticStringDataILi26EE8data_ptrEv[_ZNK17QStaticStringDataILi26EE8data_ptrEv]+0x36): undefined reference to qt_assert(char const*, char const*, int)' /tmp/cciGGVit.o: In functionQVariant QVariant::fromValue(Qt::TimeSpec const&)': connect.cpp:(.text._ZN8QVariant9fromValueIN2Qt8TimeSpecEEESRKT[_ZN8QVariant9fromValueIN2Qt8TimeSpecEEESRKT]+0x28): undefined reference to QVariant::QVariant(int, void const*, unsigned int)' /tmp/cciGGVit.o: In functionstd::pair<QString, QVariant>::pair<char const (&) [5], QString, true>(char const (&) [5], QString&&)': connect.cpp:(.text._ZNSt4pairI7QString8QVariantEC2IRA5_KcS0_Lb1EEEOTOT0[_ZNSt4pairI7QString8QVariantEC5IRA5_KcS0_Lb1EEEOTOT0]+0x4b): undefined reference to QVariant::QVariant(QString const&)' /tmp/cciGGVit.o: In functionstd::pair<QString, QVariant>::pair<char const (&) [9], QString, true>(char const (&) [9], QString&&)': connect.cpp:(.text._ZNSt4pairI7QString8QVariantEC2IRA9_KcS0_Lb1EEEOTOT0[_ZNSt4pairI7QString8QVariantEC5IRA9_KcS0_Lb1EEEOTOT0]+0x4b): undefined reference to QVariant::QVariant(QString const&)' /tmp/cciGGVit.o: In functionstd::pair<QString, QVariant>::pair<char const (&) [8], QString, true>(char const (&) [8], QString&&)': connect.cpp:(.text._ZNSt4pairI7QString8QVariantEC2IRA8_KcS0_Lb1EEEOTOT0[_ZNSt4pairI7QString8QVariantEC5IRA8_KcS0_Lb1EEEOTOT0]+0x4b): undefined reference to QVariant::QVariant(QString const&)' /tmp/cciGGVit.o: In functionstd::pair<QString, QVariant>::pair<char const (&) [10], QString, true>(char const (&) [10], QString&&)': connect.cpp:(.text._ZNSt4pairI7QString8QVariantEC2IRA10_KcS0_Lb1EEEOTOT0[_ZNSt4pairI7QString8QVariantEC5IRA10_KcS0_Lb1EEEOTOT0]+0x4b): undefined reference to QVariant::QVariant(QString const&)' /tmp/cciGGVit.o: In functionstd::pair<QString, QVariant>::pair<char const (&) [8], QHash<QString, QVariant>, true>(char const (&) [8], QHash<QString, QVariant>&&)': connect.cpp:(.text._ZNSt4pairI7QString8QVariantEC2IRA8_Kc5QHashIS0_S1_ELb1EEEOTOT0[_ZNSt4pairI7QString8QVariantEC5IRA8_Kc5QHashIS0_S1_ELb1EEEOTOT0]+0x4b): undefined reference to QVariant::QVariant(QHash<QString, QVariant> const&)' /tmp/cciGGVit.o: In functionQHash<QString, QVariant>::QHash(std::initializer_list<std::pair<QString, QVariant> >)': connect.cpp:(.text._ZN5QHashI7QString8QVariantEC2ESt16initializer_listISt4pairIS0_S1_EE[_ZN5QHashI7QString8QVariantEC5ESt16initializer_listISt4pairIS0_S1_EE]+0x27): undefined reference to QHashData::shared_null' /tmp/cciGGVit.o: In functionQHash<QString, QVariant>::freeData(QHashData)': connect.cpp:(.text._ZN5QHashI7QString8QVariantE8freeDataEP9QHashData[_ZN5QHashI7QString8QVariantE8freeDataEP9QHashData]+0x22): undefined reference to `QHashData::free_helper(void ()(QHashData::Node))' /tmp/cciGGVit.o: In function `QHash<QString, QVariant>::findNode(QString const&, unsigned int) const': connect.cpp:(.text._ZNK5QHashI7QString8QVariantE8findNodeERKS0_Pj[_ZNK5QHashI7QString8QVariantE8findNodeERKS0_Pj]+0x44): undefined reference to qHash(QString const&, unsigned int)' /tmp/cciGGVit.o: In functionQHash<QString, QVariant>::createNode(unsigned int, QString const&, QVariant const&, QHashNode<QString, QVariant>*)': connect.cpp:(.text._ZN5QHashI7QString8QVariantE10createNodeEjRKS0_RKS1_PP9QHashNodeIS0_S1_E[_ZN5QHashI7QString8QVariantE10createNodeEjRKS0_RKS1_PP9QHashNodeIS0_S1_E]+0x32): undefined reference to QHashData::allocateNode(int)' /tmp/cciGGVit.o: In functionint qRegisterNormalizedMetaType(QByteArray const&, Qt::TimeSpec, QtPrivate::MetaTypeDefinedHelper<Qt::TimeSpec, QMetaTypeId2::Defined&&(!QMetaTypeId2::IsBuiltIn)>::DefinedType)': connect.cpp:(.text._Z27qRegisterNormalizedMetaTypeIN2Qt8TimeSpecEEiRK10QByteArrayPT_N9QtPrivate21MetaTypeDefinedHelperIS5_Xaasr12QMetaTypeId2IS5_E7DefinedntsrSA_9IsBuiltInEE11DefinedTypeE[_Z27qRegisterNormalizedMetaTypeIN2Qt8TimeSpecEEiRK10QByteArrayPT_N9QtPrivate21MetaTypeDefinedHelperIS5_Xaasr12QMetaTypeId2IS5_E7DefinedntsrSA_9IsBuiltInEE11DefinedTypeE]+0x3c): undefined reference to QMetaObject::normalizedType(char const*)' connect.cpp:(.text._Z27qRegisterNormalizedMetaTypeIN2Qt8TimeSpecEEiRK10QByteArrayPT_N9QtPrivate21MetaTypeDefinedHelperIS5_Xaasr12QMetaTypeId2IS5_E7DefinedntsrSA_9IsBuiltInEE11DefinedTypeE[_Z27qRegisterNormalizedMetaTypeIN2Qt8TimeSpecEEiRK10QByteArrayPT_N9QtPrivate21MetaTypeDefinedHelperIS5_Xaasr12QMetaTypeId2IS5_E7DefinedntsrSA_9IsBuiltInEE11DefinedTypeE]+0x7b): undefined reference toqt_assert_x(char const, char const, char const, int)' connect.cpp:(.text._Z27qRegisterNormalizedMetaTypeIN2Qt8TimeSpecEEiRK10QByteArrayPT_N9QtPrivate21MetaTypeDefinedHelperIS5_Xaasr12QMetaTypeId2IS5_E7DefinedntsrSA_9IsBuiltInEE11DefinedTypeE[_Z27qRegisterNormalizedMetaTypeIN2Qt8TimeSpecEEiRK10QByteArrayPT_N9QtPrivate21MetaTypeDefinedHelperIS5_Xaasr12QMetaTypeId2IS5_E7DefinedntsrSA_9IsBuiltInEE11DefinedTypeE]+0xb4): undefined reference to QMetaType::registerNormalizedTypedef(QByteArray const&, int)' connect.cpp:(.text._Z27qRegisterNormalizedMetaTypeIN2Qt8TimeSpecEEiRK10QByteArrayPT_N9QtPrivate21MetaTypeDefinedHelperIS5_Xaasr12QMetaTypeId2IS5_E7DefinedntsrSA_9IsBuiltInEE11DefinedTypeE[_Z27qRegisterNormalizedMetaTypeIN2Qt8TimeSpecEEiRK10QByteArrayPT_N9QtPrivate21MetaTypeDefinedHelperIS5_Xaasr12QMetaTypeId2IS5_E7DefinedntsrSA_9IsBuiltInEE11DefinedTypeE]+0x107): undefined reference toQMetaType::registerNormalizedType(QByteArray const&, void ()(void), void ()(void, void const), int, QFlags, QMetaObject const)' /tmp/cciGGVit.o: In function QHash<QString, QVariant>::insert(QString const&, QVariant const&)': connect.cpp:(.text._ZN5QHashI7QString8QVariantE6insertERKS0_RKS1_[_ZN5QHashI7QString8QVariantE6insertERKS0_RKS1_]+0xd6): undefined reference toQVariant::operator=(QVariant const&)' /tmp/cciGGVit.o: In function QHashNode<QString, QVariant>::~QHashNode()': connect.cpp:(.text._ZN9QHashNodeI7QString8QVariantED2Ev[_ZN9QHashNodeI7QString8QVariantED5Ev]+0x18): undefined reference toQVariant::~QVariant()' /tmp/cciGGVit.o: In function QHash<QString, QVariant>::detach_helper()': connect.cpp:(.text._ZN5QHashI7QString8QVariantE13detach_helperEv[_ZN5QHashI7QString8QVariantE13detach_helperEv]+0x39): undefined reference toQHashData::detach_helper(void ()(QHashData::Node, void), void ()(QHashData::Node), int, int)' /tmp/cciGGVit.o: In function QHash<QString, QVariant>::findNode(QString const&, unsigned int) const': connect.cpp:(.text._ZNK5QHashI7QString8QVariantE8findNodeERKS0_j[_ZNK5QHashI7QString8QVariantE8findNodeERKS0_j]+0x91): undefined reference toqt_assert(char const, char const, int)' /tmp/cciGGVit.o: In function `QHashNode<QString, QVariant>::QHashNode(QString const&, QVariant const&, unsigned int, QHashNode<QString, QVariant>)': connect.cpp:(.text._ZN9QHashNodeI7QString8QVariantEC2ERKS0_RKS1jPS2[_ZN9QHashNodeI7QString8QVariantEC5ERKS0_RKS1jPS2]+0x5b): undefined reference to QVariant::QVariant(QVariant const&)' /tmp/cciGGVit.o: In functionQHashNode<QString, QVariant>::same_key(unsigned int, QString const&) const': connect.cpp:(.text._ZNK9QHashNodeI7QString8QVariantE8samekeyEjRKS0[_ZNK9QHashNodeI7QString8QVariantE8samekeyEjRKS0]+0x32): undefined reference to `operator==(QString const&, QString const&)' collect2: error: ld returned 1 exit status Makefile:26: recipe for target 'connect' failed make: *** [connect] Error 1

silverqx commented 1 year ago

As you wrote this problem doesn't relate to TinyORM, if you want to avoid the already prepared build system described in docs then you have to create your own makefiles and solve it somehow.

Also don't use Qt5, it's end of life, use Qt 6, also gcc 11 is little outdated, GCC 12 or 13 would be a much better choice.

Eg. the following commands are generated by the QtCreator with qmake with the latest gcc if you follow the TinyORM build documentation.

Compilation:

g++ -c -pipe -isystem /home/silverqx/Code/c/vcpkg/installed/x64-linux/include/ -g -std=c++2a -isystem /opt/Qt/6.5.1/gcc_64/include/ -isystem /opt/Qt/6.5.1/gcc_64/include/QtCore/ -isystem /opt/Qt/6.5.1/gcc_64/include/QtSql/ -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -Weffc++ -Werror -Wfatal-errors -Winvalid-pch -Wcast-qual -Wcast-align -Woverloaded-virtual -Wold-style-cast -Wshadow -Wundef -Wfloat-equal -Wformat-security -Wdouble-promotion -Wconversion -Wzero-as-null-pointer-constant -Wuninitialized -pedantic -pedantic-errors -Wdeprecated-copy-dtor -Wstrict-null-sentinel -D_REENTRANT -fPIC -DQT_DISABLE_DEPRECATED_BEFORE=0x060000 -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_BYTEARRAY -DQT_USE_QSTRINGBUILDER -DQT_STRICT_ITERATORS -DTINYORM_DEBUG -DTINYORM_DEBUG_SQL -DTINYTOM_DEBUG -DPROJECT_TINYORM -DTINYORM_BUILDING_SHARED -DTINYORM_EXTERN_CONSTANTS -DQT_NO_KEYWORDS -DQT_SQL_LIB -DQT_CORE_LIB -I/home/silverqx/Code/c/TinyOrm/TinyORM/src -I. -I/home/silverqx/Code/c/TinyOrm/TinyORM/include -I/home/silverqx/Code/c/TinyOrm/TinyORM/tom/include -I/opt/Qt/6.5.1/gcc_64/include -I/opt/Qt/6.5.1/gcc_64/include/QtSql -I/opt/Qt/6.5.1/gcc_64/include/QtCore -I. -I/opt/Qt/6.5.1/gcc_64/mkspecs/linux-g++ -o modelcommand.o /home/silverqx/Code/c/TinyOrm/TinyORM/tom/src/tom/commands/make/modelcommand.cpp

Linking:

g++ -fuse-ld=gold -Wl,-rpath,/opt/Qt/6.5.1/gcc_64/lib -shared -Wl,-soname,libTinyOrm.so.0 -o libTinyOrm.so.0.30.3 basegrammar.o countsqueries.o detectslostconnections.o <...obj files...> /opt/Qt/6.5.1/gcc_64/lib/libQt6Sql.so /opt/Qt/6.5.1/gcc_64/lib/libQt6Core.so -lpthread

Pls use cmake or QtCreator with qmake.

13015517713 commented 1 year ago

I wrote the Makefile directly, which in fact serves the same purpose as cmake. The cmake build in the documentation does not give examples of linking to other libraries, including QtSql, and whether I can import these manually without applying qmake.

silverqx commented 1 year ago

I wrote the Makefile directly, which in fact serves the same purpose as cmake.

Yea that's true but it has a little problem, it doesn't work for you 😎

The cmake build in the documentation does not give examples of linking to other libraries, including QtSql, and whether I can import these manually without applying qmake.

Here is the example you are looking for.

These commands are actually taking care of linking:

find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)
find_package(TinyOrm 0.16.0 CONFIG REQUIRED)

Pls follow the Hello World documentation to build a simple hello world project.

I have designed the CMakeLists.txt file as simple as possible, it has ~20 lines. When you will have a working example then you can rewrite it to the raw makefiles.

13015517713 commented 1 year ago

Ok. Thanks for your help.

silverqx commented 1 year ago

Were you successful or did you give up?

13015517713 commented 1 year ago

The problem I had was that the Qt I compiled didn't include a Qtconfig.cmake for import, and after locating it I found a qtconfig.cmake in the anaconda library. After importing it via cmake, I still had that problem, so I decided to pause.

After building via cmake, the find_package command in cmake was successful in finding QT. I think it is still because the qt library was not imported correctly and also reported an error. If Qt library is imported correctly, the problem can be solved.

I have some suggestions: