Linking C libraries with DMD

jmh530 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jan 21 14:49:06 PST 2016


On Thursday, 21 January 2016 at 22:35:29 UTC, Dibyendu Majumdar 
wrote:
>
> Sorry the option should be -L/IMPLIB:.. - with single slash but 
> you only need this if you are trying to create a shared library 
> which presumably you are not?
>
> I believe to create a static library you need to use -lib, else 
> it is an app so you need to supply a main function.
>
> Regards

The single slash didn't make a difference. I tried that myself 
before posting. I got the same error.

I'm not trying to created a shared library in D. My goal is to 
use a shared library from C in D. Right now, I'm working with a 
simple test case to make sure I could understand it before 
working with the actual shared library I want to use.

I recall some discussion in LearningD (don't have it in front of 
me now) that different types of shared libraries are needed on 
32bit vs. 64bit because there is a different linker. This is what 
I did to created the shared library:

gcc -Wall -fPIC -c <file>.c -I.
gcc -shared -o <libfile>.dll <file>.o -I.
implib <libfile>.lib <libfile>.dll


More information about the Digitalmars-d-learn mailing list