Questions tagged [static-linking]

42 questions
33
votes
3 answers

Do C compilers discard unused functions when statically linking to .a file?

Say I have a C program main.c that statically links to libmine.a. Statically linking to a library causes library functions to be embedded into the main executable at compile time. If libmine.a were to feature functions that weren't used by main.c,…
Izzo
  • 999
  • 1
  • 8
  • 15
18
votes
1 answer

What is bash-static used for?

What is the purpose of bash-static compared to regular bash? Is it good as a rescue shell or what is it good for?
Niklas Rosencrantz
  • 4,112
  • 6
  • 36
  • 58
17
votes
3 answers

Creating Static Binary

I installed an application [ e.g. fdisk ]. But it required libraries for execution. I am looking for utility/tool which will help me to create a static binary from already installed binaries. So that I can use it anywhere. The only reliable tools…
SHW
  • 14,454
  • 14
  • 63
  • 101
8
votes
2 answers

How can I get a static C compiler?

I'm playing around with chroot environments, and I'd like to have a portable C compiler so that I can easily set up some basic build-tools in each environment without having to move too many libraries around. Gcc seems pretty bloaty for what I want…
math4tots
  • 2,665
  • 8
  • 32
  • 42
7
votes
1 answer

Effect of static and dynamic linking on start address

I have a simple C program. I run: $ gcc Q1.c -Wall -save-temps -o Q1 Then I inspect the executable generated: $ objdump -f Q1 Q1: file format elf32-i386 architecture: i386, flags 0x00000112: EXEC_P, HAS_SYMS, D_PAGED start address…
ArunMKumar
  • 693
  • 2
  • 11
  • 19
5
votes
1 answer

Why can't ld find this library?

I'm not very knowledgeable on this topic, and therefore can't figure out why the following command does not work: $ gfortran -o dsimpletest -O dsimpletest.o ../lib/libdmumps.a \ ../lib/libmumps_common.a -L/usr -lparmetis -lmetis -L../PORD/lib/…
Sebastian
  • 8,677
  • 4
  • 39
  • 49
4
votes
1 answer

Build a standalone bash

I would like to build standalone bash binaries, which would hopefully work on a good portion of the linux distributions out there. Complete coverage is definitely not a goal. How would I approach this? Best-effort suggestions welcome. I understand…
simlei
  • 51
  • 3
4
votes
0 answers

Opening a TUN device from QEmu x86 for ARMv7 fails

On Banana PI-R1 (ARMv7), with qemu-i386-static, I'm trying to execute Barracuda VPN client statically linked for x86. Following this topic works : Running X86 binaries on armv7 But, when the VPN tries to open the TUN device is gets an «Unsupported…
Zebu1er
  • 51
  • 3
3
votes
1 answer

Static linking .so into my executable

I have a .cpp code I wrote, which is written around a commercial software program where they provide a big c++ library class to use. I want to static link their one shared object libtdfdll.so into my executable. They do not provide me with a…
ron
  • 5,749
  • 7
  • 48
  • 84
3
votes
2 answers

Linux static compilation issue

I am building testdisk as static and run make static it returns the following error /usr/bin/ld: cannot find -luuid collect2: ld returned 1 exit status What's the problem? In the makefile I have the following line LIBS = -lz -lntfs -luuid…
MA1
  • 137
  • 1
  • 9
2
votes
1 answer

create an statically linked executable from a dynamically linked executable and its dependencies

Take cat as an example, if I do ldd $(which cat), it shows linux-vdso.so.1 (0x00007fff8afbb000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb3102dd000) /lib64/ld-linux-x86-64.so.2 (0x00007fb310524000) Is there any way to bundle the cat…
doraemon
  • 371
  • 1
  • 3
  • 14
2
votes
1 answer

How to link different (incompatible) libraries at runtime depending on program?

I have a number of legacy codes that need to be compiled with specific (and often conflicting) libraries. To be specific I have a program which can only be compiled with g77 and another program which can only be compiled with gfortran. Let's call…
JBWhitmore
  • 123
  • 3
2
votes
1 answer

Apache + mod_ssl build not linking to my OpenSSL build

I have spent some time searching online but none of what I found seems to help. I'm running CentOS 6 64bit and would like to compile Apache with mod_ssl and need to link it to my own OpenSSL build (which is newer than the OS provided…
2
votes
1 answer

Error during static build of libvorbis and libmp3lame

I'm having trouble trying to build a static binary of ffmpeg - I've got almost the whole build working, with the exception of two libs - libvorbis and libmp3lame. These two libs are failing during ./configure, specifically on undefined functions…
kralewitz
  • 41
  • 5
2
votes
1 answer

Linker errors when compiling against glib...?

I'm having trouble compiling a simple, sample program against glib on Ubunutu. I get these errors. I can get it to compile but not link with the -c flag. Which I believe means I have the glib headers installed, but it's not finding the shared…
lucidquiet
  • 2,779
  • 2
  • 15
  • 8
1
2 3