1,820 questions
4
votes
2
answers
215
views
If I build a static-linked ELF binary from a Python project, can I run it on every Linux distribution?
I'm working on converting a Python package to a more efficient version by porting it from Python to C++ using pybind11.
The performances are really better, but now I have to distribute it.
It's an &...
3
votes
0
answers
101
views
Making an R module linking OpenBLAS statically
I am trying to build an R module linking statically OpenBLAS:
mypkg/
├── DESCRIPTION
├── NAMESPACE
├── R/
│ ├── check_openblas.R
│ ├── my_interface.R
│ └── openblas_init.R
├── inst/
│ └── libs/...
0
votes
0
answers
73
views
Should I build my cross-platform GUI app with static GTK or shared GTK? What are the trade-offs?
I'm building a cross-platform C application with a GTK-based GUI that performs cryptographic functions (like AES encryption/decryption using OpenSSL). I'm developing primarily on Windows using CLion ...
2
votes
1
answer
136
views
When are the dynamic/static libraries linked on compile, link, load or run time?
I found this question about the difference between .a and .so files
First Linking the dynamic libraries:
One answer says:
The advantage of .so (shared object) over .a library is that they are linked ...
-5
votes
2
answers
121
views
How to prototype winapi functions selectively in C [closed]
Is it possible to write winapi function prototypes in a C file
I know that it is possible, because the function prototype (CryptAcquireContextW above works to my delight
But I can't write VirtualLock ...
0
votes
0
answers
24
views
Link a precompiled binary in linux to make it static [duplicate]
If I have a ELF binary that has dynamic dependencies, are there any tools to perform ahead-of-time linking to create a static binary with no dependencies?
e.g.
$ ldd $(which tcpdump)
/lib/ld-...
0
votes
0
answers
24
views
C++: Function definitions are not found when I try to compile using MinGw in vscode [duplicate]
I'm trying to compile and debug my main.cpp code, with the header file of declarations ./include/linalg.hpp and the definitions in ./src/linalg.cpp, but I face the error below:
Executing task: ...
1
vote
2
answers
89
views
Statically linked pthread and terminate called after throwing an instance of 'std::system_error'
I have seen terminate called after throwing an instance of 'std::system_error' - and while I believe it talks about the similar underlying problem, the proposed solution there does not work in ...
0
votes
1
answer
54
views
Does Disaggregating Sections in an ELF File Impact Performance?
I am investigating whether disaggregating sections in a statically linked ELF file affects performance. Specifically, I have multiple statically linked libraries (e.g., lib1, lib2, lib3, lib4), and ...
-2
votes
1
answer
127
views
Removing library dependency in c++
I have lib2 that depends on for some small functionality on a large lib1. I want to deliver lib2 but not lib1 to a client that builds executables based on lib2. lib1 is only used for implementations ...
1
vote
1
answer
82
views
Cache Effects in Statically Compiled Binaries: Unexpected Cache Misses
I have a simple Hello World program written in C, which I statically compiled using: gcc -static -fno-pie -o hello{1|2} hello.c.
I expected that executing these two binaries would exhibit cache ...
0
votes
1
answer
164
views
How to link a Rust program with a full path to a static library?
I am using Rust in a Meson based build-system where I build a static library that I need to link to a Rust crate built with Cargo. Right-now I use this environment variable in my Cargo invocation:
'...
0
votes
0
answers
58
views
cmake export static lib and hide 3rd party libs [duplicate]
I am creating a static library lets call it X. This library uses rapidjson library in .cpp files. When I export this as static library, I want to hide rapidjson dependency. Another project should be ...
0
votes
1
answer
253
views
using a Rust library from existing C++ application in Visual Studio [duplicate]
I need some advice regarding the static linkage of a Rust library into C++ application.
I am able to correctly link a very easy code without Rust dependencies and I am also able to link the code (even ...
0
votes
0
answers
557
views
How to link C++ project statically to zstd.lib?
I have a VS2022 C++ project that uses zstd. Previously, it used zstd v1.5.2; I changed this to v1.5.6 (the current version). Now when I attempt to run the project, I get an error "The code ...
0
votes
1
answer
102
views
How can I link to a .a file in Visual Studio
I have an application that has been worked on for several decades and I was provided .h and .a files. My program is mainly in C/C++ and when I try to link to these .a files, I get:
Error LINK2019: ...
0
votes
0
answers
73
views
Right way to avoid multiple definition error when building Python C++ extension with MSVC BuildTools
A python C++ extension has the following structure:
/myextension
|_____basecode
| |__header.h
| |__functions.cpp
|
|_____utilities
| |______utilities.h
| |...
2
votes
1
answer
183
views
How to statically link MKL into a shared object?
My general task:
I have a Fortran Tool which uses the functions dgemm, dgemv, dgesvx and dsyev from the MKL Library. I need to compile my code as a shared object (.so) to make it work on a different ...
0
votes
1
answer
87
views
Crash in static i386 Linux exe
This simple testcase:
#include <unistd.h>
void _start(void) {
_exit(0);
}
crashes when run on Debian 12.6 i386.
Compiled with gcc -lc -nostdlib -static -Os. Note that this is on an ...
0
votes
1
answer
86
views
Why is linking a dynamic library against a static library apparently easy on Windows but on Linux `-fPIC` makes that difficult? [closed]
I am working on adapting an existing ODBC driver so that it can target Linux.
ODBC Drivers are generally distributed as DLLs on Windows and shared objects (.so) on Linux.
The driver depends on Boost. ...
0
votes
2
answers
141
views
How to configure my libraries and dependencies to compile my App as static
I am Programming an App with visual studio 2022, in c++, x64 with libraries installed with help of vcpkg. They are dynamic link libraries.
I want to use my App as static, to run it in another PC ...
1
vote
1
answer
87
views
Can static-libraries functions get inlined?
Can Static-libraries functions get inlined?
lets say I have these files
main.cpp
#include <lib/header.hpp>
int main() {
return lib::meaningoflife();
}
lib/header.hpp
namespace lib {
...
1
vote
0
answers
77
views
Flex Scanner continuously running after implementing steps from authoritative book
I'm on Linux Ubuntu.
I'm reimplementing the Flex scanner example provided at page 5 of "Managing projects with GNU make" by ROBERT MECKLENBURG.
count_words.c (application source code):
#...
0
votes
1
answer
191
views
Is it possible to build opencv statically under Linux without having problems with missing/incompatible libraries?
I'm trying to distribute an opencv binary on different Linux operating systems, but I've failed because of dependency problems.
What I'm aiming for is something similar to the opencv-python pip ...
0
votes
1
answer
287
views
attempting to link libc statically with clang, ldd showing dynamic linking?
I'd like to compile a C program with system libraries (such as libc) linked statically, with all my other custom libraries (such as openssl) linked dynamically. When I compile a "Hello World"...
1
vote
1
answer
251
views
Missing symbols when statically linking library with static dependencies
I have an executable (test) using a static library (A), which uses another static library (B). The file structure is as follow:
test: {
CMakeLists.txt,
main.cpp,
deps: {
A: {
...
1
vote
0
answers
113
views
Static link in .net looking for shared library
I'm trying to test this static linking example with .net in linux and keep getting the following exception;
System.DllNotFoundException: Unable to load shared library 'nativelib' or one of its ...
0
votes
1
answer
174
views
Use Go runtime with -buildmode=c-archive
Is it possible to have Go code use the Go runtime with this buildmode?
-buildmode=c-archive
I am building my Go code as a static library and linking it with .o files that were compiled from native ...
1
vote
0
answers
195
views
Paho Mqtt in Unreal Engine 5.3.2
I'm trying to create a plugin for Unreal Engine 5.3.2 for connecting to an mqtt broker in c++ and for that I need to use paho.mqtt.c and paho.mqtt.cpp. I built the 2 libraries with cmake. When I tried ...
0
votes
1
answer
270
views
How does Python consume DLL files without needing the import file (.lib)?
I just finished a tutorial on building a DLL library. From the tutorial I learnt that a DLL also has an associated lib file, which the linker will use to statically linked in information to the client ...
2
votes
0
answers
256
views
How to correctly compile git to a static binary with HTTPS support?
I need a git binary with https support in a distroless Docker image. I'm using musl C library and compiler - installed from Ubuntu repo - to statically compile git and all of its dependencies (libcurl,...
4
votes
1
answer
2k
views
How can I statically link a .lib file using mingw-w64
I'm trying to build an application and link it against the ffmpeg DLL's. However I want to build a static exe file.
I'm using MSYS2 and mingw-w64 (x86_64) with gcc version 13.2.0, when building this ...
0
votes
1
answer
417
views
Linking GLFW with a static library using Premake
I'm using Premake to manage the build configuration of my project, which consists of two static libraries ("Engine" and "Game") and an executable ("Launcher"). But when I ...
0
votes
1
answer
136
views
Conan: How to get the exact version of a statically linked library contained in a pre-built package?
I used the following command to get a list of pre-built packages for the libpng library:
conan download libpng/1.6.40 -p "arch=x86_64 AND os=Windows AND compiler=msvc AND compiler.version=192&...
0
votes
0
answers
454
views
undefined reference to `__mingw_vsscanf' while trying to link GLFW statically on VScode
I have been trying to set up my OpenGL, GLFW and glad project for some days now and have not been met with success. At first I was getting "undefined reference to 'glfwInit()'" while trying ...
1
vote
1
answer
139
views
How do I override location for dynamically linked libgcc_s?
I'm attempting to build an executable on a Debian Bookworm system to be run on Debian Bullseye.
I have downloaded and unpacked library packages for Bullseye in dedicated directories to link against.
...
0
votes
1
answer
206
views
Linker cannot find strnstr() on Ubuntu with libbsd
To port some existing code from FreeBSD to Ubuntu (22.04) with the libbsd-dev package installed, I am encountering a problem in the linking phase: undefined reference to 'strnstr'. Code:
#include <...
0
votes
1
answer
103
views
Compiling libR (from the R statistical package) as a standalone C library for java+jni
I'm trying to compile R as a static library with the -fPIC flag so I can use it within java+JNI (is it only possible ?), but I cannot find the right flags in '.configure' to compile R this way.
I ...
1
vote
1
answer
122
views
g++ - analogue to rust's build-std
I want to compile a C++ program so that it dynamically links to libc, but does not have a dynamic dependency on libstdc++. for example 'hello world' using std::cout, when compiled with the -static-...
1
vote
0
answers
202
views
Statically compile gcrypt
I've been bashing my head off this for a while now and am out of ideas.
What I want to do
I have an application written in C (on a linux platform) that has two main external dependencies. Raylib and ...
1
vote
1
answer
125
views
What exactly is static variable behaviour in multiple linkeage of a library that contains it in C++?
Lets imagine a scenario where I have
an executable (A),
a dll (B), and
a static library (C).
Both A and B are linking C and include its header files.
Now in C exist a class:
class Foo {
static ...
0
votes
0
answers
87
views
LNK2019 error when trying to use Stanford external C++ libraries in Visual Studio [duplicate]
I am new to C++ and trying to learn from online Stanford CS106B course.
In this course, people from Stanford have provided external C++ libraries (Link to which is given below).
I have downloaded this ...
3
votes
0
answers
122
views
Build Python as static library with won't include basic modules
I am trying to get the ultimate performance in my application based on python.
I am already using Cython and everything works compiling it in C++.
I am even able to pack everything with PyInstaller ...
1
vote
1
answer
268
views
What is the linux command that gives the paths to libraries for linking during c++ compilation?
I remember seeing some command that works like this:
g++ main.cpp `some_forgotten_command --some_forgotten_options some_library`
When the command is run, it will substitute the part enclosed by `` ...
0
votes
2
answers
996
views
Can't run my compiled c++ executable on another machine. Says "libcurl.dll not found"
I'm trying to statically link the libcurl library into my executable so I can run my executable on other machines without need of dll files since all the necessary files are baked inside my executable
...
1
vote
0
answers
37
views
build static curl executable from source [duplicate]
I'm trying to build a statically linked curl executable from source:
When I grep around1 the CMakeLists.txt, I find relevant flags:
$ git clone https://github.com/curl/curl.git
$ cd curl
$ grep -rn &...
0
votes
2
answers
45
views
Flask not detecting CSS file within 'static' folder
I've been trying to run a Flask program, however it is not detecting the style.css file within the static folder. The organization of my different directories are shown in this image here:
file ...
0
votes
0
answers
354
views
How can I statically link GL/gl.h and GL/glut.h to my C++ program, using G++
I am currently developing a little program, and faced an issue when I tried to run it on a clean Linux distribution: OpenGL freeglut3 was not installed by default. I faced the same issue when I ...
0
votes
0
answers
388
views
Build Python 3.12 statically
How can I build python 3.12 from source while statically linking at least libc but ideally all dependencies?
So far I have tried setting LDFLAGS="-static" before running the configure script ...
2
votes
1
answer
940
views
What is __dso_handle and why does it need to be defined for linking to work?
I was recently attempting to build some files in C and C++ for an AWS machine and received the linker error __dso_handle is not defined. This stymied me for some time as I reviewed several pieces that ...