#include #include "CFBundle.h" typedef int (* PI_Ptr)(); int main (int argc, char * const argv[]) { for (int i = 1; i< 100000; i++ ) { std::cout << i << std::endl; CFURLRef bundleURL = CFURLCreateWithFileSystemPath(NULL, CFSTR("./bundle.plugin"), kCFURLPOSIXPathStyle, true); CFBundleRef _bundle = CFBundleCreate(kCFAllocatorDefault, bundleURL); CFRelease(bundleURL); PI_Ptr funcAddr = (PI_Ptr)CFBundleGetFunctionPointerForName(_bundle, CFSTR("main")); funcAddr(); CFBundleUnloadExecutable(_bundle); CFRelease(_bundle); } return 0; }