Re: decyphering ld's cryptic error messages
Re: decyphering ld's cryptic error messages
- Subject: Re: decyphering ld's cryptic error messages
- From: Andreas Grosam <email@hidden>
- Date: Wed, 3 Aug 2005 12:20:02 +0200
On 03.08.2005, at 01:26, Stefan Werner wrote:
Hi everyone,
I've spent the last few days reading man pages, FAQs and forums like
crazy, trying to resolve a simple linker error, linking my C++ app
against a static build of wxWidgets:
ld: Undefined symbols:
__ZTV14wxMenuItemList
Most likely, the symbol is just not *accessible* from another dynamic
shared object, because the symbol __ZTV14wxMenuItemList has not been
"exported". Since this is a vtable you need to export the whole class.
The syntax for this is:
class __attribute__ ((visibility("default"))) Foo
{
puplic:
virtual ~Foo();
virtual int foo();
};
If you have a shared lib, and there is the following class hierarchy
defined, which each having polymorphic functions (thus having a vtabl):
A <- B <- C
If you now define another class D in another shared lib, which inherits
from C:
C <- D
you need to ensure, that the classes A, B and C will be "exported".
This is because the linker needs the vtbls from all the three base
classes.
You probably want to define macros for the ugly attribute specifier:
#define EXPORT __attribute__ ((visibility("default")))
#define LOCAL __attribute__ ((visibility("hidden")))
Please see also:
<http://developer.apple.com/releasenotes/DeveloperTools/GCC4.html>
<http://gcc.gnu.org/wiki/Visibility>
Note, for the GCC4 compiler all symbols will be exported by default.
However, in XCode the default build settings for building a shared lib
is that all symbols will be "hidden". So - either you change the
corresponding build settings (not recommeded) or you explicitly define
the visibility attribute in your source code - which i would do.
Regards
Andreas
If you ever get such mangled names from Xcode, you can unmangle them
with 'c++filt' and god knows why Xcode isn't doing the translation
automatically. The translation is:
vtable for wxMenuItemList
Now, a google search pointed me to a FAQ telling me that the linker is
trying to tell me that I probably forgot to implement a virtual
function that wxMenuItemList is supposed to inherit from its
superclass - not telling me what function that would be.
How do I figure out what's missing? I've gone to depths of ld and gcc
I never wanted to go (and would have thought that Xcode should make
that unnecessary) and this is the final step that's missing to
complete the port of a major project from CFM/CW to MachO/Xcode.
Thanks for any help,
Stefan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden