LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-24-2007, 02:20 PM   #1
md_lasalle
LQ Newbie
 
Registered: Dec 2006
Posts: 16

Rep: Reputation: 0
Distributing your app


Hello all, not sure if this is the right section to post into, but since most of programmers have to distribute an application after development, I'm guessing one will be able to answer me

My problem is simple, when new .so are installed on a computer, they need to get registered with ldconfig, and you must tell the OS the path of your lib in some file, which differs from a distribution to another ( on my uBuntu 6.10, the file is /etc/ld.so.conf )

With dynamic runtime linking, theres no such problem, because the file can be in the same folder and will get linked flawlessly.

What is the best approach, for an installation process that :

A) Wouldn't require root password ( like for ldconfig )
B) Makes sure your app will find the .so it needs
C) Works on most distros

My app shall not require a compilation on the target system, everything is in binary.

Thank you for any lights on this.
 
Old 09-24-2007, 07:34 PM   #2
JoeyAdams
Member
 
Registered: Jun 2006
Distribution: Kubuntu Hardy
Posts: 94

Rep: Reputation: 15
I know a way to do this, but it's not really that simple. Installing the library in a system directory will by nature require root password. However, you can compile your program to link against a local object rather than one in the default library path. I put together a simple example that builds a program and its library and dynamically links them, all in the same folder:

http://www.funsitelots.com/c/local_library.tar.bz2

Just extract the tarball, enter local_library, run ./build to build the program, and run ./runapp to run the program. For some reason, you have to do `export LD_LIBRARY_PATH=.:$LD_LIBRARY_PATH` before you can run the app, that's why I made the ./runapp script, too.

Anyone know a simpler way to do this?
 
Old 09-25-2007, 09:30 AM   #3
md_lasalle
LQ Newbie
 
Registered: Dec 2006
Posts: 16

Original Poster
Rep: Reputation: 0
hey thank you for your reply

My guess is that, the important line is this one :

Code:
gcc app.c -L. -lYourLib -o app
with -L. specifying the working directory as the lib search path, probably why you have to export the LD_PATH

the approach is interesting, I'm gonna test some things with this.

Thanks a lot
 
Old 09-25-2007, 10:37 AM   #4
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
You can LD_LIBRARY_PATH no matter what the line used with gcc. That just tells gcc where to look for the library at compile-time. The actual location at run-time can be anywhere. By using a shell-based wrapper, you can set that up at run time along with any other environmental variables needed.
Here's an example I use to run gcc-2.95.3.
Code:
#!/bin/sh
export PATH=/opt/gcc-2.95/bin:$PATH
export LD_LIBRARY_PATH=/opt/gcc-2.95/lib

exec "$@"
In your case, the exec line should be:
exec /path/to/your/program
or:
exec program
if the program is in the PATH set above. You can also use relatives paths if needed:
${PWD}/../../bin

Last edited by gnashley; 09-25-2007 at 10:39 AM.
 
Old 09-25-2007, 12:24 PM   #5
md_lasalle
LQ Newbie
 
Registered: Dec 2006
Posts: 16

Original Poster
Rep: Reputation: 0
everything seems to work great now.

Thanks for your reply gnashley, this was my next question :

How can I make my shell-based wrapper accessible from anywhere

so that, from any folder on the system, i can type : myApp and it would start, in the proper folder where it was installed. ( Installers are the target of my next questions )

And on a side note, what does '${PWD} does on that line : '${PWD}/../../bin'
 
Old 09-26-2007, 02:48 AM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
The shell env var $PWD is 'Print Working Dir' ie rtn the current dir you are in.
 
Old 09-26-2007, 04:55 AM   #7
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
Isn't that Present Working Directory? Anyway, it means the directory where the current process was executed from.
No there is no way to have your program available from anywhere on your system.
When you try to execute a program, the shell searches your PATH for a an executable program of the name you typed in. For ordinary users this is usually includes /usr/local/bin, /usr/bin and /usr/X11R6/bin. Only by installing your program under one of those directories can your user execute the program by simply typing the name of it.
Still, you can place it anywhere and run it by invoking the full path to it, or by cd'ing into the directory where it is and running ./prog-name
 
Old 09-26-2007, 08:10 PM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Try man pwd, although that's actually the cmd, rather than an env variable.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Distributing Source from kdevelop Simon_6162 Programming 1 04-08-2005 11:08 PM
Distributing Mandrake 10.1 Nawas111 Mandriva 11 01-05-2005 05:07 PM
Distributing my distro rickseiden Linux From Scratch 4 11-19-2004 09:36 PM
Distributing a Qt Project Baryonic Being Programming 5 10-16-2004 03:19 PM
Imaging and Distributing Linux bmckenz1 Linux - Software 4 06-13-2003 11:20 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration