digitalmars.D.learn - Adding libraries to an executable
- Anton Alexeev (3/3) Sep 06 2013 I've written a program which uses curl library. So on a PC
- Jonathan M Davis (3/6) Sep 06 2013 Statically link it.
- Anton Alexeev (7/14) Sep 07 2013 How can I do that? I have compiled my program with this command:
- Anton Alexeev (3/10) Sep 09 2013 Sorry for being noob but how I can do it?
- Rikki Cattermole (7/11) Sep 07 2013 You just gave me an idea to compile in shared libraries and then
- Rikki Cattermole (17/29) Sep 07 2013 So I modified my Bin2D which allows compiling in resources[1].
- Anton Alexeev (7/38) Sep 07 2013 Thank you for taking time and writing this tool but I don't
- Rikki Cattermole (17/62) Sep 07 2013 First I may have forgotten that phobos links with curl not loads
- Jacob Carlborg (7/10) Sep 10 2013 On Linux, doesn't all distributions ship with libcurl by default? For
- Anton Alexeev (3/11) Sep 10 2013 Can be but not libphobos2
- Jacob Carlborg (5/6) Sep 10 2013 Link statically with it, which is does by default. Just compile with:
- Anton Alexeev (4/9) Sep 11 2013 The point is:
- Mike Parker (3/13) Sep 11 2013 Apparently you need to install the libcurl dev package. The linker can't...
- Anton Alexeev (4/20) Sep 12 2013 I've installed libcurl4-openssl-dev 7.29.0-1ubuntu3.1 before I
- Jacob Carlborg (4/7) Sep 12 2013 How does your dmd.conf file look like?
- Anton Alexeev (22/29) Sep 12 2013 ;
- Jacob Carlborg (6/10) Sep 12 2013 I don't see way explicitly linking with Phobos would make a difference,
- Anton Alexeev (2/2) Sep 13 2013 So, nobody can give an easy answer how to statically link the
- FreeSlave (3/5) Sep 13 2013 Did you try to use -static option of compiler? It forces to link
- Jonathan M Davis (6/8) Sep 13 2013 If you give the exact file name for the static library (e.g.
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?
Sep 06 2013
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
Sep 06 2013
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: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.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
Sep 07 2013
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:Sorry for being noob but how I can do it?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
Sep 09 2013
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.).
Sep 07 2013
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: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()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.).
Sep 07 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: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?On Friday, 6 September 2013 at 21:31:59 UTC, Anton Alexeev wrote: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()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.).
Sep 07 2013
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: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.On Saturday, 7 September 2013 at 09:05:39 UTC, Rikki Cattermole wrote: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?On Friday, 6 September 2013 at 21:31:59 UTC, Anton Alexeev wrote: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()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.).
Sep 07 2013
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
Sep 10 2013
On Tuesday, 10 September 2013 at 07:02:17 UTC, Jacob Carlborg wrote:On 2013-09-06 23:31, Anton Alexeev wrote:Can be but not libphobos2I'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:
Sep 10 2013
On 2013-09-10 11:04, Anton Alexeev wrote:Can be but not libphobos2Link statically with it, which is does by default. Just compile with: dmd -L-lcurl test.d -- /Jacob Carlborg
Sep 10 2013
On Tuesday, 10 September 2013 at 11:06:04 UTC, Jacob Carlborg wrote:On 2013-09-10 11:04, Anton Alexeev wrote:The point is: http://pastebin.com/0VkYgFixCan be but not libphobos2Link statically with it, which is does by default. Just compile with: dmd -L-lcurl test.d
Sep 11 2013
On 9/12/2013 6:20 AM, Anton Alexeev wrote:On Tuesday, 10 September 2013 at 11:06:04 UTC, Jacob Carlborg wrote:Apparently you need to install the libcurl dev package. The linker can't find libcurl.a.On 2013-09-10 11:04, Anton Alexeev wrote:The point is: http://pastebin.com/0VkYgFixCan be but not libphobos2Link statically with it, which is does by default. Just compile with: dmd -L-lcurl test.d
Sep 11 2013
On Thursday, 12 September 2013 at 01:16:28 UTC, Mike Parker wrote:On 9/12/2013 6:20 AM, Anton Alexeev wrote:I've installed libcurl4-openssl-dev 7.29.0-1ubuntu3.1 before I asked for help here. Else I can't even compile with that command: dmd -L-lphobos2 -L-lcurl test.dOn Tuesday, 10 September 2013 at 11:06:04 UTC, Jacob Carlborg wrote:Apparently you need to install the libcurl dev package. The linker can't find libcurl.a.On 2013-09-10 11:04, Anton Alexeev wrote:The point is: http://pastebin.com/0VkYgFixCan be but not libphobos2Link statically with it, which is does by default. Just compile with: dmd -L-lcurl test.d
Sep 12 2013
On 2013-09-12 12:14, Anton Alexeev wrote:I've installed libcurl4-openssl-dev 7.29.0-1ubuntu3.1 before I asked for help here. Else I can't even compile with that command: dmd -L-lphobos2 -L-lcurl test.dHow does your dmd.conf file look like? -- /Jacob Carlborg
Sep 12 2013
On Thursday, 12 September 2013 at 11:30:05 UTC, Jacob Carlborg wrote:On 2013-09-12 12:14, Anton Alexeev wrote:; ; dmd.conf file for dmd ; ; dmd will look for dmd.conf in the following sequence of directories: ; - current working directory ; - directory specified by the HOME environment variable ; - directory dmd resides in ; - /etc directory ; ; Names enclosed by %% are searched for in the existing environment and inserted ; ; The special name % P% is replaced with the path to this file ; [Environment] DFLAGS=-I/usr/include/dmd/phobos -I/usr/include/dmd/druntime/import -L-L/usr/lib/i386-linux-gnu -L-L/usr/lib/x86_64-linux-gnu -L--no-warn-search-mismatch -L--export-dynamicI've installed libcurl4-openssl-dev 7.29.0-1ubuntu3.1 before I asked for help here. Else I can't even compile with that command: dmd -L-lphobos2 -L-lcurl test.dHow does your dmd.conf file look like?
Sep 12 2013
On 2013-09-12 18:25, Anton Alexeev wrote:[Environment] DFLAGS=-I/usr/include/dmd/phobos -I/usr/include/dmd/druntime/import -L-L/usr/lib/i386-linux-gnu -L-L/usr/lib/x86_64-linux-gnu -L--no-warn-search-mismatch -L--export-dynamicI don't see way explicitly linking with Phobos would make a difference, since the compiler will link with Phobos implicitly. That assumes you have libphobos2.a in /usr/lib/i386-linux-gnu or /usr/lib/x86_64-linux-gnu. -- /Jacob Carlborg
Sep 12 2013
So, nobody can give an easy answer how to statically link the libraries with the executable and I have yo use Bin2D?
Sep 13 2013
On Friday, 13 September 2013 at 19:54:41 UTC, Anton Alexeev wrote:So, nobody can give an easy answer how to statically link the libraries with the executable and I have yo use Bin2D?Did you try to use -static option of compiler? It forces to link application with static libraries instead of shared.
Sep 13 2013
On Friday, September 13, 2013 21:54:39 Anton Alexeev wrote:So, nobody can give an easy answer how to statically link the libraries with the executable and I have yo use Bin2D?If you give the exact file name for the static library (e.g. /path/to/libcurl.a), then it should link against the static version of the library. Also, -L-static might help, as it tells the linker to only link static libraries. - Jonathan M Davis
Sep 13 2013