digitalmars.D.learn - running my program with shared libraries
- Harpo (17/17) Apr 05 2014 Hello all! I am having trouble running a program I am writing
- Adam D. Ruppe (8/10) Apr 05 2014 This kind of thing is common in Linux, in fact, a lot of Linux
- "Marc =?UTF-8?B?U2Now7x0eiI=?= <schuetzm gmx.net> (11/22) Apr 06 2014 You can also use the linker flag "-rpath" to hard-code the search
- JR (5/8) Apr 08 2014 To list said directories;
Hello all! I am having trouble running a program I am writing without using a script. Here is what I am using to compile. dmd main.d fileloader.d tokenizer.d globals.d namefunctions.d misc.d math.d questions.d functions.d -L-ldl -gc Then in a runner script I have this. LD_LIBRARY_PATH=. ./main When I started dynamically loading shared objects I was told I need to put the LD_LIBRARY_PATH bit there to run it. When I do not have it my program fails to execute. I would like to just be able to run the program from the command line like you would any other program e.g "./main". I do not really know what the LD_LIBRARY_PATH part does so I do not know how to solve my problem. Does anyone here know how I can set this up the way I want to? I am running xubuntu 13.04 64bit. I am using the latest DMD compiler. The shared objects are coded in c++. Thanks!
Apr 05 2014
On Sunday, 6 April 2014 at 00:12:00 UTC, Harpo wrote:Then in a runner script I have this. LD_LIBRARY_PATH=. ./mainThis kind of thing is common in Linux, in fact, a lot of Linux software consists of a runner script that sets LD_LIBRARY_PATH and a separate binary file and its library .so files that is the actual application. LD_LIBRARY_PATH tells it where to find the shared library files. Without it, the system only searches the global directories like /usr/lib.
Apr 05 2014
On Sunday, 6 April 2014 at 02:49:15 UTC, Adam D. Ruppe wrote:On Sunday, 6 April 2014 at 00:12:00 UTC, Harpo wrote:You can also use the linker flag "-rpath" to hard-code the search path in the executable. dmd your_file.d -L-rpath -L'$ORIGIN/.' The $ORIGIN (with quotation marks around it to keep it from being expanded) is important. It means the linker should interpret the path relative to the location of your executable, instead of relative to whatever the current directory happens to be. (The latter is a security risk, because an adversary might trick the user to run your executable from their own directory, where they have placed a manipulated copy of the shared library.)Then in a runner script I have this. LD_LIBRARY_PATH=. ./mainThis kind of thing is common in Linux, in fact, a lot of Linux software consists of a runner script that sets LD_LIBRARY_PATH and a separate binary file and its library .so files that is the actual application. LD_LIBRARY_PATH tells it where to find the shared library files. Without it, the system only searches the global directories like /usr/lib.
Apr 06 2014
On Sunday, 6 April 2014 at 02:49:15 UTC, Adam D. Ruppe wrote:LD_LIBRARY_PATH tells it where to find the shared library files. Without it, the system only searches the global directories like /usr/lib.To list said directories; ldconfig -v 2>/dev/null | grep '^/' You can add your own paths via *.conf files in /etc/ld.so.conf/. Just text files listing absolute paths, delimited by newlines.
Apr 08 2014