开发者

Objective c library with c interface

开发者 https://www.devze.com 2022-12-10 01:39 出处:网络
I have run into a problem... I\'m trying to use QTKit in an application that we have at work. The only problem with that is the app is written in C++, not Obj-C. I have looked through Apple\'s documen

I have run into a problem... I'm trying to use QTKit in an application that we have at work. The only problem with that is the app is written in C++, not Obj-C. I have looked through Apple's documentation for answers, but I haven't found anything useful.

Basically what I'm looking to do is write a single controller class in Obj-C that has its methods exposed through a C interface to my app. I've written all that code already, but when I try and link it to even a sample C++ app, it finds the Obj-C symbols in the lib and complains about them being there. I thought about hiding the开发者_如何学C symbols using compiler flags, but I saw in Apple's docs that Obj-C isn't affected by that, since classes and messages are bound by the runtime and not the linker.

Has anyone successfully done this?

Thanks, Robbie


You can use QTKit from within your C++ application by using Objective-C++:

Rename the files that access QTKit from .cpp to .mm. This does not change anything in your existing code but you can then use Objective-C from within these files.

0

精彩评论

暂无评论...
验证码 换一张
取 消