using dylib with dmd
frostmind
frostmind at yandex.ru
Fri Apr 22 12:33:30 PDT 2011
Greetings every one,
I desperatly searched net about how to compile a d2
program that uses dylib on mac os, but unfortunately no luck.
What I've been doing:
I have a C library compiled as (taken from http://developer.apple.com/):
gcc -dynamiclib -std=gnu99 Ratings.c -current_version 0.1 -compatibility_version 0.1 -
fvisibility=default -o libRatings.A.g
--> so I have libRatings.A.dylib that my testapp will use.
I've converted Ratings.h header of the lib to Ratings.d file, all functions enclosed in extern(C);
I created a test program: test_d_client.d
import Ratings;
import std.stdio;
void main() {
writeln("Starting test");
char[] value1 = "*".dup;
addRating(value1.ptr);
writeln("rating: %s", ratings());
}
And now, when I execute: dmd test_d_client.d I get following output:
Undefined symbols:
"_addRating", referenced from:
__Dmain in test_d_client.o
"_ratings", referenced from:
__Dmain in test_d_client.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
--- errorlevel 1
What I am doing wrong here?
More information about the Digitalmars-d
mailing list