开发者

C++ popen() wrapper not working in Objective-C++ for iPhone

So I made a new view based application. Changed every .m file to .mm. Created a new C++ file called: popenWrapper.cpp and copied the code of the "Simple Wrapper" file into the popenWrapper.cpp.

I then edited my Program App Delegate File to:

#include "popenWrapper.cpp"

And I also changed this:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    string command = "ps -e";
    fstream fp;
    popen_cplusplus(command, result);


    self.window.rootViewController = self.viewCo开发者_如何学Gontroller;
    [self.window makeKeyAndVisible];
    return YES;
}

But when I run the program I get:

Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/llvm-g++-4.2 failed with exit code 1

And it also says it's type is an "Apple Mach-O linker (Id) Error".

If i comment all the content in the popenWrapper.cpp and comment the function out, it runs.

If you need more just ask.


Changing "popenWrapper.cpp" to "popenWrapper.h" (and including the .h version of course) fixed the error.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜