【问题标题】:occi c++ /usr/bin/ld: cannot find -locci collect2: ld returned 1 exit status compaile time error using makefileocci c++ /usr/bin/ld: 找不到 -locci collect2: ld returned 1 exit status 使用 makefile 编译时间错误
【发布时间】:2014-11-30 21:11:55
【问题描述】:

这里我在 centos 操作系统中有 occi c++ 应用程序。当我使用 make 文件编译我的应用程序时,我得到 /usr/bin/ld: cannot find -locci collect2: ld returned 1 exit status 错误。

Employees.cpp 文件还有:-

 #include "Employees.h"
    using namespace std;
    using namespace oracle::occi;

    int main (void)
    {
        Employees *pEmployees = new Employees();
        pEmployees->List();
        delete pEmployees;
        cout << "ENTER to continue...";
        cin.get();
        return 0;
    }

    Employees::Employees()
    {
        user = "sys";
        passwd = "sis123";
        db = "oel01:1521/OEL11GR1.SAND";
        env = Environment::createEnvironment(Environment::DEFAULT);
        try
       {
          con = env->createConnection(user, passwd, db);
       }
       catch (SQLException& ex)
       {
         cout << ex.getMessage();
       }
    }

    Employees::~Employees()
    {
        env->terminateConnection (con);
        Environment::terminateEnvironment (env);
    }

    void Employees::List()
    {
      /*
       * simple test method to select data from
       * the employees table and display the results
       */
        Statement *stmt = NULL;
        ResultSet *rs = NULL;
        string sql = "select employee_id, first_name, last_name " \
                   "from employees order by last_name, first_name";

        try
       {
         stmt = con->createStatement(sql);
       }
       catch (SQLException& ex)
      {
        cout << ex.getMessage();
       }
      if (stmt)
      {
        try
        {
          stmt->setPrefetchRowCount(32);
          rs = stmt->executeQuery();
        }
        catch (SQLException& ex)
        {
          cout << ex.getMessage();
        }
        con->terminateStatement(stmt);
      }
   }

=======================

这里还有Employees.h文件

#include <occi.h>
#include <iostream>
#include <iomanip>
using namespace oracle::occi;
using namespace std;
class Employees {
    public:
    Employees();
    virtual ~Employees();
    void List();
    private:
    Environment *env;
    Connection  *con;
    string user;
    string passwd;
    string db;
};

我的make文件是:-

Employees: Employees.cpp
    g++ -o Employees Employees.cpp \
    -I$(ORACLE_HOME)//usr/include/oracle/11.1/client \
    -L$(ORACLE_HOME) -lclntsh -locci

debug: Employees.cpp
    g++ -ggdb3 -o Employees Employees.cpp \
    -I$(ORACLE_HOME)/usr/include/oracle/11.1/client \
    -L$(ORACLE_HOME) -lclntsh -locci
clean:
    rm -f Employees

centos的/usr/include/oracle/11.1/client目录下已经安装了sqlclient occi库 问题出在制作文件上请帮助我

【问题讨论】:

  • libocci.a/libocci.so 库在哪里?
  • /usr/include/oracle/11.1/client 在这个目录中

标签: c++ oracle makefile centos6 occi


【解决方案1】:

如果 oracle 头文件的路径是 $(ORACLE_HOME)//usr/include/oracle/11.1/client(来自 makefile 中的 -I 参数),那么我发现库的路径不太可能是 $(ORACLE_HOME)(来自 makefile 中的 -L 参数),在我看来,$(ORACLE_HOME)//usr/lib/oracle/11.1/client(或类似的东西)的可能性更大。

【讨论】:

  • 我做到了,但它是一样的吗?
  • @sis 那么这可能不是正确的道路。您需要找到正确的路径并使用它。鉴于您对我的评论的回答,路径似乎是 /usr/include/oracle/11.1/client(虽然这有点奇怪,但也许这就是 oracle 做事的方式)。
  • centos occi 库中你知道的常用路径是什么?
  • 或者我应该再次安装即时客户端,如果你说是的话,请给我一些适当的 centos 安装方式的步骤谢谢
  • @sis 我对甲骨文一无所知。但这个问题不是特定于 Oracle 的。您在非标准位置有一个库,因此您需要告诉编译器/链接器该路径。这就是-L 的用途。获取正确的路径(包含libocci.alibocci.so 文件的路径),它应该可以工作。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-07-31
  • 1970-01-01
  • 1970-01-01
  • 2013-04-08
  • 1970-01-01
  • 1970-01-01
  • 2014-08-17
相关资源
最近更新 更多