Questions tagged [static-linking]

A static library or statically-linked library is a set of routines, external functions and variables which are resolved in a caller at compile-time and copied into a target application by a compiler, linker, or binder, producing an object file and a stand-alone executable. This executable and the process of compiling it are both known as a static build of the program.

1772 questions
51
votes
2 answers

CMake: how to produce binaries "as static as possible"

I would like to have control over the type of the libraries that get found/linked with my binaries in CMake. The final goal is, to generate binaries "as static as possible" that is to link statically against every library that does have a static…
pszilard
  • 1,942
  • 1
  • 15
  • 18
50
votes
17 answers

Xcode4 Linking Problem. File was built for archive which is not the architecture being linked (arm6)

Recently, I switched to Xcode4 and when I compile my project I got following error. ld: warning: ignoring file /Users/myname/Library/Developer/Xcode/DerivedData/appname-hezrgyqimckztgbdlslkavphdclw/Build/Products/Debug-iphoneos/libTapkuLibrary.a,…
Seunghoon
  • 5,632
  • 5
  • 35
  • 41
40
votes
7 answers

Making small haskell executables?

Are there any good ways to make small haskell executables? With ghc6 a simple hello world program seems to come to about 370kB (523kB before strip). Hello world in C is about 4kB (9kB before strip).
Anthony Towns
  • 2,864
  • 1
  • 19
  • 23
40
votes
4 answers

Create statically-linked binary that uses getaddrinfo?

I have included the header netdb.h, where getaddrinfo is included, but gcc issues this warning: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking gcc -m32…
Neeladri Vishweswaran
  • 1,695
  • 5
  • 22
  • 40
39
votes
3 answers

Is a statically linked executable faster than a dynamically linked executable?

Since the dynamically linked libraries have to be resolved at run-time, are statically linked executables faster than dynamically linked executables?
Hungary Coder
  • 409
  • 1
  • 4
  • 4
39
votes
5 answers

Is there a way to determine which version of Visual Studio was used to compile a static library?

I have a collection of static libraries (.lib) files one of which may have been built with a different version of Visual Studio. This is causing the code generation of a project that links against all of them to fail. Is there any way to determine…
Bill Carey
  • 1,395
  • 1
  • 11
  • 20
38
votes
1 answer

Static and Dynamic/Shared Linking with MinGW

I want to start with a simple linking usage to explain my problem. Lets assume that there is a library z which could be compiled to shared library libz.dll(D:/libs/z/shared/libz.dll) or to static library libz.a (D:/libs/z/static/libz.a). Let I want…
Yuki
  • 3,857
  • 5
  • 25
  • 43
36
votes
3 answers

CMake and Static Linking

I'm using CMake in a project, and I'm trying to statically link some libraries. I've set: set(BUILD_SHARED_LIBS OFF) set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static") set_target_properties(icarus PROPERTIES…
Ælex
  • 14,432
  • 20
  • 88
  • 129
32
votes
3 answers

making gcc prefer static libs to shared objects when linking?

When linking against libraries using the -l option (say -lfoo), gcc will prefer a shared object to a static library if both are found (will prefer libfoo.so to libfoo.a). Is there a way to make gcc prefer the static library, if both are found? The…
Ákos Maróy
  • 919
  • 2
  • 10
  • 19
32
votes
1 answer

Program can't find libgcc_s_dw2-1.dll

Possible Duplicate: The program can't start because libgcc_s_dw2-1.dll is missing I'm using Code::Blocks and MinGW 4.4 (I think) compiler to create a C++ project. I get this system error if I run it from its directory, but not from within…
Greg Treleaven
  • 8,124
  • 7
  • 30
  • 30
31
votes
4 answers

Deploying Yesod to Heroku, can't build statically

I'm very new to Yesod and I'm having trouble building Yesod statically so I can deploy to Heroku. I have changed the default .cabal file to reflect static compilation if flag(production) cpp-options: -DPRODUCTION ghc-options: -Wall…
asm
  • 8,758
  • 3
  • 27
  • 48
31
votes
3 answers

What does the "rcs" option in ar do?

I did read the man file but it does not help. rcs seems to be the most popular option to pass to ar, but the meaning isn't so clear to me. So c means to create a new archive, but then why use r? which seems to stand for "replace"? What will the s…
user3810155
30
votes
2 answers

How to force gcc to link unreferenced, static C++ objects from a library

I'm using a C++ library that can be built as either a shared or a static library. This library uses a factory technique, where static objects register themselves when the program starts and the static objects get created. This works fine as long as…
Gene Vincent
  • 5,237
  • 9
  • 50
  • 86
30
votes
2 answers

Compiling with -static-libgcc -static-libstdc++ still results in dynamic dependency on libc.so

I'm trying to make an executable that's as portable as possible. After removing a few dependencies, I came across the following when running the binary on another system: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.15' not found (required by…
Claudiu
  • 224,032
  • 165
  • 485
  • 680
29
votes
2 answers

How to static link Linux software that uses ./configure?

I would like to compile NRPE static, so I can copy the compiled binary to an OmniOS server, where I don't want gcc to be installed on. I would prefer to install NRPE with SSl support from a repository, but such doesn't seam to exist, so I would like…
Sandra Schlichting
  • 25,050
  • 33
  • 110
  • 162