mateuskl
Joined: 27 Aug 2011 Posts: 1
|
Posted: Mon Dec 26, 2011 7:14 pm Post subject: Linking D applications with Linux shared libraries |
|
|
I would like to link my D application to a Linux shared library (.so file) using the DMD compiler.
Is that possible? If so, how I do that?
I have successfully linked my D application with a Linux static library (.a file), using DMD, as in:
Code: |
dmd main.d libbar.a
|
where main.d contains:
main.d
Code: |
extern (C) {
int bar(int i, int j, int k);
}
void main() {
bar(9,10,11);
}
|
and libbar.a was generated using
Code: |
gcc -c bar.c
ar rcs libbar.a bar.o
|
where bar.c contains:
Code: |
#include <stdio.h>
int bar(int i, int j, int k)
{
printf("i = %i\n", i);
printf("j = %i\n", j);
printf("k = %i\n", k);
return 8;
}
|
I'm using DMD32 D Compiler v2.054. |
|