dynamic-linking

Telling gcc directly to link a library statically

半城伤御伤魂 提交于 2019-11-26 12:03:21
It feels strange to me to use -Wl,-Bstatic in order to tell gcc which libraries I want to link with statically. After all I'm telling gcc directly all other information about linking with libraries ( -Ldir , -llibname ). Is it possible to tell the gcc driver directly which libraries should be linked statically? Clarification: I know that if a certain library exists only in static versions it'll use it without -Wl,-Bstatic , but I want to imply gcc to prefer the static library. I also know that specifying the library file directly would link with it, but I prefer to keep the semantic for

MySQL Improperly Configured Reason: unsafe use of relative path

醉酒当歌 提交于 2019-11-26 10:31:42
问题 I\'m using Django, and when I run python manage.py runserver I receive the following error: ImproperlyConfigured: Error loading MySQLdb module: dlopen(/Library/Python/2.7/site-packages/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib Referenced from: /Library/Python/2.7/site-packages/_mysql.so Reason: unsafe use of relative rpath libmysqlclient.18.dylib in /Library/Python/2.7/site-packages/_mysql.so with restricted binary I\'m not entirely sure how to fix this. I have installed

dlopen from memory?

南楼画角 提交于 2019-11-26 07:34:58
问题 I\'m looking for a way to load generated object code directly from memory. I understand that if I write it to a file, I can call dlopen to dynamically load its symbols and link them. However, this seems a bit of a roundabout way, considering that it starts off in memory, is written to disk, and then is reloaded in memory by dlopen. I\'m wondering if there is some way to dynamically link object code that exists in memory. From what I can tell there might be a few different ways to do this:

Is it OK to use DYLD_LIBRARY_PATH on Mac OS X? And, what's the dynamic library search algorithm with it?

蹲街弑〆低调 提交于 2019-11-26 06:05:44
问题 I read some articles discouraging of the use of DYLD_LIBRARY_PATH, as the the path of dynamic library should be fixed using -install_name, @rpath, and @loader_path. In terms of making a program that runs both on Linux and Mac OS X, DYLD_LIBRARY_PATH of Mac OS X does exactly what LD_LIBRARY_PATH of Linux. And, we can share (almost) the same make file that doesn\'t have the -install_name and @rpath. Is this OK to use DYLD_LIBRARY_PATH on Mac OS X? What\'s the dynamic library search algorithm

Force GCC to notify about undefined references in shared libraries

被刻印的时光 ゝ 提交于 2019-11-26 05:25:33
问题 I have a shared library that is linked with another (third-party) shared library. My shared library is then loaded using dlopen in my application. All this works fine (assuming files are in the proper path etc). Now, the problem is that I don\'t even need to specify to link against the third-party shared library when I link my library. GCC accept it without reporting errors about undefined references. So, the question; how can I force GCC to notify me about undefined references ? If I change

Telling gcc directly to link a library statically

二次信任 提交于 2019-11-26 03:35:28
问题 It feels strange to me to use -Wl,-Bstatic in order to tell gcc which libraries I want to link with statically. After all I\'m telling gcc directly all other information about linking with libraries ( -Ldir , -llibname ). Is it possible to tell the gcc driver directly which libraries should be linked statically? Clarification: I know that if a certain library exists only in static versions it\'ll use it without -Wl,-Bstatic , but I want to imply gcc to prefer the static library. I also know

Call Go functions from C

时光怂恿深爱的人放手 提交于 2019-11-26 03:03:38
问题 I am trying to create a static object written in Go to interface with a C program (say, a kernel module or something). I have found documentation on calling C functions from Go, but I haven\'t found much on how to go the other way. What I\'ve found is that it\'s possible, but complicated. Here is what I found: Blog post about callbacks between C and Go Cgo documentation Golang mailing list post Does anyone have experience with this? In short, I\'m trying to create a PAM module written

What do linkers do?

最后都变了- 提交于 2019-11-26 02:40:35
问题 I\'ve always wondered. I know that compilers convert the code you write into binaries but what do linkers do? They\'ve always been a mystery to me. I roughly understand what \'linking\' is. It is when references to libraries and frameworks are added to the binary. I don\'t understand anything beyond that. For me it \"just works\". I also understand the basics of dynamic linking but nothing too deep. Could someone explain the terms? 回答1: To understand linkers, it helps to first understand what

Overriding 'malloc' using the LD_PRELOAD mechanism

[亡魂溺海] 提交于 2019-11-26 02:07:08
问题 This question was migrated from Software Engineering Stack Exchange because it can be answered on Stack Overflow. Migrated 8 years ago . I\'m trying to write a simple shared library that would log malloc calls to stderr (a sort of \'mtrace\' if you will). However, this is not working. Here\'s what I do: /* mtrace.c */ #include <dlfcn.h> #include <stdio.h> static void* (*real_malloc)(size_t); void *malloc(size_t size) { void *p = NULL; fprintf(stderr, \"malloc(%d) = \", size); p = real_malloc

When to use dynamic vs. static libraries

纵饮孤独 提交于 2019-11-26 01:47:53
问题 When creating a class library in C++, you can choose between dynamic ( .dll , .so ) and static ( .lib , .a ) libraries. What is the difference between them and when is it appropriate to use which? 回答1: Static libraries increase the size of the code in your binary. They're always loaded and whatever version of the code you compiled with is the version of the code that will run. Dynamic libraries are stored and versioned separately. It's possible for a version of the dynamic library to be