Re: dynamic library linking in x-code
Re: dynamic library linking in x-code
- Subject: Re: dynamic library linking in x-code
- From: "Adam J. Shuttleworth" <email@hidden>
- Date: Tue, 30 Dec 2008 22:34:32 -0600
Adding the extern"C" code worked. Thanks for your help.
Adam
On Dec 30, 2008, at 9:59 PM, Sherm Pendley wrote:
On Dec 30, 2008, at 9:54 PM, Adam J. Shuttleworth wrote:
I am trying to build a command line C++ application in X-Code. I
have a dynamic library that is needed. When I include the library
in my X-code project and build it, I get errors that act like the
library is not there. I include the library by right clicking and
selecting 'add existing files'. In fact if I remove the library I
get the same errors. This all occurs when the source code is
in .cpp files. If I change the .cpp files to .c files (and change
the dynamic memory allocation) I don't get the errors and the code
builds. I am working with intel macs running OSX10.5.5. Any
advice is appreciated.
Sounds like the library is written in C, but the library author
forgot to put an extern linkage specification in the header, to make
it callable from C++. Try this:
extern "C" {
#include "library_header.h"
}
In a perfect world, the library header would already be written like
that, with the appropriate #ifdefs in place to make sure that only C+
+ compilers see the extern linkage:
#ifdef __cplusplus
extern "C" {
#endif
/* lots of stuff */
#ifdef __cplusplus
}
#endif
sherm--
_______________________________________________
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