我正在Windows 10中使用NetBeans IDE 8.2(用于C / C +++)开发C ++应用程序(此应用程序的名称为 SGBD Rasore ),为此,我需要访问开发的数据库与Oracle 11g并由SQL Developer管理。为了简化工作,我想使用SQLAPI +++(http://www.sqlapi.com/)。我从http://www.sqlapi.com/Download/sqlapi_trial.exe下载了该库,并对其进行了解压缩(位于桌面上名为BD的文件夹中)。
在我的NetBeans项目中,我完成了以下操作:
Properties=>Build=>C++ Compiler=>Include Directories
,我已经在此处写过../../../Desktop/BD/SQLAPI/include
(标题为.h的位置)
Properties=>Build=>Linker=>Libraries
,我从SQLAPI/MinGW-5.1.0-tdm64/lib
Properties=>Build=>Linker=>Additional Library Directories
,我已经在那儿写过../../../Desktop/BD/SQLAPI/MinGW-5.1.0-tdm64/lib
编写#include <SQLAPI.h>
时没有语法错误,也没有问题,但是,当我尝试执行从http://www.sqlapi.com/Examples/step1.cpp复制的下一个示例代码时:
#include <iostream>
#include <SQLAPI.h>
using namespace std;
int main() {
SAConnection con; // create connection object
cout << "Empieza el intento\n";
try
{
// connect to database
// in this example it is Oracle,
// but can also be Sybase, Informix, DB2
// SQLServer, InterBase, SQLBase and ODBC
con.Connect(
"pruebaRAUCM", // database name
"carmor06", // user name
"1234", // password
SA_Oracle_Client);
cout << "We are connected!\n";
// Disconnect is optional
// autodisconnect will ocur in destructor if needed
con.Disconnect();
cout << "We are disconnected!\n";
}
catch (SAException &x)
{
// SAConnection::Rollback()
// can also throw an exception
// (if a network error for example),
// we will be ready
try
{
// on error rollback changes
con.Rollback();
}
catch (SAException &)
{
}
// print error message
cout << "%s\n" << (const char*)x.ErrText();
}
return 0;
}
我收到此错误消息:
cd 'C:\Users\user\Documents\NetBeansProjects\SGBD Rasore'
C:\MinGW\msys\1.0\bin\make.exe -f Makefile CONF=Debug
"/C/MinGW/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make.exe[1]: Entering directory `/c/Users/user/Documents/NetBeansProjects/SGBD Rasore'
"/C/MinGW/msys/1.0/bin/make.exe" -f nbproject/Makefile-Debug.mk dist/Debug/MinGW-Windows/sgbd_rasore.exe
make.exe[2]: Entering directory `/c/Users/user/Documents/NetBeansProjects/SGBD Rasore'
mkdir -p dist/Debug/MinGW-Windows
g++ -o dist/Debug/MinGW-Windows/sgbd_rasore build/Debug/MinGW-Windows/main.o -L../../../Desktop/BD/SQLAPI/MinGW-5.1.0-tdm64/lib -lsqlapi
build/Debug/MinGW-Windows/main.o: In function `main':
C:\Users\user\Documents\NetBeansProjects\SGBD Rasore/main.cpp:7: undefined reference to `SAConnection::SAConnection()'
C:\Users\user\Documents\NetBeansProjects\SGBD Rasore/main.cpp:15: undefined reference to `SAString::SAString(char const*)'
C:\Users\user\Documents\NetBeansProjects\SGBD Rasore/main.cpp:15: undefined reference to `SAString::SAString(char const*)'
C:\Users\user\Documents\NetBeansProjects\SGBD Rasore/main.cpp:15: undefined reference to `SAString::SAString(char const*)'
C:\Users\user\Documents\NetBeansProjects\SGBD Rasore/main.cpp:19: undefined reference to `SAConnection::Connect(SAString const&, SAString const&, SAString const&, eSAClient, void ( cdecl*)(SAConnection&, eSAConnectionHandlerType))'
C:\Users\user\Documents\NetBeansProjects\SGBD Rasore/main.cpp:15: undefined reference to `SAString::~SAString()'
C:\Users\user\Documents\NetBeansProjects\SGBD Rasore/main.cpp:15: undefined reference to `SAString::~SAString()'
C:\Users\user\Documents\NetBeansProjects\SGBD Rasore/main.cpp:15: undefined reference to `SAString::~SAString()'
C:\Users\user\Documents\NetBeansProjects\SGBD Rasore/main.cpp:25: undefined reference to `SAConnection::Disconnect()'
C:\Users\user\Documents\NetBeansProjects\SGBD Rasore/main.cpp:7: undefined reference to `SAConnection::~SAConnection()'
C:\Users\user\Documents\NetBeansProjects\SGBD Rasore/main.cpp:15: undefined reference to `SAString::~SAString()'
C:\Users\user\Documents\NetBeansProjects\SGBD Rasore/main.cpp:15: undefined reference to `SAString::~SAString()'
C:\Users\user\Documents\NetBeansProjects\SGBD Rasore/main.cpp:15: undefined reference to `SAString::~SAString()'
C:\Users\user\Documents\NetBeansProjects\SGBD Rasore/main.cpp:38: undefined reference to `SAConnection::Rollback()'
C:\Users\user\Documents\NetBeansProjects\SGBD Rasore/main.cpp:44: undefined reference to `SAException::ErrText() const'
C:\Users\user\Documents\NetBeansProjects\SGBD Rasore/main.cpp:44: undefined reference to `SAString::operator char const*() const'
C:\Users\user\Documents\NetBeansProjects\SGBD Rasore/main.cpp:44: undefined reference to `SAString::~SAString()'
C:\Users\user\Documents\NetBeansProjects\SGBD Rasore/main.cpp:44: undefined reference to `SAString::~SAString()'
C:\Users\user\Documents\NetBeansProjects\SGBD Rasore/main.cpp:7: undefined reference to `SAConnection::~SAConnection()'
collect2.exe: error: ld returned 1 exit status
make.exe[2]: *** [dist/Debug/MinGW-Windows/sgbd_rasore.exe] Error 1
make.exe[2]: Leaving directory `/c/Users/user/Documents/NetBeansProjects/SGBD Rasore'
make.exe[1]: *** [.build-conf] Error 2
make.exe[1]: Leaving directory `/c/Users/user/Documents/NetBeansProjects/SGBD Rasore'
make.exe": *** [.build-impl] Error 2
BUILD FAILED (exit value 2, total time: 1s)
我应该怎么做才能解决此错误并能够运行该程序?有人可以一步一步向我解释吗?
预先感谢