On Thursday, 25 February 2016 at 16:45:46 UTC, Chris Wright wrote:
On Thu, 25 Feb 2016 12:15:42 +0000, mahdi wrote:

Hi,

Suppose I have a package `mypack` in `~/mypack`. I run `dub` command on this package and have the compiled `mypack` file (OS is Linux).

Now I am working on my project. I know how to use the source-code of `mypack` package in the project but what if I only have the compiled binary? How can I reference and use the modules of the compiled `mypack`?

(I looked into the DUB homepage and it's Getting Started page but could
not find anything).

First thing, you need D interface files. See: https://dlang.org/dmd-linux.html#interface-files

Note that D interface files still require you to include the full body of anything in a template, so you might have to modify your code somewhat for improved secrecy.

Copy the *.di files and binaries into another dub project and add a postBuildCommand to copy that binary to the output location.

I think that will work. dub might complain that it doesn't have any source files, in which case you'll have to provide at least one D file for it to compile, but that can be empty.

Thanks. Is there a way to use a D library without having access to it's source code? I tried `dmd -lib abcd.d` which creates a static library. But still I need to specify path to library's source files using -I option when compiling the code that uses that library.

So if we have just access to the library file, is it possible to use it in the code?

Reply via email to