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
0
votes
1 answer

If I statically link a C library, will the unused functions be optimized out?

My feeling is that essentially 100% of the time this is what you would want to happen, but I suspect that there might be some theoretical caveats, for example: Say I statically link the standard library and I use printf but not sprintf. Further…
Benjamin Lindqvist
  • 4,300
  • 3
  • 18
  • 19
0
votes
0 answers

Sharing static library between .dll(runtime loading) and .exe

I have a .lib library which provides APIs which have global variables like file/device handles, these APIs are going to be used by the application(.exe) by linking with .lib statically. The application does some initialization using APIs provided by…
0
votes
1 answer

Decouple compile and linking into two steps

I have a main file, which calls a function defined in the shared lib. // main.c int main() { int x[2] = {1, 2}; int y[2] = {3, 4}; int z[2]; addvec(x, y, z, 2); } The shared library is the following code // addvec.c void addvec(int…
Will Wang
  • 105
  • 1
  • 3
  • 10
0
votes
0 answers

SFML Project Running Perfectly in Codeblocks but Release EXE Giving Errors Even with all DLLs included

So I have this issue and I cannot seem to find a solution to it online. I am dynamically linking SFML following this tutorial using the same exact versions of both Codeblocks and SFML. It works perfectly fine in the IDE but when I try to run the EXE…
Jepsilon
  • 101
  • 3
0
votes
2 answers

Static linking of Boost and OpenCV libs with Eclipse CDR. errors

I try to link my project statically with the Boost and OpenCV libs in Eclipse CDT. I have searched Google which libraries I have to add and added them to the linker. But the error messages are still there. What am I doing wrong? make all Building…
Dave
  • 23
  • 2
  • 4
0
votes
1 answer

Add new function to libpthread.a

I am trying to modify pthread_create. To be specific, in create_thread, I want to remove CLONE_FILES flag. I also have functions requires normal pthread_create. So I duplicate code of pthread_create and create_thread, rename them into…
Shuangyi Tong
  • 83
  • 1
  • 4
0
votes
1 answer

How to figure out where linking to static library of Boost's thread component is postulated when building Field3D?

I am building Field3D which links to Boost's thread library. The building environment is listed as follows: Windows 10 version 1803 64bit Visual Studio 2015 Update 3 CMake 3.11.4 Release x64 DLL mode in VS Field3D source package is downloaded from…
user5280911
  • 723
  • 1
  • 8
  • 21
0
votes
1 answer

Auto link static libraries from header file

I'm writing a library for in-house use and I want to automate the linking of static library (.lib) files so users don't have to know all the libraries they need. We use Visual Studio 2015 so I've knocked something up using pragma which seems to work…
0
votes
1 answer

How link LLVM libraries

I have small Code::Blocks project using LLVM. Code is already compiled but are problems with link: in /usr/localc/lib are 134 libraries with size all = 5 GB. If I try add to CodeBlocks library by library, are errors: not found symbols. If I try add…
Bor
  • 69
  • 4
0
votes
3 answers

Static linking issue on Solaris sparc

Undefined symbols Error while statically linking xerces with application only on solaris sparc, whereas static linking on other platforms(Linux, HP-UX,Solaris-x86) working. Here are errors. Undefined first referenced symbol …
Sach
  • 659
  • 8
  • 20
0
votes
0 answers

LNK2019 Using a static member with static linking

I have 3 projects in Visual Studio 15. The first (A) and second (B) - dynamic libraries, the third (D) - exe, which uses both libraries. The task is to link the first library statically. The first problem I encountered is if I link to both D…
Francuz
  • 433
  • 5
  • 13
0
votes
1 answer

Static linking sfml errors

I've been trying to statically link sfml to a c++ project, but It always gives me compiler errors, does anyone know what's going on here and how to fix it; edit: This is the code that produced the error: and this is what I've put into the…
EvilDuck
  • 63
  • 6
0
votes
2 answers

CMake works when I link a dynamic library but not a static library

When I link a dynamic library with CMake, create the make file and then use make, it compiles and builds correctly. When I link a static library, CMake doesn't complain but when I run make, it throws a linker error at me, even though all I did was…
0
votes
1 answer

How do I create an executable in Visual Studio without linking to any libraries?

I'm attempting to make test case executables for a disassembler, and I'd like to strip off the bulk that linking to libc or libstdc++, etc. adds to an executable. This is all well and simple using GCC, and I've got plenty of samples from GCC with no…
Chris
  • 3
  • 2
0
votes
1 answer

An error happened when compiling the FreeImage library as static linking?

I'm trying to compile the FreeImage v3.17.0 library by using Visual Studio 2015 to get the static library file but there are some problems. The library package comes as follow: I used the FreeImage.2013 file to compile the library, and after…
Lion King
  • 32,851
  • 25
  • 81
  • 143