2012-04-14 23 views
1

我正在嘗試使用sixense的專有sdk(驅動程序用於遊戲控制器)。它看起來像靜態鏈接到boost :: thread。我的應用程序和它的一些依賴項也使用boost :: thread,並且我得到了一個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的boost :: thread。

有沒有解決此問題的方法?

回答

2

看起來他們靜態鏈接到提高::線程

你沒有說什麼,他們靜態鏈接到boost::thread。我會假設他們將其鏈接到libsixense_x64.so

有避免名稱衝突幾種常見方法:

  1. 詢問SDK開發者自己的行爲。他們應該所做的是靜態鏈接提升和隱藏這個事實,例如,通過使用-fvisibility = hidden進行編譯,並且只導出他們預期的接口,而不是輸出的一切(這聽起來是他們所做的)。
  2. 如果你不能強迫sdk開發者清理,你可以通過dlopen加載他們的sdk庫,並且使用RTLD_LOCAL進行綁定。這使得使用sdk有點尷尬,但應該從全局動態鏈接器名稱空間保留它的符號。
  3. 最後,爲了完整起見:如果您在Linux上(您的消息建議但未聲明),則可以使用dlmopen將sdk加載到完全獨立的動態鏈接器名稱空間中。與選項2相比,我沒有看到任何優勢,並且存在幾個缺點。
+0

沒錯,他們將它鏈接到libsixense_x64.so,它導出所有內容。感謝徹底的答覆。 – John 2012-04-17 05:20:10