shared-libraries

What are .a and .so files?

会有一股神秘感。 提交于 2019-11-26 19:10:57
I'm currently trying to port a C application to AIX and am getting confused. What are .a and .so files and how are they used when building/running an application? Archive libraries (.a) are statically linked i.e when you compile your program with -c option in gcc. So, if there's any change in library, you need to compile and build your code again. The advantage of .so (shared object) over .a library is that they are linked during the runtime i.e. after creation of your .o file -o option in gcc. So, if there's any change in .so file, you don't need to recompile your main program. But make sure

How do I create a dynamic library (dylib) with Xcode?

江枫思渺然 提交于 2019-11-26 18:58:27
问题 I'm building few command-line utilities in Xcode (plain C, no Cocoa). I want all of them to use my customized version of libpng, and I want to save space by sharing one copy of the library among all executables (I don't mind re-distributing .dylib with them). Do I need to do some magic to get libpng export symbols? Does "Link Binary With Libraries" build phase link statically? Apple's docs mention loading of libraries at run time with dlopen , but how I can make Xcode create executable

Why am I getting a gcc “undefined reference” error trying to create shared objects?

馋奶兔 提交于 2019-11-26 18:56:05
Why am I getting an "undefined reference" error using gcc? I am trying to create a shared object (.so) that exports one function, "external()". I then try to link against the .so but get "undefined reference 'external'". What am I doing wrong here? File: external.c int external() { return 5; } File: program.c int external(); int main(char** argv, int* argc) { return external(); } Commands: $ gcc -fPIC -c external.c $ gcc -shared -o libexternal.so external.o $ gcc -L. -lexternal -o program program.c /tmp/cc3MmhAE.o: In function `main': program.c:(.text+0x7): undefined reference to `external'

Easy check for unresolved symbols in shared libraries?

ε祈祈猫儿з 提交于 2019-11-26 18:53:26
问题 I am writing a fairly large C++ shared-object library, and have run into a small issue that makes debugging a pain: If I define a function/method in a header file, and forget to create a stub for it (during development), since I am building as a shared object library rather than an executable, no errors appear at compile-time telling me I have forgotten to implement that function. The only way I find out something is wrong is at runtime, when eventually an application linking against this

Compilation fails with “relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object”

泪湿孤枕 提交于 2019-11-26 18:43:57
I'm trying to compile this source code from the makefile in a VPS, but its not working. The VPS is a 64 Cent OS Here's the full error # make gcc -c -O3 -w -DLINUX -I../SDK/amx/ ../SDK/amx/*.c g++ -c -O3 -w -DLINUX -I../SDK/amx/ ../SDK/*.cpp g++ -c -O3 -w -DLINUX -I../SDK/amx/ *.cpp g++ -O2 -fshort-wchar -shared -o "TCP_V1.so" *.o /usr/bin/ld: TCP-LINUX_V1.o: relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC TCP-LINUX_V1.o: could not read symbols: Bad value collect2: ld returned 1 exit status make: *** [all] Error 1 Here's my

How to check what shared libraries are loaded at run time for a given process?

偶尔善良 提交于 2019-11-26 18:35:54
Is there a way to check which libraries is a running process using? To be more specific, if a program loads some shared libraries using dlopen , then readelf or ldd is not going to show it. Is it possible at all to get that information from a running process? If yes, how? Other people are on the right track. Here are a couple ways. cat /proc/NNNN/maps | awk '{print $6}' | grep '\.so' | sort | uniq Or, with strace: strace CMD.... 2>&1 | grep '^open(".*\.so"' Both of these assume that shared libraries have ".so" somewhere in their paths, but you can modify that. The first one gives fairly pretty

Compile with older libc (version `GLIBC_2.14' not found)

谁说胖子不能爱 提交于 2019-11-26 17:45:01
问题 I have to compile a program on a current ubuntu (12.04). This program should then run on a cluster using CentOS with an older Kernel (2.6.18). I cannot compile on the cluster directly, unfortunately. If I just compile and copy the program without any changes I get the error message "kernel too old". The way I understood it, the reason for this is not so much the Kernel version, but the version of libc that was used for compilation. So I tried to compile my program dynamically linking the libc

TFS 2010 Branch Across Team Projects - Best Practices

我只是一个虾纸丫 提交于 2019-11-26 17:38:23
问题 I'm having issues understanding how to configure TFS according to best practices as provided by the TFS Ranger team. The issue is such: My company has several products which make use of a shared common code base. > $/Core > -> /Main/Source (Parent Branch) > > $/Product1 > -> /Main/Source > -> /Main/Source/Core/Source (Child Branch from $/Core) > -> /Main/Source/... > > $/Product2 > -> /Main/Source > -> /Main/Source/Core/Source (Child Branch from $/Core) > -> /Main/Source/... Therefore we have

Force GCC to notify about undefined references in shared libraries

蹲街弑〆低调 提交于 2019-11-26 17:23:53
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 my library to be (temporarily) an executable, I get undefined references (when not supplying the library

building a .so that is also an executable

会有一股神秘感。 提交于 2019-11-26 17:19:41
So everyone probably knows that glibc's /lib/libc.so.6 can be executed in the shell like a normal executable in which cases it prints its version information and exits. This is done via defining an entry point in the .so. For some cases it could be interesting to use this for other projects too. Unfortunately, the low-level entry point you can set by ld's -e option is a bit too low-level: the dynamic loader is not available so you cannot call any proper library functions. glibc for this reason implements the write() system call via a naked system call in this entry point. My question now is,