Re: using dylib with dmd

2011-04-23 Thread Mike Wey

On 04/22/2011 10:18 PM, frostmind wrote:

Thank you for your response! Hopefully I've done it right.

Now when everything is within the same folder,
and I execute:
dmd test_d_client.d -L.

(so I'm telling to look for libs in current dir)
Response is now different:

ld: in ., can't map file, errno=22
collect2: ld returned 1 exit status
--- errorlevel 1

What else could be done here to resolve it?


Asuming your lib is named libRatings an is in the current directory, 
this should work:


dmd test_d_client.d -L-L. -L-lRatings

--
Mike Wey


Re: using dylib with dmd

2011-04-22 Thread frostmind
Thank you for your response! Hopefully I've done it right.

Now when everything is within the same folder,
and I execute:
dmd test_d_client.d -L.

(so I'm telling to look for libs in current dir)
Response is now different:

ld: in ., can't map file, errno=22
collect2: ld returned 1 exit status
--- errorlevel 1

What else could be done here to resolve it?


Re: using dylib with dmd

2011-04-22 Thread Jesse Phillips
frostmind Wrote:

> 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?

You need to tell the linker where your library is. You can just pass it to dmd 
on the commandline.


using dylib with dmd

2011-04-22 Thread frostmind
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?