dynamic-linking

`bash: ./a.out: No such file or directory` on running executable produced by `ld`

房东的猫 提交于 2019-11-28 00:54:57
问题 Here is a Hello World code in C: // a.c #include <stdio.h> int main() { printf("Hello world\n"); return 0; } I compile it as gcc a.c , which produces a.out as expected and ./a.out prints Hello world ... as expected. Now if I do the compile and link separately: gcc -c a.c; ld -lc a.o , it run the a.out produced as ./a.out I get the message: bash: ./a.out: No such file or directory I Googled that error and it seems that happens when the executable produced is a 32-bit ELF and the machine

How do I specify the linker path in Rust?

可紊 提交于 2019-11-27 23:07:59
I'm trying to link a Rust program with libsoundio . I'm using Windows and there's a GCC binary download available. I can link it like this if I put it in the same folder as my project: #[link(name = ":libsoundio-1.1.0/i686/libsoundio.a")] #[link(name = "ole32")] extern { fn soundio_version_string() -> *const c_char; } But I really want to specify #[link(name = "libsoundio")] or even #[link(name = "soundio")] , and then provide a linker path somewhere else. Where can I specify that path? I tried the rustc-link-search suggestion as follows: #[link(name = "libsoundio")] #[link(name = "ole32")]

Linking GLEW with CMake

ぃ、小莉子 提交于 2019-11-27 22:52:50
How can you link GLEW to a project with CMake? We've been trying to link GLEW to our project using CMake for at least 3 hours without any success so any help is accepted. I'm using the FindGLEW.cmake which comes with CMake 3.1.0 CMakeLists.txt find_package(GLEW REQUIRED) if (GLEW_FOUND) include_directories($(GLEW_INCLUDE_DIRS)) endif() Environment Variables I'm using MinGW w64 to compile the sources and we successfully linked GLFW and GLM just by copying the includes and libs to their respective folders, but after doing the same with GLEW, CMake still couldn't find it. Sorry if I wasn't clear

LD_PRELOAD only working for malloc, not free

爱⌒轻易说出口 提交于 2019-11-27 22:26:15
问题 I'm trying to interpose malloc/free/calloc/realloc etc with some interposers via LD_PRELOAD. In my small test, only malloc seems to be interposed, even though free is detected (see output). I'd expect the output to contain a line "NANO: free(x)" - but this line is missing. Given // compile with: gcc test.cc #include <stdio.h> #include <stdlib.h> int main(int argc, char* argv[]) { void* p = malloc(123); printf("HOST p=%p\n", p); free(p); } And // compile with: g++ -O2 -Wall -fPIC -ldl -o

Why does the PLT exist in addition to the GOT, instead of just using the GOT?

丶灬走出姿态 提交于 2019-11-27 21:36:12
I understand that in a typical ELF binary, functions get called through the Procedure Linkage Table (PLT). The PLT entry for a function usually contains a jump to a Global Offset Table (GOT) entry. This entry will first reference some code to load the actual function address into the GOT, and contain the actual function address after the first call (lazy binding). To be precise, before lazy binding the GOT entry points back into the PLT, to the instructions following the jump into the GOT. These instructions will usually jump to the head of the PLT, from where some binding routine gets called

Linking Rust application with a dynamic library not in the runtime linker search path

大憨熊 提交于 2019-11-27 20:54:58
I have a shared library that I'd like to dynamically link into several separate binary Cargo applications. I include its location in the linker using the -- -L /path/to/dir format and the application compiles correctly with the significant decrease in binary size I expect. However, when checking the generated binary using ldd , I get a message saying that the library couldn't be found: casey@Gilthar-II:~/bot4/backtester/target/release$ ldd backtester linux-vdso.so.1 => (0x00007ffc642f7000) libalgobot_util.so => not found If I add the library to the /lib/x86_64-linux-gnu directory, the

iOS is it a static or a dynamic framework?

落花浮王杯 提交于 2019-11-27 19:01:10
This might sound like a silly question but If you have a thirdParty.framework file, can you tell if it's static or dynamic? I mean, do they look different if you look inside? trojanfoe It can be either. Only iOS8+ will allow dynamic frameworks in the app bundle, however. The way to find out is to look in the .framework and use the file command on the main file: $ cd iOS/Crashlytics.framework $ ls -l total 9984 -rwxr-xr-x 1 andy staff 4710656 11 Sep 17:11 Crashlytics drwxr-xr-x 8 andy staff 272 11 Sep 17:11 Headers -rw-r--r-- 1 andy staff 1553 11 Sep 17:11 Info.plist drwxr-xr-x 3 andy staff 102

g++: In what order should static and dynamic libraries be linked?

烂漫一生 提交于 2019-11-27 18:33:48
Let's say we got a main executable called "my_app" and it uses several other libraries: 3 libraries are linked statically, and other 3 are linked dynamically. In which order should they be linked against "my_app"? But in which order should these be linked? Let's say we got libSA (as in Static A) which depends on libSB, and libSC which depends on libSB: libSA -> libSB -> libSC and three dynamic libraries: libDA -> libDB -> libDC ( libDA is the basic, libDC is the highest) in which order should these be linked? the basic one first or last? g++ ... -g libSA libSB libSC -lDA -lDB -lDC -o my_app

How do I do weak linking in Swift?

匆匆过客 提交于 2019-11-27 13:15:26
In Objective-C, if I wanted to use a specific class that's only present in a new version of iOS, I would do something like this: if( [UIBlurEffect class] ) { // do something with UIBlurEffect } else { // gracefully fallback to old behavior } However, the equivalent Swift: if UIBlurEffect.self != nil { let blur: UIBlurEffect = UIBlurEffect(...) // ... else { // ... } // also occurs with NSClassFromString("UIBlurEffect") doesn't have the same functionality. If run on an environment where NSNewFeature is available, everything is fine. But if the class isn't defined, I get a link error when

C++ application - should I use static or dynamic linking for the libraries?

[亡魂溺海] 提交于 2019-11-27 11:58:13
问题 I am going to start a new C++ project that will rely on a series of libraries, including part of the Boost libraries, the log4cxx or the google logging library - and as the project evolves other ones as well (which I can not yet anticipate). It will have to run on both 32 and 64 bit systems, most probably in a quite diverse Linux environment where I do not expect to have all the required libraries available nor su privileges. My question is, should I build my application by dynamically or