2012-04-14 3 views
1

私はsixense(ゲームコントローラのドライバ)から独自のsdkを使用しようとしています。彼らはboost :: threadに静的にリンクしているようです。私のアプリケーションといくつかの依存関係もboost :: threadを使用し、segfaultを取得します。Segfaultはサードパーティのライブラリからの名前の衝突のために

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のブースト::スレッドを呼び出してしまうことがわかりました。

この問題の回避方法はありますか?彼らは静的に後押しするリンクのように見えます

答えて

2

::スレッド

あなたは、彼らが静的にリンクされboost::threadを何も言いませんでした。私はそれらをlibsixense_x64.soにリンクしていると仮定します。

名前の衝突を避けるために、いくつかの一般的な方法があります。

  1. 彼らの行為をクリーンアップするSDKの開発を依頼。何を彼らする必要があります静的にリンクブーストですを非表示その事実、 すべてをにエクスポートするのではなく、-fvisibility = hiddenでコンパイルし、意図したインタフェースのみをエクスポートすることで、
  2. あなたがクリーンアップするSDKの開発者を強制することはできません場合は、結合RTLD_LOCALdlopenを経由して自分のSDKライブラリをロードすることができます。これはsdkを使用するのが少し厄介ですが、そのシンボルをグローバルダイナミックリンカネームスペースから保護する必要があります。
  3. 最後に、完全を期すために:あなたは(あなたのメッセージが示しているが、状態はありません)はLinux上にある場合、あなたは完全に別の動的リンカの名前空間にSDKをロードするためにdlmopenを使用することができます。オプション2と比較して私には利点はありません。いくつかの欠点があります。そうです
+0

は、彼らはすべてをエクスポートしlibsixense_x64.so、にそれをリンクさ。徹底的な答えをありがとう。 – John

関連する問題