![ビルド ファームで C++ pthread がサポートされていないのですか?](https://rvso.com/image/1466411/%E3%83%93%E3%83%AB%E3%83%89%20%E3%83%95%E3%82%A1%E3%83%BC%E3%83%A0%E3%81%A7%20C%2B%2B%20pthread%20%E3%81%8C%E3%82%B5%E3%83%9D%E3%83%BC%E3%83%88%E3%81%95%E3%82%8C%E3%81%A6%E3%81%84%E3%81%AA%E3%81%84%E3%81%AE%E3%81%A7%E3%81%99%E3%81%8B%3F.png)
ビルド ファームでコードをコンパイルしようとしています。開発マシンでビルドすると、問題なく動作します。
checking if C compiler and POSIX threads work as is... no
checking if C++ compiler and POSIX threads work as is... no
checking if C compiler and POSIX threads work with -Kthread... no
checking if C compiler and POSIX threads work with -kthread... no
checking if C compiler and POSIX threads work with -pthread... yes
checking if C++ compiler and POSIX threads work with -Kthread... no
checking if C++ compiler and POSIX threads work with -kthread... no
checking if C++ compiler and POSIX threads work with -pthread... yes
checking for pthread_mutexattr_setpshared... yes
checking for pthread_condattr_setpshared... yes
checking for PTHREAD_MUTEX_ERRORCHECK_NP... yes
checking for PTHREAD_MUTEX_ERRORCHECK... yes
checking for working POSIX threads package... yes
しかし、ビルド ファームに渡すと、pthread サポートを有効にする機能するコンパイラ オプションが見つかりません。
[ 87s] checking if C compiler and POSIX threads work as is... no
[ 87s] checking if C++ compiler and POSIX threads work as is... no
[ 87s] checking if C compiler and POSIX threads work with -Kthread... no
[ 87s] checking if C compiler and POSIX threads work with -kthread... no
[ 87s] checking if C compiler and POSIX threads work with -pthread... yes
[ 87s] checking if C++ compiler and POSIX threads work with -Kthread... no
[ 87s] checking if C++ compiler and POSIX threads work with -kthread... no
[ 87s] checking if C++ compiler and POSIX threads work with -pthread... no
[ 87s] checking if C++ compiler and POSIX threads work with -pthreads... no
[ 87s] checking if C++ compiler and POSIX threads work with -mt... no
[ 87s] checking if C++ compiler and POSIX threads work with -mthreads... no
[ 87s] checking if C++ compiler and POSIX threads work with -lpthreads... no
[ 87s] checking if C++ compiler and POSIX threads work with -llthread... no
[ 87s] checking if C++ compiler and POSIX threads work with -lpthread... no
[ 87s] checking for pthread_mutexattr_setpshared... yes
[ 87s] checking for pthread_condattr_setpshared... yes
[ 87s] checking for PTHREAD_MUTEX_ERRORCHECK_NP... yes
[ 87s] checking for PTHREAD_MUTEX_ERRORCHECK... yes
[ 87s] checking for working POSIX threads package... no
[ 87s] configure: WARNING: "*** POSIX threads are not"
[ 87s] configure: WARNING: "*** available on your system "
[ 87s] configure: error: "*** Can not continue"
開発ボックスとビルドファームは同じベース OS を使用しています。唯一の違いは、ビルドファームの環境が非常に最小限であり、少数のベース OS パッケージの上に、仕様ファイルで必要なパッケージのみがインストールされることです。
この動作を引き起こす「不足しているパッケージ」は考えられません。 glibc-* は両方にインストールされています。
答え1
実際のクレジット/ソース:https://forums.opensuse.org/showthread.php/509781-No-C-Pthread-support-inside-OBSwolfi323 より
[Open MPI 3] を次のように構成しようとしたときに、同様の問題が発生しました。
./configure CC=gcc CXX=gcc FC=gfortran
wolfi323のforums.opensuseでの回答は、C++コンパイラが適切に指定されていませんc/c++ コンパイラ オプションは空白のままにしました。
./configure FC=gfortran
構成は次のように報告されました:
checking if C++ compiler and POSIX threads work with -Kthread... no
checking if C++ compiler and POSIX threads work with -kthread... no
checking if C++ compiler and POSIX threads work with -pthread... yes
そして完成しました。
余分な
設定
CC=gcc CXX=g++
./configure でデフォルトのコンパイラーを検索した場合と同じ/類似の結果が得られました。