如何调试occi使用Clion?

时间:2014-12-25 04:03:24

标签: c++ occi clion

我使用Clion制作一个occi应用程序。我的cmakelist.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文件使用此命令&#34; g ++ main.cpp -o main.o -locci -lclntsh&#34;,构建成功并运行成功。然后我使用Clion调试程序。程序崩溃在这一行程序Environment* env = Environment::createEnvironment();我的cmakelist.txt中有些错误吗?如何解决?

1 个答案:

答案 0 :(得分:1)

是的,我解决了!从oracle网站下载oracle Instant Client zip包:http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html,then解压缩包,将libociei.so移至/opt/oracle/product/11.2.0/dbhome_1/lib/并添加/opt/oracle/product/11.2.0/dbhome_1/lib/libociei.so to MakeList.txt.Build项目并快乐调试。