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.

Filter by
Sorted by
Tagged with
1 vote
0 answers
40 views

How to compile Julia code as stand-alone executable with help of StaticCompiler for Windows?

I'd like to compile Julia with help of StaticCompiler on Windows. StaticCompiler is an amazing tool for compiling Julia, and it would be great, if it can be used in Windows, too. I guess there is a ...
Thomas R's user avatar
0 votes
1 answer
52 views

Building Qt from source statically for Visual Studio

I tried hundreds of times to build Qt from source for static linking and read many Stack Overflow questions and neither of them worked for me. How to get the static library and use it to build apps in ...
Sayed Reda's user avatar
0 votes
1 answer
34 views

Compilers allow a weak symbol function with no implementation and no linker error

A static library declares a function with a weak symbol. Later an application (not providing the function implementation) statically links the library but no linker error is generated. This seems to ...
rare77's user avatar
  • 311
2 votes
1 answer
44 views

How to statically link binary with curl library on MSYS2?

I'm using UCRT64 profile in MSYS2. Here is source code for example that I'm trying to compile. /*************************************************************************** * ...
almint's user avatar
  • 21
0 votes
1 answer
66 views

Statically linked executable with dynamic loading

I'm not sure if it makes sense or not, but is it possible to have a statically linked executable + dynamic loading ? In other words: at compile/linking time an object code is statically linked against ...
Carlo C's user avatar
  • 51
0 votes
0 answers
20 views

How can I specify to link the static library in CMake on MacOS, when I have both dynamic and static one? [duplicate]

As the title described, I want to link one static library in case the environment cannot find the paths in runtime. Also, except this library, other dependencies should be linked through their dynamic ...
1412's user avatar
  • 1
-1 votes
1 answer
107 views

Adding an external library built from source to c++ visual studio project

I'm trying to include an external library to my visual studio project on windows. The library in question is mpg123, to decode mp3 files. I followed the install instructions included with the library ...
nTn's user avatar
  • 9
2 votes
1 answer
60 views

Can the Xcode linker deduplicate symbols in a merged binary?

Intro I'm trying to determine whether Xcode's new Mergeable Libraries feature can remove duplicated symbols in a scenario where an app links to two dynamic frameworks which both link to the same ...
ale-gen's user avatar
  • 39
2 votes
1 answer
131 views

c++ segmentation fault using condition_variable with the -static linkage flag

I compiled and linked this simple program using g++ in a Raspberry Pi 4 running on the ARMv8-A. compiler: g++ -Wall -O0 -g3 -std=c++11 -c Main.cpp linker: g++ -static -o "bugTest.elf" ./Main....
alien's user avatar
  • 59
0 votes
0 answers
36 views

Let CMake link against specific version of libstdc++

I'm working on a fresh installed Debian-12 at where only the version 11/12 of gcc/g++ can be installed against the official apt repository. But my producing target app must be compiled with g++-9, so ...
Leon's user avatar
  • 1,661
-1 votes
1 answer
30 views

clang seems to ignore debug information from object files in static libraries

When I link my final binary directly from the object files, as in clang -o binary build/lib/*.o build/bin/*.o and my binary crashes, I have line numbers everywhere, because all my object files were ...
Mecki's user avatar
  • 127k
1 vote
0 answers
44 views

how can i build static program by cmake+clang on windows?

Sorry for my poor English first. I'm trying to build a c++ program using cmake+clang on a Windows system. My CMakeLists.txt: cmake_minimum_required(VERSION 3.5) set(CMAKE_C_COMPILER "C:/Software/...
Miracle's user avatar
  • 11
0 votes
0 answers
54 views

Statically linking OpenAL Soft using mingw-w64

I'm currently trying to build a C project using mingw-w64 and make, and although I've been able to get every other library linked just fine, OpenAL Soft has been giving me a headache. I've made ...
ElvisCrespo33's user avatar
2 votes
1 answer
92 views

How to tell msys2 cmake to use static libraries [duplicate]

Enviroment: Windows 11 x64 Msys2 with the mingw64 compiler VSCode CMAKE I want to compile an executable so that I can give it to another device without having to deal with installing dependencies on ...
ConnoK0lan's user avatar
0 votes
0 answers
66 views

libstdc++ both statically and dynamically linked through different libraries

My executable dynamically links two libraries (d1.so and d2.so). d1.so statically links to libstdc++. d2.so dynamically links to libstdc++. Assuming d1.so is loaded first, which stdlib (dynamic or ...
Karthick S's user avatar
1 vote
1 answer
93 views

Is it possible to build a dynamic framework without the symbols of a static library that it links to?

I have an app that links to two dynamic frameworks which both link to the same static library, as follows: |--App |--DynamicFramework1 |--StaticLibrary |--DynamicFramework2 |...
Adil Hussain's user avatar
  • 30.5k
2 votes
0 answers
23 views

Dynamic compiling curl works, but static curl compiled errors

When I compile and run my program dynamically curl works fine, but when compiled as static I get this: $ gcc -static -o main.exe -w main.c `pkg-config --static --cflags libcurl` `pkg-config --static -...
hoze's user avatar
  • 84
0 votes
0 answers
95 views

Compiling static C program doesn't find curl functions, even though linked

I'm trying to compile a C program statically. I tried adding "-static" option to the command line, but still get erros. This is the command line. gcc main.c -o main.exe -lcurl -static -L&...
hoze's user avatar
  • 84
0 votes
0 answers
36 views

QT Static version does not include external targetted libs

so I use static version, all works fine, app exe is generated with all standard and qt dlls so its fine to open in any windows machine. However the external libraries i link against the project are ...
Jiri Zaloudek's user avatar
0 votes
0 answers
21 views

Issues Linking gdi32 library for GLFW on MinGW-W64

I am having the follow error building with my makefile: g++ -Wall -o build/chess-gui src/*.cpp src/vendor/glad/src/glad.c -Isrc/ -Isrc/vendor/glad/include -Isrc/vendor/glfw/include -Lsrc/vendor/...
Matthew Whalen's user avatar
1 vote
0 answers
33 views

How to statically link readline when using mingw on Linux?

I made a small CLI tool that uses readline() for completion and powerful editing capabilities. On Linux, I can use the dynamic library easily by including it as a dependency in the package manager. On ...
td211's user avatar
  • 117
0 votes
0 answers
56 views

How to build an application using CMake that statically link to OpenCV on MacOS?

I tried everything I could to build my application using OpenCV static library on MacOS but at the end of the build I had no error but otool -L showed me that it was not working: build/src/lut_loader: ...
Fractale's user avatar
  • 1,505
1 vote
1 answer
55 views

compile program with libcrypto linked statically

I have simple program, which just calls few crypto functions. I can compile it linked dynamically, and it produces ~15KB binary: gcc -s -o crypt crypt.c -lcrypto When I try to compile it statically, ...
Martin Vegter's user avatar
1 vote
0 answers
75 views

How to build static executable without full path of static libraries? target_link_directories breaks the process of building static executables

I built a static executable with CMake.Here's my CMakeLists.txt cmake_minimum_required(VERSION 3.25) project(tmp2) set(CMAKE_CXX_STANDARD 20) set(BUILD_SHARED_LIBS OFF) set(CMAKE_EXE_LINKER_FLAGS &...
Askr Askr's user avatar
1 vote
1 answer
73 views

How can I include_bytes! into a singular external file?

I am writing a game in Rust and I am using include_bytes! to bundle some audio into the executable. The audio files are about ~250MB. I am compiling for both Intel Macs and ARM Macs and then creating ...
Chris's user avatar
  • 1,525
1 vote
1 answer
47 views

ImportError: undefined symbol when linking pybind11 with a static/shared library

I tried to link pybind11 with a static library. The building process was successful, but I got the runtime error "ImportError: undefined symbol". Directly linking with .o file worked fine ...
chrt's user avatar
  • 21
0 votes
0 answers
69 views

How do I Statically Link SDL in VSCode with MSVC

The problem: My Code is always compiling using a dynamic linker. The setup: I used SDL2-devel-2.28.2-VC.zip, because I use the MSVC compiler (64bit) with VSCode. To build my projects I use the .vscode ...
LuigiBro's user avatar
0 votes
0 answers
21 views

How can I convert/compile a Python script into an e executable with no _Python_ dependencies?

I've read this question: How can I make a Python script standalone executable to run without ANY dependency? and some (or all?) of the options there work. But - I don't care about removing all ...
einpoklum's user avatar
  • 121k
0 votes
1 answer
10 views

Can I un-dynamicize a linked executable given a dynamic library?

Suppose I have a dynamically-linked executable which depends on symbols in libfoo and libbar; and that it works on my system, i.e. it finds appropriate versions of these shared libraries. Now, I want ...
einpoklum's user avatar
  • 121k
1 vote
0 answers
105 views

CMake how proper link internal static library for creating another one

My main problem is how to link internal static library to be able build other internal static library which needs headers from first one. I have internal project which include 3 libraries and main ...
Stanisław's user avatar
0 votes
0 answers
52 views

Rust to C++ as Static Library on Windows [duplicate]

I want to create a static library in rust and use it later in c/c++. I already tried a few things and always get: undefined reference to `hello_rust' collect2.exe: error: ld returned 1 exit status my ...
OfflineBot's user avatar
-1 votes
1 answer
485 views

How do I statically link SDL2 in Visual Studio 2022?

I'm new to linking in general, how do I link SDL2 statically without having to have DDL's? I have seen a couple examples online, but they aren't easy to understand and follow. also I've read somewhere ...
user avatar
1 vote
1 answer
28 views

qmake: detect whether the kit uses a static or dynamic Qt version

Is there a way to check whether the active kit uses a static or dynamic Qt build? Something like this: contains(SOME_QMAKE_VARIABLE, STATIC_QT_BUILD) { message("static build detected!") }
dtech's user avatar
  • 48.3k
0 votes
0 answers
42 views

Cannot compile static despite specifying -DBUILD_SHARED_LIBS=OFF

I have the following CMakeLists.txt cmake_minimum_required(VERSION 3.16) project(LSODrinkServer VERSION 0.1 LANGUAGES C) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") list(...
randomdood1923's user avatar
0 votes
0 answers
34 views

Static Linking: Merging Binaries with Common Symbols

we have a collection of (C and C++11) code that gets compiled multiple times, producing distinct static libraries whose symbols conflict with each other. For various reasons, we are unable to change ...
Paul T.'s user avatar
0 votes
0 answers
60 views

is it possible to static link the rust application when using apple M1

Recently I am learning rust static linking, now I found a issue that it seems impossible to static linking the rust application when using M1 chip. I have read the official document from here https://...
Dolphin's user avatar
  • 31.1k
2 votes
0 answers
166 views

Rust linker fails when using target-feature=+crt-static on nightly

I am trying to compile my simple program statically, as I cannot install any software or libraries on the systems where the program need to run, so I need to ship all the dependencies. I decided to ...
Francesco Frassinelli's user avatar
1 vote
0 answers
301 views

MSYS2 Qt 6 static build fails with tons of unresolved symbols

I am trying to use the static Qt 6 package provided by MSYS2 but to no success. The same code is building just fine with Qt 5.15 dynamic, Qt 5.15 static and Qt 6.5 dynamic builds, but the Qt 6.5 ...
dtech's user avatar
  • 48.3k
1 vote
0 answers
58 views

Rust library linking error: undefined reference to function in divxc3

I am trying to use a rust library in an embedded ARM C project. When I try and link the .a file I get this error: arm-none-eabi-ld: rust-lib.a(divxc3.o): In function `__divxc3': /checkout/src/llvm-...
Joel Imbergamo's user avatar
0 votes
0 answers
171 views

Installing boost boost:x64-windows-static uses openssl dynamic libs instead of static ones

I want to create a fully statically linked app, no Visual C runtime and no third party dlls if static libs are available for those. Previously I were building the thirdparty libs myself, but wanted to ...
Ricardo Capurro's user avatar
0 votes
0 answers
63 views

Linking to libvorbis nad libvorbisfile failed - LNK2001 unresolved external symbol __imp__floor

I use VS 2017. I have added linking to libvorbis_static.lib and libvorbisfile_static.lib for an exisiting project. During linking I get a few errors with the same message: LNK2001 unresolved external ...
Irbis's user avatar
  • 1,270
0 votes
0 answers
36 views

CPP compilation can't link with boost static lib

I'm building exe using boost libs, I want to static link the libs, but I have linker errors with the libboost_log lib. I saw Question1 and Question2 but it didn't helped. Cmake: #### Boost set(...
lior.i's user avatar
  • 625
0 votes
1 answer
73 views

Unexpected memory usage behaviour when using static linking in C

I am studying static linking and dynamic linking, and my understanding is that static linking consumes more memory and disk space compared to dynamic linking. It is evident that static linking ...
Michael Coleman's user avatar
1 vote
1 answer
143 views

Swift -dead_strip doesn't remove unused classes

I create simple static library with only one source file for test -dead_strip option public class UsedClass { public init() {) public func function() { print("print") } } public class ...
Fesss's user avatar
  • 35
-1 votes
1 answer
84 views

How to single-object prelink a framework?

My situation: I am developing a dynamically linked framework called A, wrapped into .xcframework I depend upon other frameworks B and C that are linked statically However, I don't want the consumers ...
Isaaс Weisberg's user avatar
0 votes
1 answer
53 views

In CMake, can I mark a library as static after add_library'ing it?

In CMake, we can write: add_library(mylib mylib.c) for a dynamically-linked (shared) library, and add_library(mylib STATIC mylib.c) for a static one. But - can we start with the first syntax, then ...
einpoklum's user avatar
  • 121k
0 votes
0 answers
31 views

CMake target_link_libraries doesn't include symbols [duplicate]

I'm trying to create a static library and link to it a symbol from another static library, which is used by it. Although I pass to target_link_library necessary lib, the symbol is not included. See ...
marco's user avatar
  • 111
0 votes
1 answer
474 views

CMake CUDA: static link with cublas

I want to compile CUDALibrarySamples. cuFFT uses cmake and I want to compile and link 1d_c2c application with the static version of cufft lib (-lcufft_static). Using Makefiles is trivial I have added -...
MANOS's user avatar
  • 31
0 votes
1 answer
98 views

Visual studio 2022 demanding dependencies of libary

So I will start from the beginning, I wrote an application and then transformed it to a static libary to use its classes in an another application that I am writing, this libary is building just fine ...
Onur Kulan's user avatar
1 vote
1 answer
154 views

How do I build libraries for WebAssembly?

I want to use the FFmpeg libraries (libav) in my WebAssembly project, using Emscripten. I think I need to build the libraries from source to create ".a" files. (Please correct me if I'm ...
Tim Orton's user avatar
  • 328

1
2 3 4 5
36