Re: How can I use a .dylib created in Xcode in my gcc-compiled program?
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com On Oct 15, 2007, at 7:06 PM, Milford Brimdash wrote: [dualg5:~/temp] steve$ cat foo.c void foo( int *n ) { *n = 0; } [dualg5:~/temp] steve$ gcc -c foo.c [dualg5:~/temp] steve$ nm foo.o 00000000 T _foo [dualg5:~/temp] steve$ g++ -c foo.c [dualg5:~/temp] steve$ nm foo.o 00000000 T __Z3fooPi 00000000 A __Z3fooPi.eh -- Steve Checkoway _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com Boris Remizov said: Hmmm...> Try to play with extern "C" directive before your func (). Another thing I've noticed...if I compile a .dylib in Xcode with the C compiler, I can call a function from the library in a separate program, but if I recompile the .dylib using the C++ compiler (no changes to the code though!) I can't even compile and link the program that uses the library. This seems like exactly the situation where you would need the extern "C". When you compile with the c++ compiler, name mangling is occurring. smime.p7s
participants (1)
-
Steve Checkoway