我目前正在使用 Mac OS X 10.9.4、odb 2.3.0 和 qt 5.3。
我使用他们的 unix 指南http://wiki.codesynthesis.com/Using_ODB_with_Qt_Creator_on_Linux安装了 odb
我尝试使用 qt 从他们的站点编译示例(odb-examples-2.3.0)并收到此错误消息:
19:55:15: Running steps for project odbtest...
19:55:15: Configuration unchanged, skipping qmake step.
19:55:15: Starting: "/usr/bin/make"
odb --database sqlite --profile qt --generate-schema --generate-query --generate-session -I/Applications/Qt/5.3/clang_64/include ../odbtest/employee.hxx
make: odb: No such file or directory
make: *** [employee-odb.cxx] Error 1
19:55:16: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project odbtest (kit: Desktop Qt 5.3.0 clang 64bit)
When executing step "Make"
19:55:16: Elapsed time: 00:00.
我的 .pro 文件看起来像这样(这几乎是示例的精确副本):
#-------------------------------------------------
#
# Project created by QtCreator 2014-09-07T16:51:45
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = odbtest
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
driver.cxx
HEADERS += mainwindow.h \
database.hxx \
employee.hxx
FORMS += mainwindow.ui
# List of header files that should be compiled with the ODB compiler.
#
ODB_FILES += employee.hxx
# ODB compiler flags.
#
ODB_FLAGS = --database sqlite --profile qt --generate-schema --generate-query --generate-session
# Select the database we are going to use.
#
DEFINES += DATABASE_SQLITE
# Suppress unknown pragmas GCC warnings.
#
QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CXXFLAGS_WARN_ON -Wno-unknown-pragmas
# Link to the ODB runtime libraries.
#
LIBS += -lodb-sqlite
LIBS += -lodb-qt
LIBS += -lodb
# ODB compilation rules. Normally you don't need to change anything here.
#
# Add the Qt headers directory to the ODB include directory list.
#
ODB_FLAGS += -I$$[QT_INSTALL_HEADERS]
# Newer versions of QtCreator do builds in a separate directory. As a
# result, we need to append the source directory to ODB files.
#
for(dir, ODB_FILES) {
ODB_PWD_FILES += $$PWD/$${dir}
}
odb.name = odb ${QMAKE_FILE_IN}
odb.input = ODB_PWD_FILES
odb.output = ${QMAKE_FILE_BASE}-odb.cxx
odb.commands = odb $$ODB_FLAGS ${QMAKE_FILE_IN}
odb.depends = $$ODB_PWD_FILES
odb.variable_out = SOURCES
odb.clean = ${QMAKE_FILE_BASE}-odb.cxx ${QMAKE_FILE_BASE}-odb.hxx ${QMAKE_FILE_BASE}-odb.ixx ${QMAKE_FILE_BASE}.sql
QMAKE_EXTRA_COMPILERS += odb
odbh.name = odb ${QMAKE_FILE_IN}
odbh.input = ODB_PWD_FILES
odbh.output = ${QMAKE_FILE_BASE}-odb.hxx
odbh.commands = @true
odbh.CONFIG = no_link
odbh.depends = ${QMAKE_FILE_BASE}-odb.cxx
QMAKE_EXTRA_COMPILERS += odbh
我想,qt 很难找到 odb。我在 qt 的 info.plist 和 launchctl 中包含了 odb 的路径,但没有帮助。