Please nominate your Qt Champions for 2021!

[SOLVED] Add own method into QOCIDriver

  • Hi all
    I am not familiar with C++ and Qt yet
    I try to add my own function into QOCIDriver
    I add function into qsql_oci.h & qsql_oci.cpp compile dll but
    include qsql_oci.h into my project but still can't use my method
    can anybody say what I forget?
    thank you

  • may be the header that you are using is old one. Or You forgot to export the symbol using Q_DECL_EXPORT. Unlike linux, windows shared library need the symbol to be explicitly exported.

  • thanks for answer
    I do not change header just add my own method

    @class Q_EXPORT_SQLDRIVER_OCI QOCIDriver : public QSqlDriver
    friend struct QOCIResultPrivate;
    friend class QOCIPrivate;
    explicit QOCIDriver(QObject* parent = 0);
    QOCIDriver(OCIEnv* env, OCISvcCtx* ctx, QObject* parent = 0);
    bool hasFeature(DriverFeature f) const;
    bool open(const QString & db,
    const QString & user,
    const QString & password,
    const QString & host,
    int port,
    const QString& connOpts);
    void close();
    QSqlResult *createResult() const;
    QStringList tables(QSql::TableType) const;
    QSqlRecord record(const QString& tablename) const;
    QSqlIndex primaryIndex(const QString& tablename) const;
    QString formatValue(const QSqlField &field,
    bool trimStrings) const;
    QVariant handle() const;
    QString escapeIdentifier(const QString &identifier, IdentifierType) const;
    void * getEnv(); // my function invisible in application that use dll
    bool beginTransaction();
    bool commitTransaction();
    bool rollbackTransaction();

    QOCIDriverPrivate *d;

  • I add method into
    compile and receive fresh dll
    after that I add same method into
    and try to use it in my application

    but receive LNK2019
    error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __thiscall QOCIDriver::breakCurrentSql(void)" (_imp?breakCurrentSql@QOCIDriver@@QAE_NXZ) referenced in function "public: static bool __cdecl PlSqlTools::breakCurrentSql(class QSqlDatabase &,class QString &)" (?breakCurrentSql@PlSqlTools@@SA_NAAVQSqlDatabase@@AAVQString@@@Z)
    1>debug\test1.exe : fatal error LNK1120: 1 unresolved externals

    can any one help me with this issue
    thank you

  • ok I go to another way just implement in QOCIDriver slot
    bool cancelQuery(); described in QSqlDriver and all run ))

Log in to reply