Mac gcc非虚拟thunk错误

时间:2010-03-30 09:37:39

标签: macos gcc linker thunk

我只在我的应用程序的部署版本中收到这些非虚拟thunk错误。它使用一个名为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

我不确定相关的是什么,所以我发布了所有内容。

3 个答案:

答案 0 :(得分:4)

发现Matt的这个帖子,可能是Apple的某个人:http://lists.apple.com/archives/unix-porting/2003/Dec/msg00107.html

在其中,马特说:

  

[非虚拟thunk]是内部的   用于C ++的实现细节   涉及的类层次结构   多重继承。你没有做   哪里不对了;这是一个编译器   错误。我们知道我们需要解决它。   同时,最好的解决方法   我们知道的是使用相同的   链接的优化级别   你用来编译的库   库。

     

(您也可以考虑不导出   来自库的C ++接口。我们   努力工作以确保C   和Objective C ABI保持不变   从一个编译器发布到下一个,   但我们对C ++没有这样的承诺。)

      --Matt

所以也许您正在尝试使用由不同版本的C ++编译器编译的C ++库? C ++ ABI似乎没有被定义为可移植的。

里德

答案 1 :(得分:1)

为什么不将生产版本的编译器标志更改为用于开发的编译器标志,然后逐渐将它们更改为看起来像现在使用的生产标志,直到找到导致问题的标志? / p>

然后你可以在gcc手册中查看这个标记并深入挖掘。

答案 2 :(得分:1)

我已经制作了一个很小的示例框架和应用程序,它遵循我在主应用程序中使用的所有相同的模式/类heirarchies,以期制作一个简单的问题示例。但那编译和链接。我无法确定这是因为我从中删除了太多代码,还是因为在当前版本的XCode中重新创建项目文件已经解决了问题。

因此,尝试并分离哪些情况属实,我从头开始重新创建我的整个框架项目(快进几个小时),并在“发布”(非部署)模式下构建并与我的应用程序链接,没有错误!咦? Ooooooooooooook。

这意味着原始项目文件以某种方式被破坏,在选项中不容易看到。我针对新创建的项目区分了所有选项,并且它非常漂亮1:1。没有什么明显的不同。所以这是在选项文件中看不到的东西。我遇到的一个问题是没有注意到项目选项实际上与目标选项不同。现在,我知道要在这两个地方查看,我可以看到一些“用户定义”选项正在阻碍。

旧的项目文件已通过多次操作系统升级和大量的XCode升级......我猜有些升级可能会发生冲突并搞砸了项目。非常感谢阅读和评论。

更新:在获得“发布”模式进行编译后,猜猜是什么? Yup Debug无法编译。 ARRRRGGGGGGGHHHHH!所以我复制了框架的所有设置,以便Debug构建与Target和Project的Release构建完全相同。这没有联系。工作继续......

事实证明,App的Release版本和Debug版本之间的最后一个区别是,我正在为调试版本定义“_DEBUG”。哪些可以切换各种内容,如断言和一些额外的调试API。现在我必须解决其中哪些导致链接错误。