[odb-users] Compilation Error with ODB Qt Profile: C++11 Requirement and Missing QDateTime Header

k l lqk1163133210 at gmail.com
Sun Mar 30 04:25:00 EDT 2025


Dear ODB Development Team,
I hope this email finds you well. I am encountering an issue while using the ODB compiler with a class that includes Qt objects (specifically QDateTime). Despite specifying C++11 support, the compilation fails with errors related to Qt’s C++11 requirement and a missing header. Below are the details:
________________________________
Issue Description
When attempting to generate code for a PostgreSQL database using the ODB compiler with the Qt profile, the process fails with two critical errors:

  1.
Error 1:
复制

D:/.../qbasicatomic.h:61:4: error: #error "Qt requires C++11 support"

Note: The --std c++11 flag is explicitly included in the command.
  2.
Error 2:

test.h:5:21: fatal error: QDateTime: No such file or directory

________________________________
Steps to Reproduce

  1.
Compilation Command:

odb -d pgsql --std c++11 --profile qt -I QT_ROOT/include --generate-schema --schema-format embedded --generate-query --generate-session test.h

  2.
Relevant Code (test.h):

#pragma db object schema("schema") table("table")
class test {
public:
    #pragma db id auto column("id")
    long id_;

    #pragma db column("create_time")
    QDateTime create_time_;
};

________________________________
Environment & Context

  *
ODB Version: 2.4.0
  *
Qt Version: 5.15.2 (MinGW 8.1.0)
  *
OS: Windows
  *
Database: PostgreSQL
  *
Compiler: MinGW/g++

________________________________
Questions & Support Request

  1.
C++11 Compatibility:
     *
Why does Qt still report a missing C++11 support even with --std c++11? Is there an additional configuration required for the Qt profile?
  2.
Header Inclusion:
     *
The QDateTime header is not found despite providing -I QT_ROOT/include. Could this be related to path formatting (e.g., forward vs. backward slashes)?
  3.
Known Limitations:
     *
Are there known issues with mapping QDateTime in ODB’s Qt profile?

________________________________
Attachments/Additional Info

  1.
Full error log (attached or included below).
  2.
File test.h (attached).

________________________________
Thank you for your time and assistance! I would greatly appreciate any guidance to resolve this issue.
Best regards,
lain

-------------- next part --------------
#ifndef TEST_H
#define TEST_H

#include <odb/core.hxx>
#include <QDateTime>

#pragma db object schema("schema") table("table")
class test
{
public:
#pragma db id auto column("id")
    long id_;

#pragma db column("create_time")
    QDateTime create_time_;
};
#endif // TEST_H
-------------- next part --------------
 odb -d pgsql --std c++11 --profile qt -I D:/dev_sdk/qt/5.15.2/5.15.2/mingw81_64/include --generate-schema --schema-format embedded --generate-query --generate-session test.h
In file included from D:/dev_sdk/qt/5.15.2/5.15.2/mingw81_64/include/QtCore/qatomic.h:46:0,
                 from D:/dev_sdk/qt/5.15.2/5.15.2/mingw81_64/include/QtCore/qglobal.h:1306,
                 from D:/dev_sdk/qt/5.15.2/5.15.2/mingw81_64/include/QtCore/qchar.h:43,
                 from D:/dev_sdk/qt/5.15.2/5.15.2/mingw81_64/include/QtCore/qstring.h:49,
                 from D:/dev_sdk/qt/5.15.2/5.15.2/mingw81_64/include/QtCore/QString:1,
                 from d:\work_space\cpp\_third\odb-2.4.0-i686-windows\mingw\include\odb\qt\basic\pgsql\default-mapping.hxx:8,
                 from <odb-prologue-2>:1:
D:/dev_sdk/qt/5.15.2/5.15.2/mingw81_64/include/QtCore/qbasicatomic.h:61:4: error: #error "Qt requires C++11 support"
 #  error "Qt requires C++11 support"
    ^
test.h:5:21: fatal error: QDateTime: No such file or directory
 #include <QDateTime>
                     ^
compilation terminated.


More information about the odb-users mailing list