Re: How can I use a .dylib created in Xcode in my gcc-compiled program?
Re: How can I use a .dylib created in Xcode in my gcc-compiled program?
- Subject: Re: How can I use a .dylib created in Xcode in my gcc-compiled program?
- From: Steve Checkoway <email@hidden>
- Date: Mon, 15 Oct 2007 19:18:18 -0700
On Oct 15, 2007, at 7:06 PM, Milford Brimdash wrote:
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.
[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
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden