2

これらの非仮想サンクエラーは、アプリのDeploymentビルドでのみ発生します。Lgiと呼ばれるプライベートフレームワークを使用します。XCode 3.1.4を使用した10.5.8でのビルド(leopardの最新ですか?)エラーは次のようになります。

Ld /Users/matthew/Code/Scribe-Branches/v2.00/build/Development/Scribe.app/Contents/MacOS/Scribe normal i386
    cd /Users/matthew/Code/Scribe-Branches/v2.00
    /Developer/usr/bin/g++-4.0 -arch i386 -L/Users/matthew/Code/Scribe-Branches/v2.00/build/Development -F/Users/matthew/Code/Scribe-Branches/v2.00/build/Development -F/Users/matthew/Code/Lgi/build -F/Users/matthew/Code/Scribe-Branches/v2.00/../../Lgi/build/Development -F/Users/matthew/Code/Scribe-Branches/v2.00/../../Lgi/build/Development -F/Users/matthew/Code/Scribe-Branches/v2.00/../../Lgi/build/Deployment -F/Users/matthew/Code/Scribe-Branches/v2.00/../../Lgi/build/Development -F/Users/matthew/Code/Scribe-Branches/v2.00/../../Lgi/build/Deployment -filelist /Users/matthew/Code/Scribe-Branches/v2.00/build/Scribe.build/Development/Scribe.build/Objects-normal/i386/Scribe.LinkFileList -framework Carbon -framework Lgi -o /Users/matthew/Code/Scribe-Branches/v2.00/build/Development/Scribe.app/Contents/MacOS/Scribe
Undefined symbols:
  "non-virtual thunk to GWindow::OnDrop(char*, GVariant*, GdcPt2, int)", referenced from:
      vtable for ScribeWndin ScribeApp.o
      vtable for GShutdownin ScribeApp.o
      vtable for CalendarUiin Calendar.o
      vtable for CalendarViewWndin CalendarView.o
      vtable for CalendarConfigin CalendarView.o
      vtable for ScribeExportin Exp_Scribe.o
      vtable for GNewMailDlgin GNewMailDlg.o
      ....etc for lots of classes....

とにかく、開発ビルドで実際にリンクして正常に実行されるため、これらを未定義のままにしないことを知っています。問題をグーグルで調べた後、最初に試すことは最適化設定を変更することです。これは私が行ったものです...そしてサイコロはありません。いくつかのリンクエラー。

したがって、これらの仮想関数は最初にGDragDropTargetで定義され、GWindowの継承は次のようになります。

class LgiClass GWindow : public GView
#ifndef WIN32
    , public GDragDropTarget
#endif

(LgiClassはwin32での__declspecエクスポート/インポート用です)

次に何を試すべきかについてのアイデアはありますか?

ところで、これはフレームワークのフラグの例です。

CompileC build/Lgi.build/Deployment/Lgi.build/Objects-normal/i386/GViewCommon.o 
/Users/matthew/Code/Lgi/src/common/Lgi/GViewCommon.cpp normal i386 c++ 
com.apple.compilers.gcc.4_0
cd /Users/matthew/Code/Lgi
/Developer/usr/bin/gcc-4.0 -x c++ -arch i386 -fmessage-length=0 -pipe -Wno-trigraphs 
-fpascal-strings -fasm-blocks -Os -Wreturn-type -Wunused-variable 
-isysroot /Developer/SDKs/MacOSX10.4u.sdk -fvisibility-inlines-hidden 
-mmacosx-version-min=10.4 
-I/Users/matthew/Code/Lgi/build/Lgi.build/Deployment/Lgi.build/Lgi.hmap 
-F/Users/matthew/Code/Lgi/build/Deployment 
-F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks -Iinclude/common 
-Iinclude/mac -Iinclude/posix -I/Users/matthew/Code/Lgi/build/Deployment/include 
-I/Users/matthew/Code/Lgi/build/Lgi.build/Deployment/Lgi.build/DerivedSources/i386 
-I/Users/matthew/Code/Lgi/build/Lgi.build/Deployment/Lgi.build/DerivedSources 
-DMAC 
-include /var/folders/b4/b4LnxwCQGLCmwy36TH3QuU+++TQ/-Caches-/com.apple.Xcode.503/SharedPrecompiledHeaders/Lgi_Prefix-aukthgaeovjxcucuoascfyqekpzz/Lgi_Prefix.pch -c /Users/matthew/Code/Lgi/src/common/Lgi/GViewCommon.cpp 
-o /Users/matthew/Code/Lgi/build/Lgi.build/Deployment/Lgi.build/Objects-normal/i386/GViewCommon.o

Ld /Users/matthew/Code/Lgi/build/Lgi.build/Deployment/Lgi.build/Objects-normal/i386/Lgi normal i386
cd /Users/matthew/Code/Lgi
setenv MACOSX_DEPLOYMENT_TARGET 10.4
/Developer/usr/bin/g++-4.0 -arch i386 -dynamiclib -isysroot /Developer/SDKs/MacOSX10.4u.sdk 
-L/Users/matthew/Code/Lgi/build/Deployment 
-F/Users/matthew/Code/Lgi/build/Deployment 
-F/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks 
-filelist /Users/matthew/Code/Lgi/build/Lgi.build/Deployment/Lgi.build/Objects-normal/i386/Lgi.LinkFileList 
-install_name @executable_path/../Frameworks/Lgi.framework/Versions/A/Lgi 
-mmacosx-version-min=10.4 -framework Carbon 
-framework SystemConfiguration -Wl,-single_module -compatibility_version 1 
-current_version 1 -o /Users/matthew/Code/Lgi/build/Lgi.build/Deployment/Lgi.build/Objects-normal/i386/Lgi

そして、これはアプリケーションのコンパイル/リンクフラグです。

    CompileC build/Scribe.build/Deployment/Scribe.build/Objects-normal/ppc/IHttp.o 
/Users/matthew/Code/Lgi/src/common/INet/IHttp.cpp normal ppc c++ com.apple.compilers.gcc.4_0
cd /Users/matthew/Code/Scribe-Branches/v2.00
/Developer/usr/bin/gcc-4.0 -x c++ -arch ppc -fmessage-length=0 -pipe -Wno-trigraphs 
-fpascal-strings -Os -mdynamic-no-pic -DMAC -DSCRIBE_APP -isysroot /Developer/SDKs/MacOSX10.4u.sdk 
-mtune=G4 -fvisibility=hidden -fvisibility-inlines-hidden -mmacosx-version-min=10.4 
-I/Users/matthew/Code/Scribe-Branches/v2.00/build/Scribe.build/Deployment/Scribe.build/Scribe.hmap 
-F/Users/matthew/Code/Scribe-Branches/v2.00/build/Deployment -F/Users/matthew/Code/Lgi/build 
-F/Users/matthew/Code/Scribe-Branches/v2.00/../../Lgi/build/Development 
-F/Users/matthew/Code/Scribe-Branches/v2.00/../../Lgi/build/Development 
-F/Users/matthew/Code/Scribe-Branches/v2.00/../../Lgi/build/Deployment 
-F/Users/matthew/Code/Scribe-Branches/v2.00/../../Lgi/build/Development 
-F/Users/matthew/Code/Scribe-Branches/v2.00/../../Lgi/build/Deployment 
-F/Users/matthew/Code/Scribe-Branches/v2.00/../../Lgi/build/Development 
-F/Users/matthew/Code/Scribe-Branches/v2.00/../../Lgi/build/Deployment 
-I/Users/matthew/libpng-1.2.37 -I/Users/matthew/jpeg-6b -I../../Lgi/include/common 
-I../../Lgi/include/mac -I../../aspell-0.60.6/interfaces/cc 
-I/Users/matthew/Code/Scribe-Branches/v2.00/build/Deployment/include 
-IResources -I../Lgi/include/common -I../Lgi/include/mac 
-I/Users/matthew/Code/Scribe-Branches/v2.00/build/Scribe.build/Deployment/Scribe.build/DerivedSources/ppc 
-I/Users/matthew/Code/Scribe-Branches/v2.00/build/Scribe.build/Deployment/Scribe.build/DerivedSources 
-DMAC 
-include /var/folders/b4/b4LnxwCQGLCmwy36TH3QuU+++TQ/-Caches-/com.apple.Xcode.503/SharedPrecompiledHeaders/Scribe_Prefix-ebutivbeomfbzzguhklrzxnwuwzc/Scribe_Prefix.pch 
-c /Users/matthew/Code/Lgi/src/common/INet/IHttp.cpp 
-o /Users/matthew/Code/Scribe-Branches/v2.00/build/Scribe.build/Deployment/Scribe.build/Objects-normal/ppc/IHttp.o

Ld /Users/matthew/Code/Scribe-Branches/v2.00/build/Scribe.build/Deployment/Scribe.build/Objects-normal/i386/Scribe 
normal i386
cd /Users/matthew/Code/Scribe-Branches/v2.00
setenv MACOSX_DEPLOYMENT_TARGET 10.4
/Developer/usr/bin/g++-4.0 -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk 
-L/Users/matthew/Code/Scribe-Branches/v2.00/build/Deployment 
-F/Users/matthew/Code/Scribe-Branches/v2.00/build/Deployment 
-F/Users/matthew/Code/Lgi/build 
-F/Users/matthew/Code/Scribe-Branches/v2.00/../../Lgi/build/Development 
-F/Users/matthew/Code/Scribe-Branches/v2.00/../../Lgi/build/Development 
-F/Users/matthew/Code/Scribe-Branches/v2.00/../../Lgi/build/Deployment 
-F/Users/matthew/Code/Scribe-Branches/v2.00/../../Lgi/build/Development 
-F/Users/matthew/Code/Scribe-Branches/v2.00/../../Lgi/build/Deployment 
-F/Users/matthew/Code/Scribe-Branches/v2.00/../../Lgi/build/Development 
-F/Users/matthew/Code/Scribe-Branches/v2.00/../../Lgi/build/Deployment 
-filelist /Users/matthew/Code/Scribe-Branches/v2.00/build/Scribe.build/Deployment/Scribe.build/Objects-normal/i386/Scribe.LinkFileList 
-mmacosx-version-min=10.4 -framework Carbon -framework Lgi 
-o /Users/matthew/Code/Scribe-Branches/v2.00/build/Scribe.build/Deployment/Scribe.build/Objects-normal/i386/Scribe

Undefined symbols:
"non-virtual thunk to GWindow::OnDrop(char*, GVariant*, GdcPt2, int)", referenced from:
    vtable for ScribeWndin ScribeApp.o
    vtable for GShutdownin ScribeApp.o

何が関係しているのかわからないので、全部投稿しました。

4

3 に答える 3

4

おそらくAppleの誰かであるMattからのこの投稿を見つけました:http://lists.apple.com/archives/unix-porting/2003/Dec/msg00107.html

その中で、マットは言います:

[非仮想サンクは]多重継承を含むC++クラス階層に使用される内部実装の詳細です。あなたは何も悪いことをしていません。これはコンパイラのバグです。私たちはそれを修正する必要があることを知っています。それまでの間、私たちが知っている最善の回避策は、ライブラリのコンパイルに使用したライブラリとのリンクに同じ最適化レベルを使用することです。

(ライブラリからC++インターフェイスをエクスポートしないことも検討してください。CとObjectiveCABIがコンパイラのリリース間で同じになるように努めていますが、C ++についてはそのような約束はしていません。)

      --Matt

では、バージョンの異なるC++コンパイラでコンパイルされたC++ライブラリを使用しようとしているのではないでしょうか。C ++ ABIは、移植性があるとは定義されていません。

リード

于 2011-04-01T20:28:36.403 に答える
1

本番ビルドのコンパイラフラグを開発に使用するものに変更してから、問題の原因となるフラグを見つけるまで、現在使用している本番フラグのように徐々に変更してみませんか?

次に、gccマニュアルでこのフラグを調べて、さらに深く掘り下げることができます。

于 2010-04-24T07:46:49.180 に答える
1

問題の簡単な例を作成する目的で、メインアプリで使用するのと同じパターン/クラス階層をすべて従う小さなサンプルフレームワークとアプリを作成しました。しかし、それはコンパイルされ、リンクされています。それがコードを切りすぎたためなのか、現在のバージョンのXCodeでプロジェクトファイルを再作成することによって問題が修正されたためなのかはわかりませんでした。

したがって、これらのケースのどれが正しいかを特定してみてください。フレームワークプロジェクト全体を最初から再作成し(数時間早送り)、それは「リリース」(デプロイではない)モードでビルドされ、エラーなしでアプリにリンクします。は?Ooooooooooooook。

これは、元のプロジェクトファイルが、オプションで簡単に表示されない何らかの方法で壊れていることを意味します。新しく作成されたプロジェクトに対してすべてのオプションを比較しましたが、かなり1:1です。明らかに違いはありません。したがって、オプションファイルには表示されないものです。私が抱えていた問題の1つは、プロジェクトオプションが実際にはターゲットオプションと異なることに気づいていないことです。両方の場所を調べることがわかったので、いくつかの「ユーザー定義」オプションが邪魔になっている場所を確認できます。

古いプロジェクトファイルは、いくつかのOSアップグレードと多数のXCodeアップグレードを経ています...いくつかのアップグレードが競合してプロジェクトを台無しにした可能性があると思います。読んでくれてありがとう、そしてあなたのコメントをありがとう。

更新:コンパイルするために「リリース」モードを取得した後、何を推測しますか?うんデバッグはコンパイルされません。ARRRRGGGGGGGHHHHH !! そのため、フレームワークのすべての設定をコピーして、デバッグビルドがターゲットとプロジェクトの両方のリリースビルドとまったく同じになるようにしました。それはリンクしていません。作業は続きます...

アプリのリリースビルドとデバッグビルドの最後の違いは、デバッグビルドに「_DEBUG」を定義していることです。これは、アサートやいくつかの追加のデバッグAPIなどのさまざまなものをオンにします。次に、リンクエラーの原因を特定する必要があります。

于 2010-04-25T10:51:47.010 に答える