static-libraries

C++ Statically linked shared library

萝らか妹 提交于 2019-11-28 17:53:13
I have a shared library used by a another application beyond my control which requires *.so objects. My library makes use of sqlite3 which needs to be statically linked with it (I absolutely need a self-contained binary). When I try to compile and link my library: -fpic -flto -pthread -m64 -flto -static -shared I end up with the following error: /usr/bin/ld: /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.6.1/crtbeginT.o: relocation R_X86_64_32 against `__DTOR_END__' can not be used when making a shared object; recompile with -fPIC /usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.6.1/crtbeginT.o:

Combining static libraries

核能气质少年 提交于 2019-11-28 17:39:11
Suppose I have three C static libraries say libColor.a which depends on *libRGB.*a which in turn depends on libPixel.a . The library libColor.a is said to depend on library libRGB.a since there are some references in libColor.a to some of symbols defined in libRGB.a . How do I combine all the above libraries to a new libNewColor.a which is independent? Independent means the new library should have all symbols defined. So while linking I just need to give -lNewColor . The size of the new library should be minimal i.e it should not contain any symbols in libRGB.a which is not used by libColor.a

How to update our static library architecture for suporting arm64 Build?

青春壹個敷衍的年華 提交于 2019-11-28 17:36:27
Few days ago i create static-library (Universal) that work's fine with Xcode5.0 SDK7 . After Update Xcode5.1 with SDK7.1 that not work if i select simulator iPhone Retina(4-inch 64-bit) . Then i am going to update my lib with Bellow setting change. I do the same for three Target:- For sporting simulator as well as device i put Universal lib and in to this i run script this:- After this i Build Again lib and used as i done Before in to my project. But still getting same issue with iPhone Retina(4-inch 64-bit) Undefined symbols for architecture x86_64: So, My question is that is there any

Linking a shared library against a static library: must the static library be compiled differently than if an application were linking it?

浪尽此生 提交于 2019-11-28 17:30:31
At least on Linux and Solaris, static libraries are really just a bunch of compiled .o's tossed into one big file. When compiling a static library, usually the -fpic flag is ommited, so the generated code is position dependent. Now say my static library is B. I've built it and have the resulting .a file which is really just a glob of all of the position dependent .o files. Now I have a shared library I'd like to build, A, and I want it to statically link B. When I build A, naturally I'll use the -fpic flag to make the generated code position independent. But if I link against B, aren't I

Configuring Cocoapods with an existing static library and iOS application

試著忘記壹切 提交于 2019-11-28 16:00:32
I'm having trouble getting my workspace to compile correctly with Cocoapods. There are 3 projects in the workspace, each with their own target: libPods - Cocoapods static library with all the external dependencies libCommon - My static library where I keep all my shared code (base controllers, networking code, common UI, etc) myApp - My iOS application Both libCommon and myApp require the external dependencies from the libPods. Originally I thought it would work like this: libPods builds libCommon links against libPods and builds myApp links with libCommon and builds In this scenario libCommon

Linker doesn't use a default runtime library when linking together libraries only (no objects)

荒凉一梦 提交于 2019-11-28 14:35:40
I want the users to be able to re-link my Qt-using application to their own build of Qt, without being forced to rebuild all of the sources. This could be used for LGPL compliance, for example. To do this, I need to provide object files for all of my sources. To make it easy, using qmake, I've partitioned the project internally into: A static library project that contains objects for all of the source files, including the file that has int main(int, char**) . An application project that links the static library above with Qt. Qt may be either a static library or dynamic. There are no source

fopen$UNIX2003 fails inside external library

只谈情不闲聊 提交于 2019-11-28 13:58:12
I have an external static library (I have the source code as well) that uses 'fopen' to access files on the filesystem. The strange thing is that it always fails both on simulator and device when it tries to do so with EXE_BAD_ACCESS inside fopen$UNIX2003 (not in fopen , fopen is not even in the call stack when the exception is thrown. I've tried to use fopen directly myself with the same path/options and it works. So, first of all, is it possible that the library is somehow calling a different fopen implementation? If so, why, and most important how can I make it call the 'right' one? EDIT:

Static library link issue with Mac OS X: symbol(s) not found for architecture x86_64

怎甘沉沦 提交于 2019-11-28 12:38:35
I'm trying to generate a static library and link it with an execution binary. This is a library function: #include <stdio.h> int hello() { return 10; } With these commands, I could get a static library. gcc -c io.c ar -crv libio.a io.o With lip -info , I checked it is x86_64 architecture. ar> lipo -info libio.a input file libio.a is not a fat file Non-fat file: libio.a is architecture: x86_64 This is the main function that uses the library. #include <stdio.h> extern int hello(); int main(int argc, char *argv[]) { printf("%d", hello()); } However, when I link the object with the static library,

Statically link ncurses to program

戏子无情 提交于 2019-11-28 12:12:28
I'm having some problems statically linking ncurses to one of my programs Here's a really simple sample program: #include<ncurses.h> int main(){ initscr(); printw("Hello world\n"); refresh(); getch(); endwin(); return 0; } When I compile it with gcc -static -lncurses hello_curses.c -o curses I get these errors: /tmp/ccwHJ6o1.o: In function `main': curses_hello.c:(.text+0x5): undefined reference to `initscr' curses_hello.c:(.text+0x14): undefined reference to `printw' curses_hello.c:(.text+0x1b): undefined reference to `stdscr' curses_hello.c:(.text+0x20): undefined reference to `wrefresh'

How do I build an app for an old linux distribution, and avoid the FATAL: kernel too old error?

寵の児 提交于 2019-11-28 11:59:49
问题 I distribute a statically linked binary version of my application on linux. However, on systems with the 2.4 kernel, I get a segfault on startup, and the message: "FATAL: kernel too old." How can I easily get a version up and running with a 2.4 kernel? Some of the libraries I need aren't even available on old linux distributions circa 2003. Is there an apt-get install or something that will allow me to easily target older kernels? 回答1: The easiest way is to simply install VirtualBox (or