How to interface with C++ code or dll?
Suliman via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Jan 11 04:56:39 PST 2015
I am trying to understand how to use C++ lib from D.
For my App I need http://www.gdal.org
I had read about using C++ libs from D, and understood that there
is 2 ways:
1. Make binding - convert .H to .d (I still do not fully
understand what is it)
2. Use directly C++ lib (.dll)
I decided to start from simple example
http://www.gdal.org/warptut.html
For compiling it's need #include "gdalwarper.h", so I maked
gdalwarper.d with tool htod.
I know that it's not recommended for usage more, but other tools
look too complex for me (I even do not understand how to sun them
on Windows).
After I had add import gdalwarper.d to my test project. But
during compilation it's asked me about other d files, that I
included one ny other in App.d file. In the result I got error
that:
"source\cpl_port.d(147): Error: module ctype is in file
'std\c\ctype.d' which can not be read"
I have got a question. Files that I include is only header files.
They do not include any code. How App would run? I should specify
C++ source location or what?
=========
Then I decided to look how to use ready dll. As far as I know D
have directive pragma(), that allow to import any lib.
Also afaik that it support inly import of dll in format of lib.
Am I right?
And next. How I can understand which lib do I need. All
documentation of GDAL assume that programmer will use source
code, but not libs. And what I should to do? I download gdal
bins, and there is a lot of dlls and I even can't understand
which of them I need.
More information about the Digitalmars-d-learn
mailing list