1

sixense(ゲームコントローラーのドライバー)のプロプライエタリSDKを使用しようとしています。静的にboost::threadにリンクしているようです。私のアプリケーションとその依存関係の一部もboost::threadを使用しており、セグメンテーション違反が発生します。

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7bd1bb5 in boost::thread::start_thread() () from /usr/lib/libboost_thread.so.1.42.0
(gdb) bt
#0  0x00007ffff7bd1bb5 in boost::thread::start_thread() () from /usr/lib/libboost_thread.so.1.42.0
#1  0x00007ffff79869bb in USBDetector::start_hotplug_thread() ()
   from /home/joschu/Downloads/sixenseSDK_linux_OSX/samples/linux_x64/sixense_simple3d/libsixense_x64.so
#2  0x00007ffff7986c7e in USBDetector::start(std::vector<unsigned int, std::allocator<unsigned int> >, std::vector<std::vector<unsigned int, std::allocator<unsigned int> >, std::allocator<std::vector<unsigned int, std::allocator<unsigned int> > > >, std::vector<unsigned int, std::allocator<unsigned int> >) () from /home/joschu/Downloads/sixenseSDK_linux_OSX/samples/linux_x64/sixense_simple3d/libsixense_x64.so
#3  0x00007ffff7987298 in USBManagerLinux::start(std::vector<unsigned int, std::allocator<unsigned int> >, std::vector<std::vector<unsigned int, std::allocator<unsigned int> >, std::allocator<std::vector<unsigned int, std::allocator<unsigned int> > > >, std::vector<unsigned int, std::allocator<unsigned int> >, int) () from /home/joschu/Downloads/sixenseSDK_linux_OSX/samples/linux_x64/sixense_simple3d/libsixense_x64.so
#4  0x00007ffff79842f3 in USBManager::start(std::vector<unsigned int, std::allocator<unsigned int> >, std::vector<std::vector<unsigned int, std::allocator<unsigned int> >, std::allocator<std::vector<unsigned int, std::allocator<unsigned int> > > >, std::vector<unsigned int, std::allocator<unsigned int> >, int) () from /home/joschu/Downloads/sixenseSDK_linux_OSX/samples/linux_x64/sixense_simple3d/libsixense_x64.so
#5  0x00007ffff79a03d6 in DriverMain::start(int) ()
   from /home/joschu/Downloads/sixenseSDK_linux_OSX/samples/linux_x64/sixense_simple3d/libsixense_x64.so
#6  0x00007ffff79a1e32 in sixenseInit ()
   from /home/joschu/Downloads/sixenseSDK_linux_OSX/samples/linux_x64/sixense_simple3d/libsixense_x64.so
#7  0x0000000000400d0d in main () at /home/joschu/bulletsim/src/hydra/hi.cpp:6

プロジェクトのリンク方法を切り替えると、他のライブラリがsixenseのboost::threadを呼び出すことになります。

この問題を回避する方法はありますか?

4

1 に答える 1

2

Boost::threadに静的にリンクしているようです

あなたは彼らが静的にリンクしているものを言っていませんでしboost::threadた。彼らはそれをにリンクしたと思いますlibsixense_x64.so

名前の衝突を回避する一般的な方法はいくつかあります。

  1. SDK開発者に彼らの行為を片付けるように頼んでください。彼らがすべきことは、静的にリンクブーストし、その事実を隠すことです。たとえば、-fvisibility = hiddenでコンパイルし、すべてをエクスポートするのではなく、目的のインターフェイスのみをエクスポートします(これは彼らが行ったように聞こえます)。
  2. SDK開発者にクリーンアップを強制できない場合は、バインディングを使用dlopenしてSDKライブラリをロードできます。RTLD_LOCALこれにより、SDKの使用が少し厄介になりますが、そのシンボルはグローバルダイナミックリンカー名前空間から保持する必要があります。
  3. 最後に、完全を期すために、Linuxを使用している場合(メッセージが示唆しているが記載されていない場合)、dlmopensdkを完全に別個のダイナミックリンカー名前空間にロードするために使用できます。オプション2と比較して利点は見られず、いくつかの欠点があります。
于 2012-04-14T22:55:49.410 に答える