1

我为客户做的一些工作要求我在 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 宏,但显然我没有在这里直接使用它。有没有人以前见过这种问题,或者可以提供任何可能的建议作为你为什么会发生这种情况?

4

1 回答 1

1

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

于 2010-09-17T15:11:13.417 回答