LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-09-2009, 08:14 PM   #1
saltzmanjoelh
LQ Newbie
 
Registered: Sep 2009
Posts: 5

Rep: Reputation: 0
build and compile and include shared libs


Is it possible to compile a program and include the shared libraries with it?

I dont have root access and I want to install git on my godaddy shared server..
 
Old 09-09-2009, 08:47 PM   #2
karlatLQ
Member
 
Registered: Sep 2009
Posts: 67

Rep: Reputation: 19
What could work, but is frowned upon, is to build it with shared libs and then put the shared libs into the same directory. If it works, the libs would need to be compatible with the running system.
 
Old 09-09-2009, 08:55 PM   #3
saltzmanjoelh
LQ Newbie
 
Registered: Sep 2009
Posts: 5

Original Poster
Rep: Reputation: 0
tried it

i tried that but it didnt work. I created my own lib folder and updated the LD_LIBRARY_PATH var and git started to use those shared lib files but i dont want to have to:

run git
upload the missing lib file
run it again
upload another missing file

there are just too many...
 
Old 09-09-2009, 09:05 PM   #4
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
Couldn't you compile it all statically linked? If I'm not mistaken, this would build the lib requirements right into the resulting binary, similar to how blackbox works (it has no external dependencies).
 
Old 09-09-2009, 09:07 PM   #5
saltzmanjoelh
LQ Newbie
 
Registered: Sep 2009
Posts: 5

Original Poster
Rep: Reputation: 0
thats it

Ah thats the term i was looking for. Now to research how to do that.

Thanks!
 
Old 09-09-2009, 09:19 PM   #6
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
I would first execute the ./configure script that presumably comes with the git sourcecode, and pass the --help flag to it, like so:

shell# ./configure --help

and look for the option to DISable shared libs, and ENABLE static libs. I've never specifically done this with the intent of making a slandalone binary, but I believe that should do it.

Let us know how it goes

Sasha
 
Old 09-09-2009, 09:20 PM   #7
saltzmanjoelh
LQ Newbie
 
Registered: Sep 2009
Posts: 5

Original Poster
Rep: Reputation: 0
awesome thanks sasha
 
Old 09-09-2009, 09:20 PM   #8
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
You're welcome -- but don't forget to let us know if it works for future reference.

Cheers!
Sasha
 
Old 09-09-2009, 09:22 PM   #9
saltzmanjoelh
LQ Newbie
 
Registered: Sep 2009
Posts: 5

Original Poster
Rep: Reputation: 0
I will later this week
 
Old 09-10-2009, 02:50 PM   #10
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
While static link is possible solution it has it's own problems:
1) Not always static libraries exist/available
2) Link command for static linking can be significantly different, than link command for dynamic linking:
- when using dynamic link linker will track dependencies libraries by itself. for static link it's up to programmer to specify all needed libraries.
- for dynamic link libraries can be specified in any order, for static link order is important, and find right one can take time and efforts.
3) Many programs used plugins, i.e them use dlopen to load shared objects in the run time. Examples are any Qt, Gnome progra m and many others.
Even ls (at least when invoked with -l flag) use dlopen
As far as I know there is no way around dlopen (short of redesigning program)

If all mentioned above is not a problem for you, then go to the static link.
If not - there are alternatives.

Executable linked dynamically (as usual) and then used
statifier (http://statifier.sf.net) or
Ermine (http://magicErmine.com)

to convert dynamically linked executable to the self-contained one.

Statifier is licensed under GPL, Ermine - commercial.
On the other hand Ermine works better than statifier on systems with
VDSO/stack randomization
 
Old 09-10-2009, 03:26 PM   #11
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
Valery, thank you for stepping in.

I agree, it sounds oversimplified that it will actually work simply via the --static flag and/or through the configuration file.
I'm not much more than an experimenter when it comes to C, but I suspect that `git` will need at the very least, some dlopen's.

Thank you for adding the information you did. I hope it helps the OP

Cheers,
Sasha
 
Old 09-10-2009, 03:37 PM   #12
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
If you don't want the hassle, or static linking is not doable, you can better use ldd to determine the whole lot of libraries that you will need, then upload them all at once and launch the program using

Quote:
LD_LIBRARY_PATH="..." ./myprog
If it works, alias it and you are done.
 
Old 09-11-2009, 01:34 AM   #13
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
Quote:
Originally Posted by GrapefruiTgirl View Post
Valery, thank you for stepping in.

I agree, it sounds oversimplified that it will actually work simply via the --static flag and/or through the configuration file.
I'm not much more than an experimenter when it comes to C, but I suspect that `git` will need at the very least, some dlopen's.

Thank you for adding the information you did. I hope it helps the OP

Cheers,
Sasha
If ldd shows libdl.so - then executable (likely) uses dlopen
 
  


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
Using shared libs hwoarang Programming 7 08-20-2008 02:09 PM
Configure keeps asking for Qt include/libs when they are there Ephracis Linux - Software 2 02-10-2006 03:12 AM
shared libs help spatula Linux - Software 3 12-14-2005 03:48 AM
Recompile ALL shared libs? ta0kira Programming 3 06-13-2005 12:49 AM
shared libs hanzerik Linux From Scratch 2 03-14-2002 01:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:26 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