static-linking

Selective Static Linking Of Library Functions In Shared Library

I want to create a shared library that uses functions from a 3rd-party static library. For example, foo and bar from libfoobar.a. I know that my main application is also using foo and will be exporting that symbol. So I simply want to link in bar to save code size and leave 'foo' unresolved (as it will be provided by main application). I...

Why create a .a file from .o for static linking?

Consider this code: one.c: #include <stdio.h> int one() { printf("one!\n"); return 1; } two.c: #include <stdio.h> int two() { printf("two!\n"); return 2; } prog.c #include <stdio.h> int one(); int two(); int main(int argc, char *argv[]) { one(); two(); return 0; } I want to link these programs togethe...

Statically linking against library built with different version of C Runtime Library, ok or bad?

Consider this scenario: An application links to 3rd party library A. A is built using MSVC 2008 and is statically linking (ie. built with /MT) to the C Runtime Library v9.0. The application is built using MSVC 2005 and is statically linking to A and (using /MT) to the C Runtime Library v8.0. I can see trouble with this - for instance ...

Static library symbols missing in linked executable

Hi, I am trying to link a statically created .a library with another piece of C code. Butin the final executable several symbols (function names) are are found missing when seen with the nm command. Is itdue to the fact that the linker (gcc being called) is stripping the symbols which are not referenced in the other pirce of C code that ...

Glade and static linking

If I'm statically linking a GTK+ program under FreeBSD 8, gtk_builder_add_from_file() suddenly returns with an error: Invalid object type `GtkWindow' How to fix that? With dynamic linking everything works fine. Update: linking is done by: cc -o foobar foo.o bar.o main.o -Wall -pedantic -std=c99 D_THREAD_SAFE -DORBIT2=1 -D_REENTRAN...

How do I sort the symbols of other sections besides the "COMMON" section?

The gnu linker "ld" supplies the option "-sort-common" which sorts the uninitialized global parameters, known as the COMMON section symbols, by their size. When the linker aligns the symbols to even addresses, this option helps minimizing the holes in the section. For example, if we define: --main.c char a; short b; ch...

Static linking vs dynamic linking

Are there any compelling performance reasons to choose static linking over dynamic linking or visa versa in certain situations? I've heard or read the following, but I don't know enough on the subject to vouch for their veracity. 1) The difference in performance between static linking and dynamic linking is usually negligible. 2) (1) i...

C++ application - should I use static or dynamic linking for the libraries?

I am going to start a new C++ project that will rely on a series of libraries, including part of the Boost libraries, the log4cxx or the google logging library - and as the project evolves other ones as well (which I can not yet anticipate). It will have to run on both 32 and 64 bit systems, most probably in a quite diverse Linux enviro...

How to build MTd projects which use MDd dlls in VS2005

I am building my application in Visual Studio 2005, using project properties ->c/c++->CodeGeneration->RuntimeLib: MTd (using static CRT library-LIBCMTD). The application is using 3rd party dlls and libs which are built in MDd(using dynamic CRT lib- MSVCRTD). I'm getting linker errors as: MSVCRTD.lib(MSVCR80D.dll) : error LNK2005: __mkti...

How to make and link static library in Xcode for iPhone?

I have a static library project and an application project. I thought it should be easy to link my own library, but it was not. I cannot figure out how to link my lib into my app project. I built lib.a successfully. I added the .a file into my app project's framework folder. But I cannot access classes inside there. And the header file...

c static linking to lib and still requesting DLL

Hello, Using visual studio 2008, I have an .H and a .LIB file of a library. I wrote a program and refrenced the LIB via the project properties. It compiles fine, but when it runs, it asks for the DLL to be installed. If the DLL is in the same dir as the EXE it works ... but, if I have the LIB, doesn't it already mean the functions are s...

Trying to statically link Boost

I am working in Linux, Eclipse CDT, g++, with Boost library. Having existing program which uses Boost thread, I try to link it statically instead of dynamically. /usr/local/lib directory contains the following files: libbost_thread.a libbost_thread.so libbost_thread.1.41.0 Dynamic linking works: g++ -o"MyProgram" ./main.o -lboost...

What's the difference between link libstdc++ statically and link libstdc++.a

Hi, all. I've read this article before I asked this question:Linking libstdc++ statically I just can not understand his explaination of why linking statically simplye not ganna work. Can anybody here help me out? (since orignial blog feedback is closed, I can't help but asking here) ...

Which dynamic libraries on OS X can be taken for granted?

If I want to make an OS X program as self-contained as possible to ease installation, what dynamic libraries can I expect everyone or most people to have? If I know that, I won't have to compile static libraries for everything. ...

What are the pro and cons of statically linking a library?

Hi, I want to release an application I developed as a hobby both for Linux and Windows. This application depends on boost (and possibly other libraries). The norm for this kind of application (a chess engine) is to provide only an executable file and possibly some helper files. I tough it would be a good idea to statically link the lib...

ImageMagick static compilation with another project gives linker errors

I've downloaded the ImageMagick source, compiled the wizard to create a Visual Studio solution for static linkage, and included the static library Magick++ project in my sample project (code below). I've also added a dependency on that project and included the .lib file in the solution, nothing helps. #include <Magick++.h> int main() {...

Statically compiling QWebKit 4.6.2

I tried to compile Qt+Webkit statically with MS VS 2008 and this worked. C:\Qt\4.6.2>configure -release -static -opensource -no-fast -no-exceptions -no-accessibility -no-rtti -no-stl -no-opengl -no-openvg -no-incredibuild-xge -no-style-plastique -no-style-cleanlooks -no-style-motif -no-style-cde -no-style-windowsce -no-style-windowsmobi...

undefined references

Hello, I'm trying to compile some fortran code and I'm running into some confusing linking errors. I have some code that I compile and place into a static library: >gfortran -c -I../../inc -o bdout.o bdout.F >ar rv libgeo.a bdout.o I then try to compile against that library with some simple test code and get the following: >gfortran...

Iphone Link Static Library

Hi All, I have created a static library in XCode called TestLib. I then created a simple test project that will use this library. I dragged the TestLib xcode project into my test project (frameworks section - if it matters), and set TestLib as a direct dependency of the test project. I am having trouble importing header files from the ...

Static library not included in resulting LLVM executable

Hi, I am trying to compile a c program using LLVM and I am having trouble getting some static libraries included. I have successfully compiled those static libraries using LLVM and, for example, libogg.a is present, as is ogg.l.bc. However, when I try to build the final program, it does not include the static ogg library. I've tried va...