FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Linking D applications with Linux shared libraries

 
Post new topic   Reply to topic     Forum Index -> Bindings
View previous topic :: View next topic  
Author Message
mateuskl



Joined: 27 Aug 2011
Posts: 1

PostPosted: Mon Dec 26, 2011 7:14 pm    Post subject: Linking D applications with Linux shared libraries Reply with quote

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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Bindings All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group