Re: Symbol Not Fouund
Re: Symbol Not Fouund
- Subject: Re: Symbol Not Fouund
- From: Jean-Daniel Dupas <email@hidden>
- Date: Sun, 20 Nov 2011 11:35:17 +0100
When compiling C code, the symbol name mangling is as simple as prefixing the function name with a single underscore.
When compiling C++ code, the name mangling is a very complex transformation that have to take account of namespace, arguments type, and all other C++ specific tricks.
When you compile you library as obj-c, is generate symbols using the C mangling (as you can see using nm), but then when you compile a C++ file that try to call one of your function, it uses the C++ name mangling.
If you have a look at system headers in /usr/include, you can see that they uses the __BEGIN_DECLS/__END_DECLS which create an extern "C" block in C++.
And for frameworks' functions, they are usually declared using macros like FOUNDATION_EXPORT, which is expanded to extern "C" in C++.
Le 20 nov. 2011 à 02:52, koko a écrit :
> what I did was compile the library as objc++ (had to clean up lots of type mismatch) but it worked and verified my suspicions
>
> so you say if I put the C funs in extern C declarations that would have solved the problem as well … is that because C funcs are not name mangled?
>
> -koko
>
> On Nov 19, 2011, at 5:59 PM, Jean-Daniel Dupas wrote:
>
>> Make sure your C functions are declared as extern "C" or inside an extern "C" block in headers includes from C++ files.
>>
>> Le 20 nov. 2011 à 00:31, koko a écrit :
>>
>>> Additional information and a question
>>>
>>> THe library contains .h and .m files and is compile sources is according to file type.
>>>
>>> The project it is linked to is a mix of .m and .cpp so is compiled as Objective-C++.
>>>
>>> The symbol being asked for is in a .m file … just wondering is there is any name mangling issue.
>>>
>>> -koko
>>>
>>>
>>>
>>>
>>> On Nov 19, 2011, at 3:59 PM, koko wrote:
>>>
>>>> I have built a BSD Static Library. The setting "Symbols Hidden By Default" is not enabled. running nm on the library I can see the symbols.
>>>>
>>>> I add the library to my project and verify that it is in the Link Binary with Libraries list for the target.
>>>>
>>>> When I build my project it fails on the Link with Symbol(s) not Found and list the symbol tahst I can see when I run nm on the library.
>>>>
>>>> Please point me to something that I can use to see why this symbol is not found.
>>>>
>>>> BTW, I link project with 8 other BSD Static libs that I have built with no issues … that is why this is so puzzling to me.
>>>>
>>>> Thanks …
>>>>
>>>> -koko _______________________________________________
>>>> 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
>>>>
>>>
>>> _______________________________________________
>>> 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
>>
>> -- Jean-Daniel
>>
>>
>>
>>
>>
>
-- Jean-Daniel
_______________________________________________
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