Help on making 3 years old code run with recent QxOrm

Forum for posting problems using QxOrm library

Help on making 3 years old code run with recent QxOrm

Postby rbertoche » Fri Oct 19, 2018 7:25 pm

Hey there fellow C++ programmers

I'm not really used to this library. It's API looks really nice and apparently it does a great job storing C++ classes in a Orm fashion but that's basically all I know about it right now.

Now I must reactivate this project that's been down for about 3 years and does extensive use of QxOrm. It's a remote control for an oil industry specialized inspection tool some other team made here where I work.

Some time ago I had already compiled it successfully, but since it uses QxOrm 1.3.2, it doesn't work anymore with available boost on opensuse, and we don't think sticking to boost 1.57 is a good idea. Hence I tried to get the project running with the latest QxOrm, 1.4.5. But now I'm starting to think I was too optimistic to think I'd be able to get that code running with QxOrm 1.4.5 just by fixing compilation errors. I'm stuck the first error caused by the update and I'm hoping to get some pointers here at this forum as I'm helplessly lost at the moment:

Code: Select all
error: static assertion failed: qx::trait::is_qx_registered<typename qx::QxSqlQueryBuilder<T>::type_sql>::value
    virtual ~QxDao_Helper() { static_assert(qx::trait::is_qx_registered<typename qx::QxSqlQueryBuilder<T>::type_sql>::value, "qx::trait::is_qx_registered<typename qx::QxSqlQueryBuilder<T>::type_sql>::value"); }


From the message I can figure it looks like some T type is not a properly registered type on Qx; I also can infer that this type is probably one of clientPtr, Client or maybe one of his members; What I don't know is whether it wasn't registered at all, because of some API change, or whether it's not yet registered at the moment the affected code line is being compiled.

That's my comprehension of if it as of now. Anybody can give me any directions toward a solution?

Thank all of you that read me this far!

Whole g++ output (i've ommited some unused argument warning)
Code: Select all
g++ -c -pipe -fPIC -g -Wall -W -D_REENTRANT -fPIC -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_SQL_LIB -DQT_SCRIPT_LIB -DQT_XML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -isystem /usr/include/Qt5GStreamer -Isrc -isystem /usr/include/qwt6 -isystem /usr/include/qt5 -I../Thirdparty/QxOrm/include -I../AuriBase/include -isystem /usr/include/qt5/QtWidgets -isystem /usr/include/qt5/QtGui -isystem /usr/include/qt5/QtSql -isystem /usr/include/qt5/QtScript -isystem /usr/include/qt5/QtXml -isystem /usr/include/qt5/QtNetwork -isystem /usr/include/qt5/QtCore -I. -isystem /usr/include/libdrm -I. -I/usr/lib64/qt5/mkspecs/linux-g++ -o videoutils.o src/videoutils.cpp
In file included from ../Thirdparty/QxOrm/include/QxDao/QxDao_Impl.h:67,
                 from ../Thirdparty/QxOrm/include/QxOrm.h:112,
                 from ../AuriBase/include/precompiled.h:4,
                 from ../AuriBase/include/dbmanager.h:4,
                 from src/clientdialog.h:5,
                 from src/clientdialog.cpp:1:
../Thirdparty/QxOrm/include/QxDao/../../inl/QxDao/QxDao_Helper.inl: In instantiation of ‘qx::dao::detail::QxDao_Helper<T>::~QxDao_Helper() [with T = boost::shared_ptr<Client>]’:
../Thirdparty/QxOrm/include/QxDao/../../inl/QxDao/QxDao_FetchAll.inl:42:40:   required from ‘static QSqlError qx::dao::detail::QxDao_FetchAll_Generic<T>::fetchAll(const qx::QxSqlQuery&, T&, QSqlDatabase*, const QStringList&) [with T = boost::shared_ptr<Client>]’
../Thirdparty/QxOrm/include/QxDao/../../inl/QxDao/QxDao_FetchAll.inl:174:45:   required from ‘static QSqlError qx::dao::detail::QxDao_FetchAll<T>::fetchAll(const qx::QxSqlQuery&, T&, QSqlDatabase*, const QStringList&) [with T = boost::shared_ptr<Client>]’
../Thirdparty/QxOrm/include/QxDao/QxDao.h:649:54:   required from ‘QSqlError qx::dao::fetch_by_query(const qx::QxSqlQuery&, T&, QSqlDatabase*, const QStringList&) [with T = boost::shared_ptr<Client>]’
src/clientdialog.cpp:39:42:   required from here
../Thirdparty/QxOrm/include/QxDao/../../inl/QxDao/QxDao_Helper.inl:45:44: error: static assertion failed: qx::trait::is_qx_registered<typename qx::QxSqlQueryBuilder<T>::type_sql>::value
    virtual ~QxDao_Helper() { static_assert(qx::trait::is_qx_registered<typename qx::QxSqlQueryBuilder<T>::type_sql>::value, "qx::trait::is_qx_registered<typename qx::QxSqlQueryBuilder<T>::type_sql>::value"); }
                                            ^~
In file included from ../Thirdparty/QxOrm/include/QxDao/QxSqlQueryHelper.h:68,
                 from ../Thirdparty/QxOrm/include/QxDao/QxSqlQueryBuilder.h:47,
                 from ../Thirdparty/QxOrm/include/QxOrm.h:98,
                 from ../AuriBase/include/precompiled.h:4,
                 from ../AuriBase/include/dbmanager.h:4,
                 from src/clientdialog.h:5,
                 from src/clientdialog.cpp:1:
../Thirdparty/QxOrm/include/QxDao/../../inl/QxDao/QxSqlQueryHelper_FetchAll.inl: In instantiation of ‘static void qx::dao::detail::QxSqlQueryHelper_FetchAll<T>::resolveOutput(T&, QSqlQuery&, qx::IxSqlQueryBuilder&, const QStringList&) [with T = boost::shared_ptr<Client>]’:
../Thirdparty/QxOrm/include/QxDao/../../inl/QxDao/QxDao_FetchAll.inl:67:70:   required from ‘static QSqlError qx::dao::detail::QxDao_FetchAll_Generic<T>::fetchAll(const qx::QxSqlQuery&, T&, QSqlDatabase*, const QStringList&) [with T = boost::shared_ptr<Client>]’
../Thirdparty/QxOrm/include/QxDao/../../inl/QxDao/QxDao_FetchAll.inl:174:45:   required from ‘static QSqlError qx::dao::detail::QxDao_FetchAll<T>::fetchAll(const qx::QxSqlQuery&, T&, QSqlDatabase*, const QStringList&) [with T = boost::shared_ptr<Client>]’
../Thirdparty/QxOrm/include/QxDao/QxDao.h:649:54:   required from ‘QSqlError qx::dao::fetch_by_query(const qx::QxSqlQuery&, T&, QSqlDatabase*, const QStringList&) [with T = boost::shared_ptr<Client>]’
src/clientdialog.cpp:39:42:   required from here
../Thirdparty/QxOrm/include/QxDao/../../inl/QxDao/QxSqlQueryHelper_FetchAll.inl:68:21: error: static assertion failed: qx::trait::is_qx_registered<T>::value
       static_assert(qx::trait::is_qx_registered<T>::value, "qx::trait::is_qx_registered<T>::value");
 ]}


I'll post here the class definition and also the usage that triggered the first error:
Code: Select all
/* part of clientdialog.cpp
I'm ommiting its includes but the important part is that ClientDialog has a clientPtr client member
*/
29 void ClientDialog::on_btnSave_clicked()
30 {
31     if (ui->name->text().isEmpty()) {
32         QMessageBox::critical(this, "Error Occurred", tr("The following fields are empty: \n * Name"));
33         return;
34     }
35
36     qx::QxSqlQuery query("WHERE Client.name = :name");
37     query.bind(":name", ui->name->text());
38
39     qx::dao::fetch_by_query(query, client);   // first required from here
40
41     client->name    = ui->name->text();
42     client->contact = ui->contact->text();
43
44     if (!qx::dao::save(client).isValid())
45         this->accept();
46 }


Code: Select all
/* client.h defining Client and clientPtr */
#ifndef CLIENT_H
#define CLIENT_H


#include <QxOrm.h>
#include <boost/shared_ptr.hpp>
#include "export.h"

class Pipe;

class AURI_BASE_DLL_EXPORT Client
{
public:

  typedef boost::shared_ptr<Pipe> pipePtr;
  typedef std::vector<pipePtr> listPipe;

  long id;
  QString name;
  QString contact;
  listPipe pipes;

  Client() : id(false) { ; }
  virtual ~Client(){ ; }

};

QX_REGISTER_HPP_AURI_BASE(Client, qx::trait::no_base_class_defined, 0)

typedef boost::shared_ptr<Client> clientPtr;
typedef QList<clientPtr> listClient;

#endif // CLIENT_H

rbertoche
 
Posts: 3
Joined: Fri Oct 19, 2018 6:39 pm

Re: Help on making 3 years old code run with recent QxOrm

Postby qxorm » Mon Oct 22, 2018 7:49 am

Hello,

Welcome on this forum !

Here you have all changes made between QxOrm 1.3.2 and latest QxOrm 1.4.5 versions : https://www.qxorm.com/qxorm_en/download ... ownload_10
I think the biggest change is that boost is now optional and not enabled by default (QxOrm is only Qt dependency).
But if you add correct compilation option, you should be able to compile and run your program without error (we kept ascendant compatibility).

Code: Select all
g++ -c -pipe -fPIC -g -Wall -W -D_REENTRANT -fPIC -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_SQL_LIB -DQT_SCRIPT_LIB -DQT_XML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB

I don't see any BOOST compilation options, and I think this is your issue.
You should read QxOrm.pri configuration file and enable at least _QX_ENABLE_BOOST.
And I think also _QX_ENABLE_BOOST_SERIALIZATION because you come from QxOrm 1.3.2 version.

I also see that you put these includes in a header file :
Code: Select all
#include <QxOrm.h>
#include <boost/shared_ptr.hpp>
#include "export.h"

Don't do this ==> you should put them in a precompiled header.
qxorm
Site Admin
 
Posts: 439
Joined: Mon Apr 12, 2010 7:45 am

Re: Help on making 3 years old code run with recent QxOrm

Postby rbertoche » Mon Oct 22, 2018 4:59 pm

Thanks a lot for your answer!

That run I had the line that includes "QxOrm.pri" commented out and was trying to compile without the precompiled header.

I'll try it with both these things and check if those defines will show up. But It's really strange since I did toggle _QX_ENABLE_BOOST! Directly in QxOrm.pro, is that a bad idea?
rbertoche
 
Posts: 3
Joined: Fri Oct 19, 2018 6:39 pm

Re: Help on making 3 years old code run with recent QxOrm

Postby rbertoche » Tue Oct 23, 2018 8:23 pm

I've solved it by compiling it without boost_serialization! I took me some time to figure I could still use structures containing boost:shared_ptr even without boost_serialization - of course, now it seems quite obvious

As the solution came to me while I was writing this post, I'm still submitting this quote here to show the thoughts that lead me to that solution and also to know whether there is another way to get it running with boost, out of sheer curiosity, as in this case boost it is completely optional to me, as long as I still use shared_ptr.

Thank you for giving me the pointers, it seems the major problem were those missing defines you pointed out!

The post where I intended to ask how to compile QxOrm using boost from /usr/include:

I figured out how to add those missing defines by including QxOrm.pri on some other .pro file where it was commented out.

Now I can get past that is_valid assertion_error and what I get is some undefined references. Looking at QxOrm.so I saw they were already missing there. I'm uploading ldd -r libQxOrmd.so output, there are a bunch of boost symbols missing. I'm assuming the application compilation undefined reference error comes from the QxOrm compilation.

That seems to be related to something else: I didn't really get what should I do to build QxOrm using boost libraries installed regularly as packages in my system. I tried passing QX_BOOST_INCLUDE_PATH=/usr/include and though that passes the version.hpp test it fails to do absurdly simple things such as including <math.h> inside other libs headers. That lead me to disable the isEmpty( QX_BOOST_INCLUDE_PATH ) and let g++ use the appropriate installed boost headers. QX_CHECK_BOOST_INCLUDE_PATH was set to /usr/include/boost/version.hpp to pass the version test. That seemed to work, though I get those undefined references at libQxOrm.so. I've manually added appropriate lib linking "-l" directives so they shouldn't be missing.

Other than all those hacks I had to make to avoid downloading and compiling boosts, is there a simpler way to tell QxOrm to use the default available installation and headers from the system, instead of passing an absolute path to it?


Edit: I still had to patch some hacks on QxOrm.pri to avoid triggering errors while using _QX_ENABLE_BOOST without setting QX_BOOST_INCLUDE_PATH. I'm uploading a diff file with those changes.

The files I intended to upload here:

ldd showing missing references on libQxOrmd.so:
https://drive.google.com/open?id=1FRD4t ... Sdej8WzDgZ

compiling QxOrm:
https://drive.google.com/open?id=141B-0 ... uQZaJUMziH

QxOrm.pri diff:
https://drive.google.com/open?id=1B1elY ... 7h1RTNR8zC
rbertoche
 
Posts: 3
Joined: Fri Oct 19, 2018 6:39 pm

Re: Help on making 3 years old code run with recent QxOrm

Postby qxorm » Wed Oct 24, 2018 7:44 am

I've solved it by compiling it without boost_serialization!
it seems the major problem were those missing defines you pointed out!

Great !
qxorm
Site Admin
 
Posts: 439
Joined: Mon Apr 12, 2010 7:45 am


Return to QxOrm - Help

Who is online

Users browsing this forum: No registered users and 1 guest

cron