簡體   English   中英

C ++與靜態lib中的std :: string相關的未定義符號

[英]C++ Undefined symbol related to std::string in static lib

我通過在Linux上用C ++將一堆代碼與靜態庫(.a)相鏈接來構建一個共享庫。 我有一個靜態庫中定義的方法。 當我使用nm -C打印符號時,靜態庫顯示為:

 Alembic::AbcCoreFactory::v9::IFactory::getArchive(std::string const&, Alembic::AbcCoreFactory::v9::IFactory::CoreType&)

輸出.so文件(我正在構建的庫)中沒有定義符號,但是當我使用nm -uC列出未定義的符號時,它會打印:

Alembic::AbcCoreFactory::v9::IFactory::getArchive(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, Alembic::AbcCoreFactory::v9::IFactory::CoreType&)

區別在於第一個使用std :: string const&,第二個使用std :: __ 1 :: basic_string,std :: __ 1 :: allocator> const&

我試圖理解為什么它沒有找到符號。 兩者不應該匹配,因為它們基本相同嗎?

對於上下文,我正在嘗試編譯一個Alembic Importer,它隨附了Unreal Editor 4 for linux。 我試圖鏈接的庫是alembic庫。

您正在嘗試鏈接針對libc++ (clang的標准C ++庫)編譯的代碼和針對libstdc++ (gcc的標准C ++庫)編譯的代碼。 這不會太好用。

檢查你的圖書館。

在我的系統上:

> nm -DC /usr/lib64/libc++_shared.so | grep 'std::__1'
  === lots of output ===
> nm -DC /usr/lib64/libc++_shared.so | grep 'std::basic'
  === nothing ===
> nm -DC /usr/lib/gcc/x86_64-pc-linux-gnu/6.2.0/libstdc++.so.6 | grep 'std::__1'
  === nothing ===
> nm -DC /usr/lib/gcc/x86_64-pc-linux-gnu/6.2.0/libstdc++.so.6 | grep 'std::basic'
  === lots of output ===

在您的系統上,文件可能位於不同的位置,但結果應該是相同的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM