• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Link error using C dylib from C++ dylib
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Link error using C dylib from C++ dylib


  • Subject: Re: Link error using C dylib from C++ dylib
  • From: Jonathan Prescott <email@hidden>
  • Date: Thu, 18 Sep 2008 12:04:49 -0400

Daniel:

I think the code should look like:

extern "C" {
#include "csource.h"
}

The include directive needs to be on a separate line so that the C/C++ pre-processor can expand the header file before it gets presented to the compiler. If you keep what you wrote on 1 line (extern "C" { #include "csource.h" }), the include directive gets missed by the pre-processor.

Jonathan

On Sep 18, 2008, at 10:00 AM, Daniel Luis dos Santos wrote:

Hello,

I have an xcode project with one C source file and header file. These are built into a BSD dylib.
Have another xcode project with a Cpp source file and header file. I include the C source in the Cpp file in which one of the class's methods I call the C function. The C header file inclusion is surrounded by a extern "C" { #include "csource.h" }. I then drag the built dylib from the C project into the link with libraries build phase of the C++ target. The function from the C source is not found by the linker.


Do I have to do anything else to get this to link ?
_______________________________________________
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
References: 
 >Link error using C dylib from C++ dylib (From: Daniel Luis dos Santos <email@hidden>)

  • Prev by Date: Re: How do I view the retain count in Xcode's debug window?
  • Next by Date: Re: Link error using C dylib from C++ dylib
  • Previous by thread: Link error using C dylib from C++ dylib
  • Next by thread: Re: Link error using C dylib from C++ dylib
  • Index(es):
    • Date
    • Thread