如何使用C++;在Linux上?为C+;使用对象接口时获取编译器错误+; 我使用IBM提供的C++对象接口编写了下面的代码。我正在尝试在RHEL(Linux)上编译它:

如何使用C++;在Linux上?为C+;使用对象接口时获取编译器错误+; 我使用IBM提供的C++对象接口编写了下面的代码。我正在尝试在RHEL(Linux)上编译它:,c++,linux,informix,C++,Linux,Informix,我得到的错误如下所示: /tmp/cchJkPb1.o: In function `main': test1.cpp:(.text+0x82): undefined reference to `ITString::ITString(char const*)' test1.cpp:(.text+0x90): undefined reference to `ITString::ITString(char const*)' test1.cpp:(.text+0x9e): undefined refer

我得到的错误如下所示:

/tmp/cchJkPb1.o: In function `main':
test1.cpp:(.text+0x82): undefined reference to `ITString::ITString(char const*)'
test1.cpp:(.text+0x90): undefined reference to `ITString::ITString(char const*)'
test1.cpp:(.text+0x9e): undefined reference to `ITString::ITString(char const*)'
test1.cpp:(.text+0xac): undefined reference to `ITString::ITString(char const*)'
test1.cpp:(.text+0xc8): undefined reference to `ITDBInfo::ITDBInfo(ITString const&, ITString const&, ITString const&, ITString const&)'
test1.cpp:(.text+0xd1): undefined reference to `ITString::~ITString()'
test1.cpp:(.text+0xea): undefined reference to `ITString::~ITString()'
test1.cpp:(.text+0xfc): undefined reference to `ITString::~ITString()'
test1.cpp:(.text+0x115): undefined reference to `ITString::~ITString()'
test1.cpp:(.text+0x127): undefined reference to `ITString::~ITString()'
/tmp/cchJkPb1.o:test1.cpp:(.text+0x140): more undefined references to `ITString::~ITString()' follow
/tmp/cchJkPb1.o: In function `main':
test1.cpp:(.text+0x15f): undefined reference to `ITConnection::ITConnection(ITDBInfo const&)'
test1.cpp:(.text+0x178): undefined reference to `ITString::~ITString()'
test1.cpp:(.text+0x194): undefined reference to `ITConnection::Open()'
test1.cpp:(.text+0x19d): undefined reference to `ITErrorManager::Error() const'
test1.cpp:(.text+0x1e6): undefined reference to `ITQuery::ITQuery(ITConnection const&)'
test1.cpp:(.text+0x1f4): undefined reference to `ITString::ITString(char const*)'
test1.cpp:(.text+0x209): undefined reference to `ITQuery::ExecOneRow(ITString const&, ITEssential**)'
test1.cpp:(.text+0x222): undefined reference to `ITString::~ITString()'
test1.cpp:(.text+0x23b): undefined reference to `ITString::~ITString()'
test1.cpp:(.text+0x2a6): undefined reference to `operator<<(std::basic_ostream<char, std::char_traits<char> >&, ITString const&)'
test1.cpp:(.text+0x2c4): undefined reference to `ITQuery::NextRow(ITEssential**)'
test1.cpp:(.text+0x2f1): undefined reference to `ITConnection::Close()'
test1.cpp:(.text+0x317): undefined reference to `ITQuery::~ITQuery()'
test1.cpp:(.text+0x32c): undefined reference to `ITQuery::~ITQuery()'
test1.cpp:(.text+0x366): undefined reference to `ITConnection::~ITConnection()'
test1.cpp:(.text+0x378): undefined reference to `ITConnection::~ITConnection()'
test1.cpp:(.text+0x3b2): undefined reference to `ITDBInfo::~ITDBInfo()'
test1.cpp:(.text+0x3ce): undefined reference to `ITDBInfo::~ITDBInfo()'
collect2: ld returned 1 exit status
/tmp/cchJkPb1.o:在函数“main”中:
test1.cpp:(.text+0x82):对“ITString::ITString(char const*)”的未定义引用
test1.cpp:(.text+0x90):对“ITString::ITString(char const*)”的未定义引用
test1.cpp:(.text+0x9e):对“ITString::ITString(char const*)”的未定义引用
test1.cpp:(.text+0xac):对“ITString::ITString(char const*)”的未定义引用
test1.cpp:(.text+0xc8):未定义对“ITDBInfo::ITDBInfo(ITString const&,ITString const&,ITString const&,ITString const&)”的引用
test1.cpp:(.text+0xd1):未定义对“ITString::~ITString()”的引用
test1.cpp:(.text+0xea):未定义对“ITString::~ITString()”的引用
test1.cpp:(.text+0xfc):未定义对“ITString::~ITString()”的引用
test1.cpp:(.text+0x115):未定义对“ITString::~ITString()”的引用
test1.cpp:(.text+0x127):未定义对“ITString::~ITString()”的引用
/tmp/cchJkPb1.o:test1.cpp:(.text+0x140):下面是对“ITString::~ITString()”的更多未定义引用
/tmp/cchJkPb1.o:在函数“main”中:
test1.cpp:(.text+0x15f):对“ITConnection::ITConnection(ITDBInfo const&)”的未定义引用
test1.cpp:(.text+0x178):未定义对“ITString::~ITString()”的引用
test1.cpp:(.text+0x194):对“ITConnection::Open()”的未定义引用
test1.cpp:(.text+0x19d):对“iterrormager::Error()const”的未定义引用
test1.cpp:(.text+0x1e6):对“ITQuery::ITQuery(ITConnection const&)”的未定义引用
test1.cpp:(.text+0x1f4):对“ITString::ITString(char const*)”的未定义引用
test1.cpp:(.text+0x209):对“ITQuery::ExecuteRow(ITString常量和ITEssential**)”的未定义引用
test1.cpp:(.text+0x222):未定义对“ITString::~ITString()”的引用
test1.cpp:(.text+0x23b):未定义对“ITString::~ITString()”的引用

test1.cpp:(.text+0x2a6):对`operator的未定义引用实际上没有使用
-l
命令行参数与库链接。
-L
命令行参数告诉链接器在何处查找它,但不指定实际的库


运行时也会使用
LD\u LIBRARY\u PATH
,但配置非标准目录的更好方法是使用
/etc/LD.so.conf
/etc/LD.so.conf.d/
中的文件配置动态链接器。这些是链接错误,而不是编译错误。不知何故,链接器找不到正确的(或全部?)库。抱歉,bo:)。谢谢你的批改。你看到我的g++命令有什么问题吗?我想我链接的是正确的路径。你没有链接任何东西——你只是指定了大量的搜索路径。你必须用
-l..说出库名。
谢谢。我对linux不是很流利。但这很有帮助。
g++ -Wno-deprecated -I/opt/Informix/11.5FC8/incl/c++ \
    -I/opt/Informix/11.5FC8/incl/public \
    -L/opt/Informix/11.5FC8/lib/c++ -g -o test1 test1.cpp
/tmp/cchJkPb1.o: In function `main':
test1.cpp:(.text+0x82): undefined reference to `ITString::ITString(char const*)'
test1.cpp:(.text+0x90): undefined reference to `ITString::ITString(char const*)'
test1.cpp:(.text+0x9e): undefined reference to `ITString::ITString(char const*)'
test1.cpp:(.text+0xac): undefined reference to `ITString::ITString(char const*)'
test1.cpp:(.text+0xc8): undefined reference to `ITDBInfo::ITDBInfo(ITString const&, ITString const&, ITString const&, ITString const&)'
test1.cpp:(.text+0xd1): undefined reference to `ITString::~ITString()'
test1.cpp:(.text+0xea): undefined reference to `ITString::~ITString()'
test1.cpp:(.text+0xfc): undefined reference to `ITString::~ITString()'
test1.cpp:(.text+0x115): undefined reference to `ITString::~ITString()'
test1.cpp:(.text+0x127): undefined reference to `ITString::~ITString()'
/tmp/cchJkPb1.o:test1.cpp:(.text+0x140): more undefined references to `ITString::~ITString()' follow
/tmp/cchJkPb1.o: In function `main':
test1.cpp:(.text+0x15f): undefined reference to `ITConnection::ITConnection(ITDBInfo const&)'
test1.cpp:(.text+0x178): undefined reference to `ITString::~ITString()'
test1.cpp:(.text+0x194): undefined reference to `ITConnection::Open()'
test1.cpp:(.text+0x19d): undefined reference to `ITErrorManager::Error() const'
test1.cpp:(.text+0x1e6): undefined reference to `ITQuery::ITQuery(ITConnection const&)'
test1.cpp:(.text+0x1f4): undefined reference to `ITString::ITString(char const*)'
test1.cpp:(.text+0x209): undefined reference to `ITQuery::ExecOneRow(ITString const&, ITEssential**)'
test1.cpp:(.text+0x222): undefined reference to `ITString::~ITString()'
test1.cpp:(.text+0x23b): undefined reference to `ITString::~ITString()'
test1.cpp:(.text+0x2a6): undefined reference to `operator<<(std::basic_ostream<char, std::char_traits<char> >&, ITString const&)'
test1.cpp:(.text+0x2c4): undefined reference to `ITQuery::NextRow(ITEssential**)'
test1.cpp:(.text+0x2f1): undefined reference to `ITConnection::Close()'
test1.cpp:(.text+0x317): undefined reference to `ITQuery::~ITQuery()'
test1.cpp:(.text+0x32c): undefined reference to `ITQuery::~ITQuery()'
test1.cpp:(.text+0x366): undefined reference to `ITConnection::~ITConnection()'
test1.cpp:(.text+0x378): undefined reference to `ITConnection::~ITConnection()'
test1.cpp:(.text+0x3b2): undefined reference to `ITDBInfo::~ITDBInfo()'
test1.cpp:(.text+0x3ce): undefined reference to `ITDBInfo::~ITDBInfo()'
collect2: ld returned 1 exit status