Adam Ryczkowski
Adam Ryczkowski

Reputation: 8064

dlang how specify location of the external "C" library?

I'd like to use augeas on my Ubuntu. I've installed the libaugeas-dev apt package, that installed augeas.h file in /usr/include directory. Now I'd like to call some augeas functions.

The first one is augeas *aug_init(const char *root, const char *loadpath, unsigned int flags). I try to use it with the following code

import std.string;

struct augeas;

extern (C) augeas *aug_init(const char *root, const char *loadpath, uint flags);

void main() {
    auto x = aug_init(std.string.toStringz("/"), 
                  std.string.toStringz(""), 
                  0);   
}

The code compiles, but the linker cannot find the aug_init function (undefined reference toaug_init'`). How can I tell him to find it?

Upvotes: 0

Views: 177

Answers (1)

Adam Ryczkowski
Adam Ryczkowski

Reputation: 8064

All that was needed is to put the following entry in the dub.json:

"libs": ["augeas"]

So the whole dub.json is this:

{
    "name" : "aug-tool",
    "description" : "Hello World",
    "dependencies" : {  },
    "libs": ["augeas"]
}

Upvotes: 1

Related Questions