How to add third party libraries to the project. (Xamarin)

ZombineDev via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Dec 4 11:15:57 PST 2015


On Friday, 4 December 2015 at 18:15:47 UTC, Neomex wrote:
> How do I add third party libraries to the project? I am using 
> Xamarin. I have built Derelict-SDL2 with dub and got the lib 
> file but I don't know what to do with it.
>
> In xamarins references folder theres only option to refresh not 
> to add anything.

The MonoD plugin for Xamarin/Monodevelop supports DUB,
so you don't need to manually add references and/or
build the dependencies yourself.

Here's how you can create a new DUB project the
depends on Derelict-SDL2 inside a folder named myproj:

mkdir myproj
dub init ./myproj derelict-sdl2 -fjson

The last command will create the following directory structure:
myproj/.gitignore  <- useful, if you use git version control
myproj/source  <- here you should put your source code
myproj/source/app.d
myproj/dub.json  <- this file describes your project and its 
dependencies

The myproj/dub.json file contains:
{
     "name": "myproj",
     "description": "A minimal D application.",
     "copyright": "Copyright © 2015, ubuntu",
     "authors": ["ubuntu"],
     "dependencies": {
         "derelict-sdl2": "1.9.7"
     }
}

To build this sample application with DUB you need
to run only the following command:

dub

To open the created project under XamrinStudio / Monodevelop
1) Open XamrinStudio / Monodevelop
2) Make sure you have MonoD installed.
   You can do it from Tools -> Add-in Manager -> Gallery -> 
Language Bindings ->
   D Language Binding.
3) File -> Open -> navigate into the myproj folder and select the 
dub.json file.

That's it. Xamarin Studio / Monodevelop will now open the DUB 
project in the Solution Pad. You can even browse through the 
source code of the dependencies, by clicking on the External 
Dependencies folder in the Solution Pad, which should be 
populated after the first time you build you project through 
Xamarin Studio / MonoDevelop.

Here you can find more information about MonoD:
http://wiki.dlang.org/Mono-D
https://github.com/aBothe/Mono-D

Mike Parker who is the main developer behind Derelict has a nice 
blog here:
http://dblog.aldacron.net/

Good luck!


More information about the Digitalmars-d-learn mailing list