我使用Clion来制作occi应用程序。我的清单.txt:
cmake_minimum_required(VERSION 2.8.4)
project(oracle_manager)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp)
add_executable(oracle_manager ${SOURCE_FILES})
INCLUDE_DIRECTORIES(/opt/oracle/product/11.2.0/dbhome_1/rdbms/public)
LINK_DIRECTORIES(/opt/oracle/product/11.2.0/dbhome_1/lib)
SET(REQ_LIB /opt/oracle/product/11.2.0/dbhome_1/lib/libagtsh.so
/opt/oracle/product/11.2.0/dbhome_1/lib/libclntsh.so
/opt/oracle/product/11.2.0/dbhome_1/lib/libocci.so
/opt/oracle/product/11.2.0/dbhome_1/lib/libodm11.so
/opt/oracle/product/11.2.0/dbhome_1/lib/liborasdk.so
/opt/oracle/product/11.2.0/dbhome_1/lib/liborasdkbase.so
/opt/oracle/product/11.2.0/dbhome_1/lib/libsqlplus.so)
TARGET_LINK_LIBRARIES(oracle_manager ${REQ_LIB})
SET(SOURCE_FILES main.cpp)
我的程序:
int main()
{
Environment* env = Environment::createEnvironment();
Connection* con = env->createConnection("user", "password", "server");
Statement* stmt = con->createStatement("select * from tab");
ResultSet* rs = stmt->executeQuery();
stmt->closeResultSet(rs);
con->terminateStatement(stmt);
env->terminateConnection(con);
Environment::terminateEnvironment(env);
cout << 1 << endl;
return 0;
}
我的操作系统是ubuntu 12.04 lts,Oracle数据库的版本是11g。我编译main.cpp文件使用以下命令"g++ main.cpp -o main.o -locci -lclntsh",构建成功并运行成功。然后我使用 Clion 来调试程序。程序在此行程序中崩溃Environment* env = Environment::createEnvironment();
这些在我的 cmakelist 中是否有问题.txt?如何解决?
是的,我修好了!从oracle web station下载oracle Instant Client zip软件包:http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html,然后解压缩软件包,libociei.so
移动到/opt/oracle/product/11.2.0/dbhome_1/lib/
并将/opt/oracle/product/11.2.0/dbhome_1/lib/libociei.so
添加到MakeList.txt.构建项目并快乐调试。