Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

arunan

macrumors newbie
Original poster
Feb 17, 2009
6
0
I have most of the code in C, C++ in my application . I would want to build the GUI and render the video using the QTkit .
Is it possible to build a objective C dynamic library in cocoa using xcode and call them from the C files ? I am using make files to compile the C code .
Please provide me the details as to how to do it if it is possible.A simple example would be of great help as I am new to MAC .
:confused:
 

gnasher729

Suspended
Nov 25, 2005
17,980
5,566
I have most of the code in C, C++ in my application . I would want to build the GUI and render the video using the QTkit .
Is it possible to build a objective C dynamic library in cocoa using xcode and call them from the C files ? I am using make files to compile the C code .
Please provide me the details as to how to do it if it is possible.A simple example would be of great help as I am new to MAC .
:confused:

You can add any C functions you like to a .m file and compile them, then call them as you would call any other C functions.
 

arunan

macrumors newbie
Original poster
Feb 17, 2009
6
0
May be I have n't put my problem clearly !!
I want to build a dynamic library in cocoa that implements the video capture using QTKit and initiate the capture from C code . Would finally compile the application C code using make files .
 

kpua

macrumors 6502
Jul 25, 2006
294
0
You can export C functions from Objective-C files just like you normally would. Here's an example:

MyFunc.m:
Code:
void doSomething() {
    [someObjCObject someMethod];
}

and then in your C file, you use it like this:
Code:
extern void doSomething();

void anotherFunction() {
    doSomething();
}


Both files are compiled separately into object files, after which, the linker doesn't care what language they were written in. The extern'd doSomething() declaration in the C file will be linked to the doSomething() definition in the .m file.
 

arunan

macrumors newbie
Original poster
Feb 17, 2009
6
0
Thanks a lot for all your valuable inputs . I could succesfully compile creating a C wrapper function in a .m file and having the objective code in that.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.