以下のプログラムのビルド実行可能ファイルはPPCツールチェーンを使用しています。PPCのスレッド作成のクラッシュ
ツールチェーンの詳細: のpowerpc-WRS-のlinux-gnuの-G ++(ウインドリバーのLinuxのSourcery G ++ 4.4A-341)4.4.1
私たちは、コンパイル時に-pthread含まれており、リンクする-lpthreadています。 -lrtと-ldlフラグも使用しています。あなたは私たちは、ビルドのためのフラグで何かが欠けている提案してくださいすることができ
#include <string>
#include <iostream>
#include <thread>
using namespace std;
// The function we want to execute on the new thread.
void task1(string msg)
{
cout << "task1 says: " << msg;
}
int main()
{
// Constructs the new thread and runs it. Does not block execution.
thread t1(task1, "Hello");
// Makes the main thread wait for the new thread to finish execution
// therefore blocks its own execution.
t1.join();
}
プログラムを実行している間は
Program received signal SIGILL, Illegal instruction.
0x10000e30 in __gnu_cxx::__exchange_and_add(int volatile*, int)()
(gdb) bt
#0 0x10000e30 in __gnu_cxx::__exchange_and_add(int volatile*, int)()
#1 0x10000f14 in __gnu_cxx::__exchange_and_add_dispatch(int*, int)()
#2 0x10001960 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release()()
#3 0x100016ac in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count()()
#4 0x100013ac in std::__shared_ptr<std::thread::_Impl_base, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr()()
#5 0x100013e8 in std::shared_ptr<std::thread::_Impl_base>::~shared_ptr()()
#6 0x100014c0 in std::thread::thread<void (&)(std::basic_string<char, std::char_traits<char>, std::allocator<char> >), char const (&) [6]>(void (&&&)(std::basic_string<char, std::char_traits<char>, std::allocator<char> >), char const (&&&) [6])()
#7 0x10000fd4 in main()
以下のようにクラッシュを取得しています。
メッセージなしでcoutを試しても、同じエラーが表示されます。それは本当の問題ではないようです。 – rajeshkb
g ++ -std = C++ 11 -pthread -o main main.cpp、main.cppはソースファイル名 –
C++ 11のサポートはありません。私たちは、PPCのスレッディングに問題があるように見えました。私たちはブーストで更新し、今は問題ありません。ありがとうございました。 – rajeshkb