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
400 views

Use ngspice library in WebAssembly

I would need some help with using ngspice as a library in a webassembly (wasm) project. I installed emsdk and newest version of emcc (1.39.20) and downloaded the source of ngspice version 32. To my ...
balping's user avatar
  • 7,738
1 vote
0 answers
95 views

How to create a C++ DLL using another C++ LIB?

I'm trying to generate a DLL based on existing software pieces compiled in a static library (.lib) file. I'm using Visual Studio 2019, and the target is purely Windows. The existing project (P1) have ...
Maël Le Monnier's user avatar
0 votes
0 answers
50 views

Static linking external library problems - Visual Studio 2019 [duplicate]

I have been trying to statically link the TagLib library to a project in Visual Studio 2019. So far my project will build however as soon as I declare anything from the TagLib library I get an error ...
WalleyM's user avatar
  • 172
0 votes
2 answers
229 views

Django Static Files - No error but still doesnt load or change css

It seems like this is an incredibly common issue and I've read the docs and tried all solutions and multiple youtube videos, but can't find a solution. When I run the development server, my static ...
sjuice10's user avatar
2 votes
2 answers
2k views

How do I statically link FFTW on windows?

During the setup of my project - when I knew even less than I do now about cmake - I was trying my hardest to link the FFTW library. C:\\path\\to\\fftw-3.3.5-dll64 contains the .h files, .lib files (...
Tobi Akinyemi's user avatar
2 votes
2 answers
45 views

Is it possible to create a function that returns a static value generated upon creation, not upon calling the function?

Problem Statement: How do I create a function that will pass a value that is determined upon creation of the function, and not upon calling the function? Background Using altair I am trying to set up ...
Mike Williamson's user avatar
2 votes
1 answer
387 views

Statically linking the dependencies of a shared object in linux

I'm trying to create a share object which has its own dependencies statically linked. Here is an example: /* File: add.c */ #include <stdio.h> int add(int a, int b) { printf("Adding: %d %...
Anastasios Andronidis's user avatar
0 votes
1 answer
2k views

Why is linking to cuda runtime still necessary for library user even when compiling with -cudart static

I have some simple cuda code that I am compiling to a static library using nvcc, and some user code that I am compiling with g++ and linking against the previously compiled static library. When ...
Diggs's user avatar
  • 129
1 vote
0 answers
80 views

How to create two static libraries in which one has dependency over the other in Xcode?

I am trying to create two static libraries in which one static library is dependent on the other in Xcode. Below is a simple example that I use to demonstrate what exactly I mean: In static library ...
zfgo's user avatar
  • 315
10 votes
1 answer
7k views

How does CGO_ENABLED affect dynamic vs static linking?

We are compiling our Go code to be run on docker and we were investigating why our binary was not executing. We found that it was missing some dynamic libraries (although we want statically linked ...
Thomas's user avatar
  • 8,640
8 votes
2 answers
36k views

standard_init_linux.go:219: exec user process caused: no such file or directory

I am trying to move my rust server from Heroku to Google Cloud or AWS. Even though I like the simplicity of having a git push build and deploy to Heroku with just a buildpack specified, the service is ...
manonthemat's user avatar
  • 6,181
0 votes
0 answers
2k views

Issue linking SDL-2 statically in Visual Studio 2019 project

I am trying to statically link SDL-2 in my Visual Studio 2019 project and I am getting the following error. LNK4098 defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library ...
cookies's user avatar
  • 347
1 vote
0 answers
232 views

C++ linking to static library

I have one c++ project 'A' which outputs a dynamic library. I want this library to link to a static library 'B' that I made. The problem is that I am having an undefined external symbol error on ...
Hasan H's user avatar
  • 141
0 votes
1 answer
573 views

How to statically link allegro5 (Linux, G++)?

I built the latest stable version of allegro5's source code following these steps I have the following code (main.cpp): #include <stdint.h> #include <allegro5/allegro.h> #include <...
rdbo's user avatar
  • 163
0 votes
1 answer
929 views

C++ detours linking issue

I have problems building my code that is using static lib detours. I am trying to do an old basic CTF. For that I want to get into detours. Whenever I try to build my .dll file I get an issue LNK2019 ...
geo10's user avatar
  • 377
1 vote
1 answer
1k views

How should I link to static wxWidgets libraries when using gcc / mingw?

It's rather frustrating and the most common answer is "do what CodeBlocks does". I don't care. I want to undertand. The problem is: wxWidgets, when built non-monolithically, is split across ...
Kuba hasn't forgotten Monica's user avatar
1 vote
2 answers
4k views

How are relocations supposed to work in static PIE binaries?

Consider this GNU Assembler program for AMD64 Linux: .globl _start _start: movl $59, %eax # SYS_execve leaq .pathname(%rip), %rdi # position-independent addressing leaq .argv(%rip), %...
Joseph Sible-Reinstate Monica's user avatar
0 votes
0 answers
312 views

Making a static library

I am attempting to make a static library for a piece of code of mine, but cannot figure out how to get it to work. The exact question is: What exactly do I need to export and what do I need to import ...
NiInThTrCo's user avatar
0 votes
0 answers
149 views

Why are `malloc` and `free` listed as `External` and `UNDEF` in DUMPBIN.exe output for my static library?

I have built a static library on Linux with gcc compilers using cmake and am now porting to windows with msvc compilers. I'm using CLion with the default generator, which is NMakefiles x64. I have ...
CiaranWelsh's user avatar
  • 7,352
0 votes
2 answers
535 views

build a standalone exe file form a QT+openCV project running in QT Creator

I just recently programmed a project in QT Creator framework which both uses QT libraries such as QT_Widget and also openCV libraries such as openCV_tracking . my project includes .ui , .pro , main....
AmirHossein Rasoulian's user avatar
0 votes
1 answer
584 views

Undefined symbol to destructor only on MacOS [duplicate]

In a library i'm working on, I have something like this template class in a header file: template <int something> class Base { public: virtual ~Base(); // Implemented in c++ file } class ...
Rotartsi's user avatar
  • 547
0 votes
1 answer
1k views

CMake add linker options after .obj files

Cross compiling an executable for an embedded system with CMake requires me to manually add link options to link libc, libgcc and whatnot. However using target_link_options for that results in a ...
Vinci's user avatar
  • 1,440
0 votes
2 answers
2k views

How can I link the 3rd party library bzip2 in my gcc compiler?

I'm a python developer new to C and developing C code on Windows that needs to work on Windows and Linux. To that end, I downloaded MSYS2 and used pacman to install gcc and bz2. My question is: How ...
CSStudent7782's user avatar
0 votes
1 answer
485 views

g++ link against static library does not work

I have a simle file main.cpp and static library MyLib.lib and I am trying to link program against static library like this: g++ -o m main.cpp -static -L c:\lib\path -l MyLib or like this: g++ -o m ...
sfgr's user avatar
  • 1
3 votes
1 answer
2k views

Eliminate dependency on MinGW-specific DLLs when compiling dynamic library

I am using msys2 to compile a library that uses autotools as the build system. The end result is a DLL. This DLL ends up referring to the following other DLLs that come with msys2: libgcc_s_seh-1.dll ...
Szabolcs's user avatar
  • 25.2k
2 votes
1 answer
225 views

instruction point value of dynamic linking and static linking

By using Intel's pin, I printed out the instruction pointer (ip) values for a program with dynamic linking and static linking. And I've found that their ip values are quite different, even though ...
Tae's user avatar
  • 125
1 vote
1 answer
665 views

Find static library unresolved dependencies before linking executable

So let's say we have static library mylib.a, which contains compiled cpp files. file1.cpp: int do_stuff(); int func_unres() { int a = do_stuff(); return a; } file2.cpp: int do_other_stuff(...
toozyfuzzy's user avatar
  • 1,108
4 votes
0 answers
875 views

Undefined reference errors to all functions whe trying to statically link my SDL2-based program

I want to link statically my C++ SDL2-based program, but it's not working as expected. I already placed all headers files, my program and the libSDL2main.a file in a single folder. Then I tried to ...
isocppforbids's user avatar
2 votes
1 answer
462 views

Is it possible to have a completely statically linked GUI app on Linux?

Is it possible to have a completely statically linked GUI app on Linux? I'm aware that some libraries (e.g. Qt5) have the option to be statically compiled and linked into the executable, but even then ...
fygesser's user avatar
1 vote
2 answers
2k views

Xamarin.iOS native linking error MTOUCH MT5210 undefined symbol std::string

My Xamarion.iOS binding project has the links to all the required native video SDK libraries and native OS frameworks. I have set the required frameworks using Frameworks attribute. Other settings ...
Hong Wang's user avatar
0 votes
0 answers
36 views

Linux, C++ - libraries in libraries, gcc, code::blocks linking error [duplicate]

code::blocks version 17.12 Ubuntu MATE 19.10 1.22.2 gcc - 4:9.2.1-3.1ubuntu1 libavahi-client3 - 0.7-4ubuntu5 (although probably not relevant) I have C++ app which uses avahi to communicate across the ...
Mike's user avatar
  • 2,739
1 vote
0 answers
778 views

How to Externally, Dynamically Link Lua into a WinAPI/C++ Visual Studio 2019 Project with CMake

Background I'm currently dabbling in the world of game programming, and following an online guide from bell0bytes. Right now I'm working on this tutorial: https://bell0bytes.eu/lua-and-game-settings/ ...
davidhinton23's user avatar
-1 votes
3 answers
202 views

Call C function without declaring it beforehand

Short version: I would like to declare a function in the same statement that calls it. The syntax I'm looking for is something of this sort: // foo is undeclared in this file, and implemented in ...
NadavS's user avatar
  • 777
0 votes
0 answers
398 views

what does it mean that my static library symbols are defined with an address 0

I'm trying to componentize my build into multiple static libraries, and link them together into one shared library. I'm losing symbols from the final .so file. One strange behavior I noticed is that ...
xaviersjs's user avatar
  • 1,644
0 votes
0 answers
39 views

How to correctly link MSVC library

I'm currently following instructions from a document and it says something like : add headers and library to your compiler. I have the choice between those precompiled files : https://github.com/...
heartie's user avatar
  • 13
0 votes
1 answer
441 views

Missing exported symbols when building using MinGW linked with static library

I have a simple c++ program with libcurl dependency: #include <curl/curl.h> extern "C" int curlTest(void); int curlTest(void) { CURL *curl = curl_easy_init(); return 0; } I would ...
Clyx's user avatar
  • 43
1 vote
0 answers
1k views

Is msvcrt a static or dynamic library?

I was reading in MSDN ( here ) about the different CRT libraries in Windows. According to it, msvcrt.lib is a: Static library for the native CRT startup for use with DLL UCRT and vcruntime. while ...
Z E Nir's user avatar
  • 332
17 votes
1 answer
8k views

What's the difference between "statically linked" and "not a dynamic executable" from Linux ldd?

Consider this AMD64 assembly program: .globl _start _start: xorl %edi, %edi movl $60, %eax syscall If I compile that with gcc -nostdlib and run ldd a.out, I get this: statically ...
Joseph Sible-Reinstate Monica's user avatar
2 votes
0 answers
3k views

Static linkage of executable with CMAKE_MSVC_RUNTIME_LIBRARY in Visual Studio 2019

I am using the CMAKE_MSVC_RUNTIME_LIBRARY option so that MSVC uses /MTd to statically link an executable. CMakeLists.txt cmake_minimum_required (VERSION 3.15 FATAL_ERROR) cmake_policy(SET ...
hertzsprung's user avatar
  • 9,714
0 votes
2 answers
508 views

lnk2001 error in VS trying to use the Bullet physics library

I'm new to C++, Visual Studio (2019) and Bullet (2.89). I've been tying to build the Hello_World.cpp from Bullet for the past few days but I'm stuck on these 5 linking errors: 1>Hello_World.obj : ...
Lieven Petersen's user avatar
0 votes
1 answer
523 views

Undefined reference to functions while linking to static library

I'm including X.a static library to my code and X.a requires a.so library , so do I need to include X.a only or do I need to include both libaries to my code? I have tried including the only X.a for ...
mahesh hegde's user avatar
0 votes
1 answer
492 views

Linking with a static library [duplicate]

I am having trouble in linking with a static library I created. Here is my directory structure: test ├── b.c ├── b.o ├── i.h ├── libb.a └── t └── a.c Here is the content of each file: i.h: #...
babon's user avatar
  • 3,645
4 votes
4 answers
6k views

Linking SDL2/SD2_image statically with CMake

I'm trying to add SDL2 as a library to my project. I want to link it statically. I'm new to c++. 1 - Why does the SDL website recommend linking dynamically whenever possible? I understand the ...
frankelot's user avatar
  • 14k
-2 votes
1 answer
626 views

Creating a static binary with size less than 1MiB that can download a file from S3 or GCS

I understand that the question might look too specific, but I think the answers can also be useful for other areas. The real problem I'm having: Given an arbitrary container image that has sh binary, ...
Ark-kun's user avatar
  • 6,551
0 votes
1 answer
745 views

Static libraries in Qt 5.14 MinGW toolchain? (default Qt installation)

Just now I noted that the MinGW Toolchain that comes with the default Qt installation, at least Qt 5.14, comes with a lib directory with libQt5*.a files. Are those files static libraries? I think so ...
lateus's user avatar
  • 381
0 votes
1 answer
405 views

Mac OS Static vs Dynamic Linking having same size of executable

There is a c++ library, against which I tried linking both statically and dynamically. I generated the .so file and installed at a path, properly setting the install_name, LIBRARY_PATH and ...
zephyr0110's user avatar
5 votes
0 answers
852 views

rust-lld relocation R_X86_64_32S out of range

I'm trying to linking some code to 0xffff800000000000 but i'm getting the error 'relocation R_X86_64_32S out of range'. I'm linking 64bit code and using '-C relocation-model=large -C code-model=static'...
William Taylor's user avatar
1 vote
1 answer
952 views

__declspec(dllexport) static linked libraries to dll

I have a simple project setup for an OpenGL-project for University. An API project where every library I want to use (GLEW, GLFW, GLM) is linked statically. These libraries should be combined with my ...
Kaskorian's user avatar
  • 446
0 votes
1 answer
792 views

How to make CMake or OpenCV link statically [cross compilation Linux -> Windows]

I want to build a statically, because I need to distribute the application on multiple platforms (Linux and Windows). OpenCV has been built and installed on a linux machine statically. Here you can ...
GRASBOCK's user avatar
  • 691
-1 votes
1 answer
194 views

Organizing static libraries for a C++ desktop app

My C++ desktop app is an exe which is linked to a dozen static libraries (.lib files) and uses MFC in a static library. The total size of a debug build of the exe is 25 Mb. I'm adding a new feature ...
Brainless's user avatar
  • 1,602

1
5 6
7
8 9
37