realbasic-plugins
[Top] [All Lists]

Re: XCode problems compiling RB plugin

To: REALbasic Plugins <realbasic-plugins at lists dot realsoftware dot com>
Subject: Re: XCode problems compiling RB plugin
From: Alex Fischer <alex at basasoft dot com>
Date: Wed, 11 May 2005 16:38:13 +0200
Delivered-to: realbasic-plugins at lists dot realsoftware dot com
References: <79875693-F568-45E9-8B0F-1E048BA3981E at ohri dot ca> <88503EAE-D445-43E1-88A1-DF0F3F56AB0F at ljug dot com> <A17F5D3F-6EA4-45D4-9AC6-0E1C655BF044 at ohri dot ca> <047ED1DC-1EE5-4EC2-8899-5D00B07E760E at basasoft dot com> <1A4B8DB2-5132-4FE9-8837-D50FF5073F31 at realsoftware dot com>
Thanks Jon!

I have used your first approach and that did the trick. I am glad you told me 'cause I would have never guessed that.

Now I'll continue to fix some errors with missing libraries but that should be easier ;-)

On May 11, 2005, at 14:12 , Jonathan Johnson wrote:


On May 11, 2005, at 5:33 AM, Alex Fischer wrote:


Hi to all:

I have been reading you for a while now and hope you can now help me ;-)

For some time now I have been developing plugins in CodeWarrior and want to go now the way to start doing so in XCode. I have created a basic Mach-O plugin that compiles perfectly and works fine. The problem comes when I try to extend the plugin with more functionality.

I am trying to implement some Cocoa functions. As Apple development says this is possible from Carbon if you write a C callable wrapper function. To do so I have created a "misc.m" file and included the function there. The file seems to compile well. I have also created a "misc.h" file and included the C function definition there. The main plugin code file includes "#include misc.h". The problem is that when I try to call the function I get an linker error saying there is an "unresolved symbol error" giving a cryptic name resembling the one of my wrapper function.

You have probably noticed that I am not very experienced to C programming and there is probably just an error in how I organize and reference the files due to lack in knowledge of that type of programming. I have tried all kinds of solutions but nothing works.

One approach was to include the wrapper function in the main plugin file but that seems not too bee possible as it gives me a lot of errors. Seems a problem of mixing C and Obj-C.

Well I hope I have explained myself and somebody can give me a clue of what I am doing wrong.


Objectice-C is a superset of C, not C++, so the link signatures are those of what C would be. You can fix this in two ways (I prefer the first approach, because Objective-C++ has been a little funky to me :P):

1) Inside of your header, put this at the top:

#ifdef __cplusplus
  extern "C" {
#endif

And this at the bottom:

#ifdef __cplusplus
  }
#endif

This will make the C++ compiler treat functions declared in your header as if they were C functions.

2) Change the extension of your file to .mm. This makes GCC treat your file as Objective-C++ which should solve your problems.

Again, I haven't had much experience with #2, and I generally take approach #1.

HTH,
Jon


--
Jonathan Johnson
REAL Software, Inc.

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>



_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>