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.

static-linking
Filter by
Sorted by
Tagged with
1 vote
1 answer
489 views

undefined reference to `WinMain@16' error while linking SDL1.2 in cmake for MinGW

I recently managed to find solution to this problem related to SDL2, but somehow those solutions does not apply to SDL1.2. I tried using the flags -lmingw32 -lSDL -lSDLmain and also to add ...
Daniel's user avatar
  • 423
0 votes
0 answers
338 views

How can I statically compile Go programs so they can run in an empty container?

I have a program my_prog.go written in Go. I want to statically compile it into a standalone binary that can run inside an arbitrary or empty container: Dockerfile: FROM scratch My goal is that I ...
Ark-kun's user avatar
  • 6,551
0 votes
0 answers
188 views

Statically compiling python program to be able to run in an empty container

I have a program my_prog.py written in python. I want to statically compile it into a standalone binary that can run inside an arbitrary or empty container: Dockerfile: FROM scratch My goal is that ...
Ark-kun's user avatar
  • 6,551
4 votes
3 answers
9k views

Qt5 CMake include all libraries into executable

I'm trying to build a with Qt 5.14 an application on release mode and everything is working fine inside of Qt Creator, but when I'm trying to run the executable by itself I'm getting an error like ...
Mircea's user avatar
  • 1,869
0 votes
1 answer
183 views

Opencv in UBUNTU LTS error on basic c++ program

I installed opencv on UBUNTU 18.04 for C++. I used cmake on github source code and build in opencv/release. But writing even a hello world program containing ''' #include ''' is causing error on ...
Bhartendu Kumar's user avatar
0 votes
0 answers
372 views

gcc cannot find the static library installed in /usr/local/lib

I have built and installed my library according to the following cmake: install( TARGETS ${LIBRARY_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${...
Phocs's user avatar
  • 2,480
3 votes
0 answers
596 views

How to build a Swift program as a static executable?

I do not have any familiarity with the Swift Package Manager, but I have to compile a Swift program (https://github.com/ltentrup/SafetySynth, if it matters) as a statically linked executable (on Linux)...
Nicola Gigante's user avatar
2 votes
0 answers
190 views

Why do I get so many warnings building Haskell with optl-static in Docker?

Here's my Dockerfile FROM fpco/stack-build:lts-15.4 as haskell ENV STACK_ROOT /home/stackage/.stack WORKDIR /opt/build COPY Main.hs . RUN stack ghc --package process -- -optl-static Main.hs FROM ...
mmachenry's user avatar
  • 1,872
0 votes
0 answers
47 views

What is the best approach to simplify linking to my library?

I want to build a library which is easy to use and link to. Therefore, I do not want the user of my library to bother with building and linking against the libraries my library uses. What is the best ...
Simon Pio.'s user avatar
6 votes
1 answer
5k views

cmake - linking static library pytorch cannot find its internal functions during build

I'm trying to build a program using cmake. For several reasons, the program must be built using static libraries rather than dynamic libraries, and I need to use PyTorch so this is what I've done: ...
WannabeArchitect's user avatar
1 vote
1 answer
605 views

How can I change the ESCDELAY value for C ncurses when I'm statically linking the libraries at compile time?

I have a program that I wrote using the C ncurses library. In this program, near the top I have this line: ESCDELAY = 0; This line is used to remove the delay that comes when pressing the escape key ...
chunchunmaru's user avatar
2 votes
0 answers
630 views

Assembly alias and symbol

1.cpp: int meth() { return 0; } __asm__(".global meth_alias \n meth_alias = meth"); __asm__(".global meth_alias2 \n meth_alias2 = meth"); 2.cpp: int meth_alias(); int meth_alias2(); int ...
jw_'s user avatar
  • 1,723
1 vote
1 answer
444 views

Misconception about static/implicit linking Vs dynamic/explcit linking

I've recently learnt that static linking and implicit linking are basically the same thing, just different nomenclature. My understanding is that when you statically (implicitely) link to a binary, ...
CiaranWelsh's user avatar
  • 7,352
0 votes
2 answers
995 views

cannot link to static mysqlclient library, though shared library works

I have a sample program to familiarize myself with mysqlclient APIs. However when I compile and link it to the mysqlclient library statically (.a file), the linker complains it cannot find the file, ...
Daniel's user avatar
  • 1,514
0 votes
2 answers
380 views

Segfault due to static linking with ocaml and c libraries

I have a question regarding static linking in ocaml. When passing the flag "-static" to the c compiler, it compiles but when calling the resulting binary I immediately get a segmentation fault. The ...
mth's user avatar
  • 1
1 vote
0 answers
184 views

Can Gradle C++ dependencies get set differently for different applications?

I have some applications in the same project that have the same dependencies that are also being built, some of which need them as static and others need them shared. I built a very basic show of this ...
IAmPattycakes's user avatar
1 vote
0 answers
237 views

Crash when building C++ program in Visual Studio with "Use Link Time Code Generation" enabled, only for x64 platform

I have two C++ Visual Studio (16.5.0 Preview 2.0) projects: a library and an application that uses it. The library project produces four .lib files (for x86/x64 and release/debug), which the other ...
Jonathan Sharman's user avatar
2 votes
0 answers
469 views

How to create a Windows executable that embeds the Python interpreter using Cython

I try to create an executable using Cython with embedded Python (look here). I can find examples doing this on Linux, but not on Windows. The only Windows example I can find results in an executable ...
Frank Tap's user avatar
  • 348
0 votes
1 answer
80 views

Reducing disk size of dynamic libraries if code is shared between them

My C++ application loads two dynamic libraries libdy1.so and libdy2.so. I know both library libdy1.so and libdy2.so share lot of common code base. As these libraries are used only by my application i ...
SaurabhS's user avatar
  • 633
1 vote
1 answer
2k views

What does GLFW require linking with?

I keep getting undefined reference errors trying to compile this code: #include <GLFW/glfw3.h> int main(void) { if (!glfwInit()) return -1; glfwTerminate(); return 0; } I ...
João Pedro Voga's user avatar
0 votes
1 answer
314 views

netty-tcnative-openssl-static-2.0.28.Final-windows-x86_64.jar is dynamiclly linking to openssl

After building netty-tcnative-openssl-static-2.0.28.Final-windows-x86_64 from sources, using the created jar file results in unresolved dependency errors at runtime: Suppressed: java.lang....
user2011348's user avatar
2 votes
2 answers
586 views

Linking library C++

I'm struggling to link a project to an external project (named Prog). I'm not used with big project and dependecies problem, It's the first time I encounter such problem to link another library. I ...
helppls's user avatar
  • 21
2 votes
1 answer
1k views

Same object file in different static libraries when linking

clang++ ... foo.cpp ... -o dir1/foo.o clang++ ... foo.cpp ... -o dir2/foo.o //The only difference beween the above two clang++ command lines //is the output directory llvm-ar ... dir1/lib1.a ... dir1/...
jw_'s user avatar
  • 1,723
2 votes
2 answers
341 views

Populating an array with include directives

This morning I learned that the famous videogame Super Mario 64 has been fully decompiled back to C source code. Just out of curiosity, I've decided to look through it, and I noticed something that I ...
Gian's user avatar
  • 357
0 votes
0 answers
699 views

How to link the libsvm library in google colab when executing CUDA? What is the proper linking flag for libsvm?

I am working on google colab and i want to use libsvm library in my project. I downloaded libsvm and installed it. Now when i use !nvcc -o command and run the code using CUDA i am getting errors like, ...
ColabAli's user avatar
0 votes
0 answers
32 views

How to merge libraries in linux [duplicate]

Recently I wanted to build a game engine using C++ and glfw3. I want to create a static library libengine.a and link it with libglfw3.a and its dependencies. My question is how can I replace this: # ...
Dragomir's user avatar
11 votes
1 answer
9k views

How to build a Rust app free of shared libraries?

How does one compile a Rust application without having to load shared libraries at all? What have I tried: ex.rs fn main() { println!("Try to compile me statically!"); } According to https://...
unegare's user avatar
  • 2,359
2 votes
0 answers
761 views

Linking against static system library without full path in CMake

When building a CMake find module for a common system library, libatomic, I have noticed that if one creates a STATIC IMPORTED target with the name of a static library (i.e. libatomic.a) and then add ...
Thomas Russell's user avatar
1 vote
1 answer
1k views

How to create one static library from several others static libraries in C on Linux? [duplicate]

For example, we have three following libraries: 1.1.......................lib_A.a 1.2.......................lib_B.a 1.3.......................lib_C.a Now I want to create one library ...
Amish Sharma's user avatar
3 votes
1 answer
990 views

I cannot add additional libraries with premake5

I am learning OpenGL and GLFW, and I decided to use premake5, because it seems easy to use and maintain. My project is located in a folder called LearningOpenGL. I am on MAC. Project structure. ...
Tigran Fahradyan's user avatar
0 votes
1 answer
63 views

How does msvc compiler(and other compilers) knows which std overload to bind to?

I know this question has two answers - one very long and complicated and one rather short and simple. For now, I am interested in the latter. I am coming from C#/.NET background and if you used it ...
kuskmen's user avatar
  • 3,728
2 votes
0 answers
435 views

macOS Catalina static linking library issue

I have c++ project where I have 3 libraries. Two static and one dynamic which is dependent from first two. Those two are building successfully and third is crashing while building because lack of ...
Przemekeke's user avatar
1 vote
1 answer
335 views

Can a dynamically linked library override a static one?

nokogori gem comes with its own version of libxml2. Moreover it warns about libxml2.so of a different version being loaded before it was required: if compiled_parser_version != ...
x-yuri's user avatar
  • 17.7k
0 votes
1 answer
200 views

How to include all DLLs with my SDL2_mixer mingw application?

I'm making a simple application which uses SDL2_mixer lib. I want to make my application ready for distribution, which I guess means I should include all the dependency DLLs with my application. g++ -...
birgersp's user avatar
  • 4,477
2 votes
0 answers
99 views

How to link specific modules from libc?

I’m wondering is it possible to link only a specific module from libc, lets say - string.h. I’m creating a C program that is being statically linked, and needs to be as tiny as possible (memory wise)....
Tal Avraham's user avatar
2 votes
1 answer
6k views

Building libcurl with static linking to openssl

I am trying to build libcurl with static linking to openssl. So to achieve that, I have used following configuration: OpenSSL: LDFLAGS="-static” LIBS="-ldl” cURL: LDFLAGS="-static” CPPFLAGS="-I$(...
user1228352's user avatar
3 votes
1 answer
52 views

When do I need to care about static vs. dynamic linking in C for programs which use std functionality?

All of my programs tend to be rather rudimentary console applications in C. For example, I may write some code to parse a file header and then print some data from the header to the screen. To do this,...
the_endian's user avatar
  • 2,379
0 votes
0 answers
556 views

Statically link SDL on Windows (MinGW) / undefined references

I built SDL (2.0.10) using cmake and now I am trying to link it to my application. For linking I use g++ $(OBJS) -L./Path/To/SDL/LibFolder -lmingw32 -lSDL2main -lSDL2-static -oOut.exe When I link it ...
Etwus's user avatar
  • 579
5 votes
0 answers
1k views

How can I link libc statically with just ld?

I want to link libc statically with just ld. I got it right (dynamically) with ld -dynamic-linker /lib/ld-linux.so.2 prog.o -lc. I thought i have to find the right objectcode for the libc functions ...
rifkin's user avatar
  • 349
0 votes
1 answer
97 views

Can I save a C static library anywhere I want?

I have created a library in C and want to link it when compiled. Do I have to save in a certain folder in my computer's file system or can I create my own file structure within my application to save ...
Robinhoets's user avatar
5 votes
1 answer
2k views

GCC: --whole-archive recipe for static linking to pthread stopped working in recent gcc versions

Static linking against pthread is a difficult topic on Linux. It used to work to wrap -lpthread as -Wl,--whole-archive -lpthread -Wl,--no-whole-archive (the details can be found in this answer). The ...
Philipp Claßen's user avatar
0 votes
1 answer
700 views

Undefined reference when linking a .o file to a .elf file

I have an .o file compiled from a C project which references a function named init_static_pools. I use objdump -t to show its symbol dependency info: 00000000 UND 00000000 ...
smwikipedia's user avatar
  • 63.2k
2 votes
1 answer
2k views

How to clone, build, and link g2o framework in C++

I want to use g2o library in my C++11 project on Ubuntu 18.04, but I cannot make build working. I have all the dependencies. But I cannot link g2o library to my project via CMakeLists.txt I am a ...
Mikuláš Bankovič's user avatar
0 votes
1 answer
810 views

c++: statically link against different versions of the same library?

I include a 3rd party library in my code. I maintain a static link to it and am unable to support dynamic links (which would be the easiest solution to the problem but is not possible in my case). ...
Tyson's user avatar
  • 1,228
0 votes
1 answer
2k views

Issues with Statically linked libraries with CAPL Dll,

Can someone suggest the use of Callbacks which does not block the CANoe measurement? So, I have issues when I try to statically link libraries and make CAPL DLL. I contacted VECTOR but there is no ...
Om Choudhary's user avatar
0 votes
1 answer
2k views

Error linking SSL and crypto libraries installed in custom location

I am trying to create a shared library that is to be linked against OpenSSL-1.0.2p which depends on libssl1.0. The installed version of OpenSSL on my ubuntu bionic machine is however OpenSSL-1.1.1 ...
Skegg's user avatar
  • 870
8 votes
2 answers
7k views

How can I create a static executable with rustc using glibc instead of musl?

I wrote simple code in C, Go and Rust. foo.c #include <stdio.h> int main() { printf("hello\n"); return 0; } foo.go package main import "fmt" func main() { fmt.Println("hello");...
Lone Learner's user avatar
  • 19.3k
3 votes
1 answer
4k views

How to get static libraries for Eclipse Paho MQTT C client?

I'm trying to compile the code from the Paho repository on Ubuntu 16.04, such that the static libraries are produced: cd ~/Downloads git clone https://github.com/eclipse/paho.mqtt.c.git mkdir /tmp/...
ci7i2en4's user avatar
  • 834
0 votes
1 answer
223 views

wxWidgets cannot open setup.h

Stuff I've already done: Set the locations of both (some stuff)\include and (some stuff)\include\msvc in the properties. Set the location of the lib. Tried static linking (used the ones I've compiled/...
Mr SLAYER's user avatar
0 votes
1 answer
83 views

Statiс variable in base templated class, C++17 usage

I use C++17 and I'm trying to make such classes hierarchy (simplified): template<typename TChar> class CLoggerTxtBase { public: using TString = std::basic_string<TChar>; static ...
Oleksandr N.'s user avatar

1
6 7
8
9 10
37