Adding libraries to an executable
Anton Alexeev
alexanto at gmx.de
Sat Sep 7 06:39:48 PDT 2013
On Saturday, 7 September 2013 at 10:13:39 UTC, Rikki Cattermole
wrote:
> On Saturday, 7 September 2013 at 09:05:39 UTC, Rikki Cattermole
> wrote:
>> On Friday, 6 September 2013 at 21:31:59 UTC, Anton Alexeev
>> wrote:
>>> I've written a program which uses curl library. So on a PC
>>> without curl the program will not work until you install the
>>> library. Is there a way to put the curl library in the
>>> executable?
>>
>> You just gave me an idea to compile in shared libraries and
>> then to extract them on run.
>> I'll let you know when I got some code.
>> (Btw this is not a good idea but definitely will work for
>> license reasons, although this could be a rather gray zone.
>> Should be confirmed.).
>
> So I modified my Bin2D which allows compiling in resources[1].
> Now it can produce an output file that when compiled in gives
> two new functions.
> These functions essentially extract the files for you.
> One of those is for temporary directory[2].
>
> Little bit off topic but it can be utilised for packaging up
> shared libraries into your executable and then extracting on
> run.
>
> E.g.
> $ dub build
> $ cd bin
> $ ./Bin2D outputFile.d=outputModule lib1.so lib2.dll
> Just an example usage. Note not on dub repository.
>
> Just another option for ya.
>
> [1] https://github.com/rikkimax/Bin2D/blob/master/source/Bin2D.d
> [2] string[string] outputBin2D2FS()
Thank you for taking time and writing this tool but I don't
really understand how to use it. Can you please explain it little
bit more? So I have my main.d file with source code and I compile
it with this command: "dmd -L-lphobos2 -L-lcurl main.d". How will
I get all the libraries into one executable with Bin2D?
More information about the Digitalmars-d-learn
mailing list