LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-16-2009, 12:48 AM   #1
<Ol>Origy
Member
 
Registered: Aug 2003
Location: Slovenia
Distribution: Arch, Debian, Embedded
Posts: 136

Rep: Reputation: 15
How to compile a static binary?


I am trying to compile a static binary of cryptsetup-1.0.6 from source for use within the initial ram disk (initrd). The commands "configure && make && make install" will compile a dynamically linked executable, but what are the correct commands to compile a static binary "cryptsetup.static"?

I assume it is "configure --enable-static" before invoking make && make install. The only problem is that in this case the make script spits out some error that the gcc tried to link a dynamic object libgcrypt.so.
 
Old 01-16-2009, 02:16 AM   #2
chakka.lokesh
Member
 
Registered: Mar 2008
Distribution: Ubuntu
Posts: 270

Rep: Reputation: 33
-static-libgcc

go through the above option in "man gcc"
 
Old 01-16-2009, 08:36 AM   #3
<Ol>Origy
Member
 
Registered: Aug 2003
Location: Slovenia
Distribution: Arch, Debian, Embedded
Posts: 136

Original Poster
Rep: Reputation: 15
Here's the actual error that make spits out when using "configure --enable-static":
Quote:
gcc -g -O2 -o cryptsetup -static cryptsetup.o /usr/lib/libpopt.a ../lib/.libs/libcryptsetup.a -ldevmapper /usr/lib/libgcrypt.so -lnsl /usr/lib/libgpg-error.so -luuid
/usr/lib/gcc/i486-slackware-linux/4.1.2/../../../../i486-slackware-linux/bin/ld: attempted static link of dynamic object `/usr/lib/libgcrypt.so'
collect2: ld returned 1 exit status
make[2]: *** [cryptsetup] Error 1
make[2]: Leaving directory `/root/cryptsetup-1.0.6/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/cryptsetup-1.0.6'
make: *** [all] Error 2
And neither configure nor make seem to recognize the -static-libgcc flag.
 
Old 01-16-2009, 08:47 AM   #4
aldesha989
LQ Newbie
 
Registered: Oct 2008
Posts: 13

Rep: Reputation: 0
try
make install
 
Old 01-17-2009, 02:15 AM   #5
<Ol>Origy
Member
 
Registered: Aug 2003
Location: Slovenia
Distribution: Arch, Debian, Embedded
Posts: 136

Original Poster
Rep: Reputation: 15
Anyone?

I have noticed that my system lacked the two problematic static libraries - libgcrypt.a and libgpg-error.a - which the GCC tried to link their dynamic versions. I think I fixed the absence by downloading both libs from GnuPG website and compiling them from source using the standard "configure && make && make install" routine.

Trying to compile cryptsetup-1.0.6 with "configure --enable-static", make spits out this new error:
Quote:
gcc -g -O2 -o cryptsetup -static cryptsetup.o /usr/lib/libpopt.a ../lib/.libs/libcryptsetup.a -ldevmapper -L/usr/local/lib /usr/local/lib/libgcrypt.a /usr/lib/libgpg-error.so /usr/local/lib/libgpg-error.a -luuid
/usr/lib/gcc/i486-slackware-linux/4.1.2/../../../../i486-slackware-linux/bin/ld: attempted static link of dynamic object `/usr/lib/libgpg-error.so'
collect2: ld returned 1 exit status
make[2]: *** [cryptsetup] Error 1
make[2]: Leaving directory `/root/sources/cryptsetup-1.0.6/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/sources/cryptsetup-1.0.6'
make: *** [all] Error 2
Unfortunately, here is where I was stuck all along. I definitely have both static libs present now, but why is >make< still trying to link a shared library? Could it be a bug in the make script?
 
Old 01-18-2009, 02:27 AM   #6
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
Quote:
Originally Posted by <Ol>Origy View Post
Anyone?

I have noticed that my system lacked the two problematic static libraries - libgcrypt.a and libgpg-error.a - which the GCC tried to link their dynamic versions. I think I fixed the absence by downloading both libs from GnuPG website and compiling them from source using the standard "configure && make && make install" routine.

Trying to compile cryptsetup-1.0.6 with "configure --enable-static", make spits out this new error:

Unfortunately, here is where I was stuck all along. I definitely have both static libs present now, but why is >make< still trying to link a shared library? Could it be a bug in the make script?
You can use Ermine (http://magicErmine.com) or statifier (http://statifier.sf.net)
to create from dynamically linked file self-contained executable with all needed shared libraries.
 
  


Reply

Tags
binary, static



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
Static awk or gawk binary rbautch Linux - Software 5 06-14-2011 01:41 AM
Binary -- static or dynamic ? swiadek Linux - General 2 02-11-2006 04:25 PM
static compile twistedpair Linux - Software 3 01-09-2006 05:50 PM
How to compile into ELF binary? kornerr Programming 3 06-29-2005 11:37 AM
compile java classes to binary? ludeKing Programming 2 08-15-2004 09:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:21 AM.

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