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 に答える