www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Using C library libsndfile with D

reply "kerdemdemir" <kerdemdemir hotmail.com> writes:
Hi

I want to read wav files. I thought I can use libsndfile since I 
am quite familiar with it.

I downloaded the project from.
https://github.com/D-Programming-Deimos/libsndfile

I add the sndfile.di file to my project.

I thought I could directly use  libsndfile.dll since D directly 
supports C. But I am getting link errors.

Can I use a C DLL directly ?
Do I have to add anything to my dub.json file if dll is my 
project file ?
What is "Deimos" stands for ?  Is it collections of bindings ? 
Does community supports "Deimos" projects?
Jun 25 2015
next sibling parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 06/25/2015 11:12 AM, kerdemdemir wrote:

 I downloaded the project from.
 https://github.com/D-Programming-Deimos/libsndfile

 I add the sndfile.di file to my project.

 I thought I could directly use  libsndfile.dll since D directly supports
 C. But I am getting link errors.
Bindings are for compilation only. You still need to link with the libraries, which varies by platform. D has the pragma(lib) feature where you can tell the compiler to link with a specific library as well. For example: pragma(lib, "curl"); You would probably use "sndfile" in your case (not sure): pragma(lib, "sndfile");
 Can I use a C DLL directly ?
Yes.
 Do I have to add anything to my dub.json file if dll is my project file ?
I will let others answer that. I don't know Windows anymore.
 What is "Deimos" stands for ?
All the names come from planet Mars. Phobos is its large moon and Deimos is the small one.
 Is it collections of bindings ?
Yes.
 Does community supports "Deimos" projects?
Yes. Ali
Jun 25 2015
parent reply "bachmeier" <no spam.com> writes:
On Thursday, 25 June 2015 at 18:29:23 UTC, Ali Çehreli wrote:

 D has the pragma(lib) feature where you can tell the compiler 
 to link with a specific library as well. For example:

   pragma(lib, "curl");

 You would probably use "sndfile" in your case (not sure):

   pragma(lib, "sndfile");
This is the first time I've heard of pragma(lib). It's a nice feature that should be added to the compiler documentation.
Jun 25 2015
next sibling parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 06/25/2015 12:51 PM, bachmeier wrote:

   pragma(lib, "sndfile");
This is the first time I've heard of pragma(lib). It's a nice feature that should be added to the compiler documentation.
They are all here: http://dlang.org/pragma.html pragma(inline) is the latest, which will be available in 2.068. Ali
Jun 25 2015
next sibling parent "bachmeier" <no spam.com> writes:
On Thursday, 25 June 2015 at 19:54:34 UTC, Ali Çehreli wrote:
 They are all here:

   http://dlang.org/pragma.html

 pragma(inline) is the latest, which will be available in 2.068.

 Ali
I meant on this page: http://dlang.org/dmd-linux.html Someone starting out with D might not look at the pragma documentation. pragma(lib) is easy to miss even if you read that page.
Jun 25 2015
prev sibling parent reply "tcak" <tcak gmail.com> writes:
On Thursday, 25 June 2015 at 19:54:34 UTC, Ali Çehreli wrote:
 On 06/25/2015 12:51 PM, bachmeier wrote:

   pragma(lib, "sndfile");
This is the first time I've heard of pragma(lib). It's a nice feature that should be added to the compiler documentation.
They are all here: http://dlang.org/pragma.html pragma(inline) is the latest, which will be available in 2.068. Ali
I would expect documentation was to be saying "Added on 2.068" somewhere for it.
Jun 25 2015
parent "Kadir Erdem Demir" <kerdemdemir hotmail.com> writes:
 D has the pragma(lib) feature where you can tell the compiler 
 to link with a specific library as well. For example:

   pragma(lib, "curl");
I want to try that as soon as I get home from work.
 You probably need to make a .lib file from the dll too. The 
 implib program does that.

 If you don't have it, if you wanna email me the 
 libsoundfile.dll program, I'll run it and make the .lib for you.
Your advice and your time is very important for me. I will try to run implib. I think it is important to get use to this tool for future anyways. Thanks alot Erdem
Jun 25 2015
prev sibling parent reply Steven Schveighoffer <schveiguy yahoo.com> writes:
On 6/25/15 3:51 PM, bachmeier wrote:
 On Thursday, 25 June 2015 at 18:29:23 UTC, Ali Çehreli wrote:

 D has the pragma(lib) feature where you can tell the compiler to link
 with a specific library as well. For example:

   pragma(lib, "curl");

 You would probably use "sndfile" in your case (not sure):

   pragma(lib, "sndfile");
This is the first time I've heard of pragma(lib). It's a nice feature that should be added to the compiler documentation.
http://dlang.org/pragma.html#lib It's got some problems though. Not everyone's system is the same. -Steve
Jun 25 2015
parent "bachmeier" <no spam.com> writes:
On Thursday, 25 June 2015 at 19:54:40 UTC, Steven Schveighoffer 
wrote:

 http://dlang.org/pragma.html#lib

 It's got some problems though. Not everyone's system is the 
 same.

 -Steve
Okay. Then I guess it should not be pushed.
Jun 25 2015
prev sibling parent "Adam D. Ruppe" <destructionator gmail.com> writes:
You probably need to make a .lib file from the dll too. The 
implib program does that.

If you don't have it, if you wanna email me the libsoundfile.dll 
program, I'll run it and make the .lib for you.
Jun 25 2015