2

zxing iphone プロジェクトをビルドし、cppunit-1.12.1 で作成されたテスト スイートを実行しようとしています。プロジェクト内に cppunit-1.12.1 コードをコピーし、アクティブな SDK を 10.5 に変更すると、cppunit および zxingcore ターゲットをビルドできますが、zxingcore-tests ターゲットをビルドしようとすると、次のエラーが発生します。これは vtables に関連しているようで、ライブラリのアーキテクチャ タイプに関係する奇妙な警告が表示されます。

基本的に、すべての行の前に > を挿入することなくフォーマットをエスケープすることにより、これをフォーマットする良い方法はありますか? <pre>プレビューではうまく機能するタグを使用しましたが、最終的なレンダリングでは機能しませんでした。フォーマットを尊重せず、テキストを切り取っていませんでした。誰かから提案があり次第、フォーマットを変更します。


Ld build/Debug/zxingcore-tests normal i386
cd /Users/andres/src/zxing/iphone
setenv MACOSX_DEPLOYMENT_TARGET 10.5
/Developer/usr/bin/g++-4.2 -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk -L/Users/andres/src/zxing/iphone/build/Debug -F/Users/andres/src/zxing/iphone/build/Debug -filelist /Users/andres/src/zxing/iphone/build/ZXing.build/Debug/zxingcore-tests.build/Objects-normal/i386/zxingcore-tests.LinkFileList -mmacosx-version-min=10.5 -lzxingcore -lCppUnit -o /Users/andres/src/zxing/iphone/build/Debug/zxingcore-tests

ld: warning: in /Developer/SDKs/MacOSX10.5.sdk/usr/local/lib/libCppUnit.dylib, file is not of required architecture
ld: warning: common::Counted::Counted()has different visibility (default) in /Users/andres/src/zxing/iphone/build/Debug/libzxingcore.a(GF256.o) and (hidden) in /Users/andres/src/zxing/iphone/build/ZXing.build/Debug/zxingcore-tests.build/Objects-normal/i386/BitSourceTest.o
ld: warning: common::Counted::retain()    has different visibility (default) in /Users/andres/src/zxing/iphone/build/Debug/libzxingcore.a(GF256.o) and (hidden) in /Users/andres/src/zxing/iphone/build/ZXing.build/Debug/zxingcore-tests.build/Objects-normal/i386/BitSourceTest.o
ld: warning: common::ArrayRef::~ArrayRef()has different visibility (default) in /Users/andres/src/zxing/iphone/build/Debug/libzxingcore.a(GF256.o) and (hidden) in /Users/andres/src/zxing/iphone/build/ZXing.build/Debug/zxingcore-tests.build/Objects-normal/i386/ReedSolomonTest.o
ld: warning: std::valarray::operator[](unsigned long)has different visibility (default) in /Users/andres/src/zxing/iphone/build/Debug/libzxingcore.a(GF256.o) and (hidden) in /Users/andres/src/zxing/iphone/build/ZXing.build/Debug/zxingcore-tests.build/Objects-normal/i386/ReedSolomonTest.o
ld: warning: common::ArrayRef::reset(common::Array*)has different visibility (default) in /Users/andres/src/zxing/iphone/build/Debug/libzxingcore.a(GF256.o) and (hidden) in /Users/andres/src/zxing/iphone/build/ZXing.build/Debug/zxingcore-tests.build/Objects-normal/i386/ReedSolomonTest.o
ld: warning: common::ArrayRef::ArrayRef(common::Array*)has different visibility (default) in /Users/andres/src/zxing/iphone/build/Debug/libzxingcore.a(GF256.o) and (hidden) in /Users/andres/src/zxing/iphone/build/ZXing.build/Debug/zxingcore-tests.build/Objects-normal/i386/ReedSolomonTest.o
ld: warning: common::ArrayRef::ArrayRef(common::ArrayRef const&)has different visibility (default) in /Users/andres/src/zxing/iphone/build/Debug/libzxingcore.a(GF256.o) and (hidden) in /Users/andres/src/zxing/iphone/build/ZXing.build/Debug/zxingcore-tests.build/Objects-normal/i386/ReedSolomonTest.o

....many more of these warnings...

そして今、エラー


Undefined symbols:
  "vtable for CppUnit::TestSuiteBuilderContextBase", referenced from:
      __ZTVN7CppUnit27TestSuiteBuilderContextBaseE$non_lazy_ptr in BitArrayTest.o
      __ZTVN7CppUnit27TestSuiteBuilderContextBaseE$non_lazy_ptr in BitMatrixTest.o
      __ZTVN7CppUnit27TestSuiteBuilderContextBaseE$non_lazy_ptr in BitSourceTest.o
      __ZTVN7CppUnit27TestSuiteBuilderContextBaseE$non_lazy_ptr in BlackPointEstimatorTest.o
      __ZTVN7CppUnit27TestSuiteBuilderContextBaseE$non_lazy_ptr in PerspectiveTransformTest.o
      __ZTVN7CppUnit27TestSuiteBuilderContextBaseE$non_lazy_ptr in ReedSolomonTest.o
      __ZTVN7CppUnit27TestSuiteBuilderContextBaseE$non_lazy_ptr in DataMaskTest.o
      __ZTVN7CppUnit27TestSuiteBuilderContextBaseE$non_lazy_ptr in ErrorCorrectionLevelTest.o
      __ZTVN7CppUnit27TestSuiteBuilderContextBaseE$non_lazy_ptr in FormatInformationTest.o
      __ZTVN7CppUnit27TestSuiteBuilderContextBaseE$non_lazy_ptr in ModeTest.o
      __ZTVN7CppUnit27TestSuiteBuilderContextBaseE$non_lazy_ptr in VersionTest.o
  "CppUnit::TestLeaf::doGetChildTestAt(int) const", referenced from:
      vtable for CppUnit::TestCaller in BitArrayTest.o
      vtable for CppUnit::TestCaller in BitMatrixTest.o
      vtable for CppUnit::TestCaller in BitSourceTest.o
      vtable for CppUnit::TestCaller in BlackPointEstimatorTest.o
      vtable for CppUnit::TestCaller in PerspectiveTransformTest.o
      vtable for CppUnit::TestCaller  in ReedSolomonTest.o
      vtable for CppUnit::TestCallerin DataMaskTest.o
      vtable for CppUnit::TestCallerin ErrorCorrectionLevelTest.o
      vtable for CppUnit::TestCallerin FormatInformationTest.o
      vtable for CppUnit::TestCallerin ModeTest.o
      vtable for CppUnit::TestCallerin VersionTest.o
  "typeinfo for CppUnit::TestCase", referenced from:
      typeinfo for CppUnit::TestCallerin BitArrayTest.o
      typeinfo for CppUnit::TestCallerin BitMatrixTest.o
      typeinfo for CppUnit::TestCallerin BitSourceTest.o
      typeinfo for CppUnit::TestCallerin BlackPointEstimatorTest.o
      typeinfo for CppUnit::TestCallerin PerspectiveTransformTest.o
      typeinfo for CppUnit::TestCallerin ReedSolomonTest.o
      typeinfo for CppUnit::TestCallerin DataMaskTest.o
      typeinfo for CppUnit::TestCallerin ErrorCorrectionLevelTest.o
      typeinfo for CppUnit::TestCallerin FormatInformationTest.o
      typeinfo for CppUnit::TestCallerin ModeTest.o
      typeinfo for CppUnit::TestCallerin VersionTest.o
  "CppUnit::TestLeaf::countTestCases() const", referenced from:
      vtable for CppUnit::TestCaller in BitArrayTest.o
      vtable for CppUnit::TestCaller in BitMatrixTest.o
      vtable for CppUnit::TestCaller in BitSourceTest.o
      vtable for CppUnit::TestCaller in BlackPointEstimatorTest.o
      vtable for CppUnit::TestCaller in 
`... lots of these errors ... `
CppUnit::assertEquals(qrcode::decoder::FormatInformation const&, qrcode::decoder::FormatInformation const&, CppUnit::SourceLine, std::basic_string, std::allocator > const&)in FormatInformationTest.o
      void CppUnit::assertEquals(int const&, int const&, CppUnit::SourceLine, std::basic_string, std::allocator > const&)in ModeTest.o
      void CppUnit::assertEquals(qrcode::decoder::Mode* const&, qrcode::decoder::Mode* const&, CppUnit::SourceLine, std::basic_string, std::allocator > const&)in ModeTest.o
      void CppUnit::assertEquals(int const&, int const&, CppUnit::SourceLine, std::basic_string, std::allocator > const&)in VersionTest.o
      void CppUnit::assertEquals(bool const&, bool const&, CppUnit::SourceLine, std::basic_string, std::allocator > const&)in VersionTest.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
 
4

3 に答える 3

3

OK、これが問題だと思うのですが、これについては引用しないでください;)

cppunitコードは、CPPUNIT_APIマクロを使用してまとめます

__declspec(dllexport)

__declspec(dllimport)

Win32でビルドする場合。同等のものは使用しません

__attribute__ ((visibility("default")))

のためにgcc。これは、で可視性属性を使用するプロジェクトにそのコードを含めるgcc場合、特にプロジェクトがgccコマンドラインフラグを使用する場合に問題を引き起こす可能性があります。

-fvisibility=hidden

デフォルトですべてのシンボルをライブラリに対してプライベートにし、次に使用する

__attribute__((visibility("default")))

__declspec(dllexport/import)必要に応じて代わりに。vtableなどのシンボルが、他のすべてのライブラリでパブリックとマークされていても、1つのライブラリで非表示とマークされている場合、明らかに(以下のリンクを参照)、非表示とマークされ、リンカーエラーが発生します。

あなたの場合、最初に表示されるリンカーの警告はzxingcore-tests、デフォルトで非表示のシンボルでビルドされていることを示唆しています(-fビルド時にそのオプションをチェックしてください)が、xzingcoreそれ自体はパブリックになっています。cppunit vtablesのシンボルは、に存在しますがcppunit、でzxingcorezxingcore-tests表示としてマークされてzxingcore-testいるため、非表示になります。

ビルドがシンボルを隠している理由を見つけて、zxingcore-testsそれを防ぐ必要があると思います。

詳細については、gcc wikiの可視性ページ、特に「C ++例外の問題」のセクションを試してください(vtablesにも適用されることを示すあいまいなリンクに関するリンクも参照してください)。私はこのようなものに漠然と精通しています。なぜならdynamic_cast、ライブラリ全体の失敗に噛まれてきたからです。その場合、typeinfoオブジェクトが誤って隠されてしまうことが原因です。

于 2009-09-15T23:00:43.697 に答える
2

問題は、cppunitおよびzxingcoreライブラリがarmv6用に構築されていたのに対し、zxingcore-testsはIntelアーキテクチャ用に構築されていたという事実にあったと思います。zxingcore-testsの構成設定をNATIVE_ARCHに変更した後、正常にコンパイルされているようです。

于 2009-09-17T20:34:20.237 に答える
0

ライブラリを使用しても同様の問題が発生しました。両方のプロジェクトのビルド設定で以下が設定されていることを確認することで、問題を修正できました。

[ターゲット情報] - [ビルド] - [GCC 4.2] - [コード生成] の下:

「Inline Methods Hidden」と「Symbols Hidden by Default」の両方がオフになっていることを確認します。

これは少し大げさなテクニックかもしれませんが、うまくいきます。この問題を解決するためのよりきめ細かい方法を誰かが提案できる場合は、感謝します。

于 2010-07-15T04:06:28.853 に答える