在RHE 5.3上使用gcc 3.2.3进行编译

时间:2010-09-07 10:49:14

标签: c++ gcc redhat

我为客户做的一些工作要求我在Red Hat Enterprise上使用非常旧版本的gcc构建。我们最近从4.x转移到5.3,当我尝试构建简单的示例时,我遇到了一些编译错误:

#include <iostream>

int main()
{
    std::cout << "Hello World" << std::endl;

    return 0;
}

我得到以下内容:

bash-3.2$ g++ -o hello hello.cpp
In file included from /opt/ext/gcc-3.2.3.34rh/include/c++/3.2.3/bits/stl_alloc.h:90,
                 from /opt/ext/gcc-3.2.3.34rh/include/c++/3.2.3/memory:55,
                 from /opt/ext/gcc-3.2.3.34rh/include/c++/3.2.3/string:48,
                 from /opt/ext/gcc-3.2.3.34rh/include/c++/3.2.3/bits/localefwd.h:49,
                 from /opt/ext/gcc-3.2.3.34rh/include/c++/3.2.3/ios:48,
                 from /opt/ext/gcc-3.2.3.34rh/include/c++/3.2.3/ostream:45,
                 from /opt/ext/gcc-3.2.3.34rh/include/c++/3.2.3/iostream:45,
                 from hello.cpp:1:
/opt/ext/gcc-3.2.3.34rh/include/c++/3.2.3/bits/stl_threads.h: In 
   constructor `std::_Refcount_Base::_Refcount_Base(unsigned int)':
/opt/ext/gcc-3.2.3.34rh/include/c++/3.2.3/bits/stl_threads.h:74: error: `
   __LOCK_INITIALIZER' undeclared (first use this function)
/opt/ext/gcc-3.2.3.34rh/include/c++/3.2.3/bits/stl_threads.h:74: error: (Each
   undeclared identifier is reported only once for each function it appears 
   in.)

__LOCK_INITIALIZER是一个pthreads宏,但显然我不是直接在这里使用它。有没有人见过这种问题,或者可以提供任何可能的建议,为什么会发生这种情况?

1 个答案:

答案 0 :(得分:1)

你的LD_LIBRARY_PATH设置为什么?特别是gcc依赖于libgcc *和libstdc ++ *(尽管如果你静态地链接它应该不是问题)。如果是一个问题,请尝试将LD_LIBRARY_PATH设置为/opt/ext/gcc-3.2.3.34rh/lib:$LD_LIBRARY_PATH。