Thread overview
Using C library libsndfile with D
Jun 25, 2015
kerdemdemir
Jun 25, 2015
Ali Çehreli
Jun 25, 2015
bachmeier
Jun 25, 2015
Ali Çehreli
Jun 25, 2015
bachmeier
Jun 25, 2015
tcak
Jun 26, 2015
Kadir Erdem Demir
Jun 25, 2015
bachmeier
Jun 25, 2015
Adam D. Ruppe
June 25, 2015
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?
June 25, 2015
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

June 25, 2015
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.
June 25, 2015
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

June 25, 2015
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

June 25, 2015
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.


June 25, 2015
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.
June 25, 2015
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.
June 25, 2015
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.
June 26, 2015
> 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