Thread overview | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
September 06, 2013 Adding libraries to an executable | ||||
---|---|---|---|---|
| ||||
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? |
September 06, 2013 Re: Adding libraries to an executable | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anton Alexeev | On Friday, September 06, 2013 23:31:57 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?
Statically link it.
- Jonathan M Davis
|
September 07, 2013 Re: Adding libraries to an executable | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anton Alexeev | 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.).
|
September 07, 2013 Re: Adding libraries to an executable | ||||
---|---|---|---|---|
| ||||
Posted in reply to Rikki Cattermole | 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() |
September 07, 2013 Re: Adding libraries to an executable | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | On Friday, 6 September 2013 at 22:31:52 UTC, Jonathan M Davis wrote:
> On Friday, September 06, 2013 23:31:57 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?
>
> Statically link it.
>
> - Jonathan M Davis
How can I do that? I have compiled my program with this command: "dmd -L-lphobos2 -L-lcurl test.d
"
Excuse me for that dumb question but I'm really new to compiled languages. I've written some code in Java but it's not the same.
|
September 07, 2013 Re: Adding libraries to an executable | ||||
---|---|---|---|---|
| ||||
Posted in reply to Rikki Cattermole | 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?
|
September 08, 2013 Re: Adding libraries to an executable | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anton Alexeev | On Saturday, 7 September 2013 at 13:39:49 UTC, Anton Alexeev wrote:
> 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?
First I may have forgotten that phobos links with curl not loads at runtime.
So if your wanting to use shared libraries like this over static still.
You can basically compile normally.
Then $ Bin2D output.d=output main curl.so
Where main is the executable you built with dmd.
You will need to add a main function to output.d e.g.
import std.process;
void main() {
string[string] files = outputBin2D2FS();
execute(files["main"]);
}
Note that the usage of std.process is from memory.
Although I would highly recommend using static instead if you can.
|
September 09, 2013 Re: Adding libraries to an executable | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | On Friday, 6 September 2013 at 22:31:52 UTC, Jonathan M Davis wrote:
> On Friday, September 06, 2013 23:31:57 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?
>
> Statically link it.
>
> - Jonathan M Davis
Sorry for being noob but how I can do it?
|
September 10, 2013 Re: Adding libraries to an executable | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anton Alexeev | On 2013-09-06 23:31, 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? On Linux, doesn't all distributions ship with libcurl by default? For Windows I found this: http://www.drdobbs.com/packing-dlls-in-your-exe/184416443 I have no idea if it works for D. -- /Jacob Carlborg |
September 10, 2013 Re: Adding libraries to an executable | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On Tuesday, 10 September 2013 at 07:02:17 UTC, Jacob Carlborg wrote:
> On 2013-09-06 23:31, 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?
>
> On Linux, doesn't all distributions ship with libcurl by default? For Windows I found this:
Can be but not libphobos2
|
Copyright © 1999-2021 by the D Language Foundation