DUB linking to local library

Craig Dillabaugh via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Aug 3 19:26:16 PDT 2015


I have been writing bindings for the GDAL library (www.gdal.org). 
   I recently updated my bindings to the latest release of GDAL 
(2.0).

Before adding my bindings to code.dlang.org I want to run some 
tests.  I've built GDAL2 locally and want to link my bindings to 
this library.  However, I also have the older GDAL libraries 
(1.11) installed system wide on my machine.

My GDAL bindings have the following dub.json file:

{
	"name": "gdald",
	"description": "D bindings for the Geospatial Data Abstraction 
Library (GDAL).",
	"homepage": "https://github.com/craig-dillabaugh/TBD",
	"homepage": "http://www.gdal.org/",
	"importPaths":["."],
	"targetType":"sourceLibrary",
	"license": "MIT",
	"authors": [
		"Craig Dillabaugh"
	],
	"libs" : ["gdal"]
}

While my test program appears as follows:

{
	"name": "gdaltest",
	"description": "Test cases for GDAL D.",
	"copyright": "Copyright © 2014, Craig Dilladub bubaugh.",
	"authors": [
		"Craig R. Dillabaugh"
	],
	"dependencies": {
		"gdald" : {"version": "~master"}
	},
	"lflags" : [ 
"-L/home/craig2/code/gdal-2.0.0/lib64/libgdal.so.20.0.0" ],
	"libs" : ["gdal"],
	"targetPath" : ".",
	"targetType" : "executable"
}

I used add-local so that my test program could see my bindings.

My issue is that while everything compiles OK (with dub build) 
the resulting executable gdaltest seems to be linked with the 
system gdal.so file and not the libgdal.so.20.0.0 file I 
specified with lflags.

ldd prints out:

ldd gdaltest
         linux-vdso.so.1 (0x00007ffe417e2000)
         libgdal.so.1 => /usr/lib64/libgdal.so.1 
(0x00007faabacf8000)

So how can I force my application to link to my local copy of 
GDAL2 at /home/craig2/code/gdal-2.0.0/lib64.  Any help is 
appreciated.


Craig






More information about the Digitalmars-d-learn mailing list