Mac gcc non-virtual thunk error?

You are going to learn how to never get slapped by Google, and how to always demolish your competition with higher placement and lower click prices. Seriously...we're not kidding here. Get it now!

Found this posting from Matt, presumably someone at Apple: lists.apple.com/archives/unix-porting/20....

Up vote 0 down vote favorite 1 share g+ share fb share tw.

I'm getting these non-virtual thunk errors only in the Deployment build of my app. It uses a private framework called Lgi. Building on 10.5.8 using XCode 3.1.4 (latest for leopard?

) The error looks like this: 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.... Anyway I know I'm not leaving those undefined because it does in fact link and run fine in the development build. Now after googling the issue the first thing to try is changing the optimization setting, which I did... and no dice. Some link error.

So these virtual functions are initially defined in GDragDropTarget, and GWindow's inheritance looks like this: class LgiClass GWindow : public GView #ifndef WIN32 , public GDragDropTarget #endif (LgiClass being for __declspec export/import on win32) Any ideas on what to try next? Btw this is some example flags for the framework: 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 And this is the compile/link flags for the application: 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 I'm not sure whats relevant so I posted them all.

Osx gcc linker thunk link|improve this question edited 2.00 at 7:27 asked 2.00 at 9:37fret394214 83% accept rate.

– ergosys Apr 24 '10 at 3:10 I've added all the flags to the question. – fret Apr 25 '10 at 7:28.

Found this posting from Matt, presumably someone at Apple: lists.apple.com/archives/unix-porting/20... In it, Matt says: A non-virtual thunk is an internal implementation detail used for C++ class hierarchies that involve multiple inheritance. You aren't doing anything wrong; this is a compiler bug. We know that we need to fix it.

In the mean time, the best workaround we know of is to use the same optimization level for linking against a library that you used to compile the library. (You might also consider not exporting a C++ interface from a library. We work very hard to make sure that the C and Objective C ABI stays the same from one compiler release to the next, but we make no such promise for C++.

) --Matt So perhaps you are trying to use a C++ library that was compiled by a differently-versioned C++ compiler? The C++ ABI is not defined as portable it seems. Reid.

Then you can look this flag up in the gcc manual and dig deeper.

Turns out the ultimately the _DEBUG define was making the error occur. But I used your comment as a method for isolating the issue. Thx – fret Apr 27 '10 at 6:18.

I've made a tiny example framework and app that follow all the same patterns/class heirarchies that I use in my main app, with a view towards making a simple example of the problem. But that compiled and linked. I couldn't be sure whether that was because I'd cut too much code from it, or because by recreating the project files in the current version of XCode had fixed the problem.

So try and isolate which of those cases was true I re-created my entire framework project from scratch (fast forward some hours) and THAT builds in "Release" (not deployment) mode and links with my app with NO ERRORS! Huh? Ooooooooooooook.

That means that the original project file is broken in some way that isn't easily visible in the options. I diff'd all the options against a newly created project and it's pretty 1:1. Nothing obviously different.

So it's something NOT visible in the options file. One problem I did have is not noticing that the project options are actually different to the target options. Now that I know to look in both places I can see where some "user defined" options are getting in the way.

The old project file has been through several OS upgrades and numerous XCode upgrades... I guess it's possible some of the upgrades have conflicted and messed up the project. So thanks for reading and for your comments. Update: Well after getting "Release" mode to compile, guess what?

Yup Debug DOESN'T compile. ARRRRGGGGGGGHHHHH! So I've copied over all the settings for the framework so that the Debug build is exactly the same as the Release build for both Target and Project.

That doesn't link. Work continues... Turns out that the last difference between the Release and Debug builds of the App, is that I'm defining "_DEBUG" for the debug build. Which switches on various things like asserts and some extra debugging API's.

Now I have to work out which of those is causing the link error.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions