static-linking

linking OpenMP statically with GCC

拈花ヽ惹草 提交于 2019-12-10 17:47:06
问题 Given the following file print.cpp #include <stdio.h> int main() { printf("asdf\n"); } I can link this statically like this g++ -static print.cpp or like this g++ -static-libgcc -Wl,-Bstatic -lc print.cpp -o print But now let's add a little OpenMP and call the file print_omp.cpp #include <omp.h> #include <stdio.h> int main() { printf("%d\n", omp_get_num_threads()); } I can link this statically like this (I checked it with ldd ) g++ -fopenmp -static print_omp.cpp However, this does not work g+

linking error: undefined reference to icu_50::UnicodeString::UnicodeString()

谁说胖子不能爱 提交于 2019-12-10 17:16:41
问题 I am trying to compile my project where I've declared as class members some: icu::UnicodeString label; icu::UnicodeString tags; icu::UnicodeString domain; icu::UnicodeString data; After having included (yes it is found) #include <unicode/unistr.h> In my CMakeLists.txt it searches, finds and links with: icuuc icudata (libicuuc, libicudata) as the output suggests prior to throwing the errors: -o icarus -rdynamic -lPocoNet -lPocoUtil -lPocoXML -licuuc -licudata I have built and installed from

Limiting the scope of global symbols from linked objects

僤鯓⒐⒋嵵緔 提交于 2019-12-10 16:36:23
问题 I have a C library in an archive file, clib.a . I've written a C++ wrapper for it, cpp.o , and would like to use this as a static library: ar cTrvs cppwrap.a clib.a cpp.o Code which links to this won't be able to use the stuff from clib.a directly unless the correct header is included. However, if someone coincidentally creates an appropriate prototype -- e.g. void myCoincidentallyNamedGlobalFunction() -- I'm concerned which definition of myCoincidentallyNamedGlobalFunction will apply. Since

Same symbols in different libraries and linking order

有些话、适合烂在心里 提交于 2019-12-10 15:41:13
问题 I have 2 libraries: test.1 and test.2 . Both libraries contain a single global extern "C" void f(); function, with different implementations (just a cout for the test). I did the following test: Test 1 Dynamic linking: If I add libtest.1.so and then libtest.2.so in the makefile of the executable and then call f(); in main , libtest.1.so->f() is called. If I change the order in the makefile, libtest.2.so->f() is called Test 2 Static linking: Absolutely the same happens with static libraries

link libssh with static library (libssh.a)

狂风中的少年 提交于 2019-12-10 12:07:57
问题 I was trying to link my program with libssh static library. Following is my simple code copied from libssh tutorial: //sshtest.c #define LIBSSH_STATIC 1 #include <libssh/libssh.h> #include <stdlib.h> int main() { ssh_session my_ssh_session; my_ssh_session = ssh_new(); if (my_ssh_session == NULL) exit(-1); ssh_free(my_ssh_session); } I put library file libssh.a into the subdirectory libs/ Then compile it with command gcc sshtest.c -Llibs -lssh -o sshtest The output is bunch of undefined

How to compile SDL program and run it without DLL

一世执手 提交于 2019-12-10 10:54:24
问题 is it possible to compile SDL library program into exec and run it without having "sdl.dll"? for example let say i wrote sdl program and it works and everything but the thing is to run the program on windows, i need to have "sdl.dll" within the same folder or system folder. is it possible to compile it so that i can just take the exec with me without needing to have "sdl.dll" along with it? i am using visual studio 2010 express. 回答1: Typically the procedure for this kind of stuff is: Download

Cython static link with python runtime?

和自甴很熟 提交于 2019-12-09 12:41:24
问题 I have a Python script for python 2.7, say this: print("Hello World!") Next I turn this into C using: python cython.py --embed helloworld.py And then I try to compile it statically: gcc -IC:\Python27\include -LC:\Python27\libs helloworld.c -Wl,-Bstatic -lpython27 -Wl,-Bdynamic But gcc just creates a binary that uses the python27.dll runtime. How can I create a binary that statically links to the runtime? 回答1: If you are working from Linux or OS X, you can use my engine's builder tool, Schafer

Size difference between static and dynamic (debug) library and impact on final exe

孤人 提交于 2019-12-09 12:36:17
问题 I never put much thought into the size difference between a static library and a dynamic library until I downloaded pre-built libraries of boost today. I found that the static libraries of boost are much much bigger than the dynamic libraries. For example, the debug multi-threaded boost wave static library is 97.7 mb in size while the same library, but dynamic, is only 1.4 mb in size (including import library and dll)! That is a huge difference. Why is that? Second question, if I statically

Can Clang compile code with GCC compiled .a libs?

走远了吗. 提交于 2019-12-09 08:28:31
问题 I have my project currently compiling under gcc. It uses Boost, ZeroMQ as static .a libraries and some .so libraries like SDL. I want to go clang all the way but not right now. I wonder if it is possible to compile code that uses .a and .so libraries that were compiled under gcc with clang? 回答1: Yes, you usually can use clang with GCC compiled libraries (and vice versa, use gcc with CLANG compiled libraries), because in fact it is not compilation but linking which is relevant. You might be

Differences between static libraries and dynamic libraries ignoring how they are used by the linker/loader

喜夏-厌秋 提交于 2019-12-09 07:41:12
问题 I understand how static/dynamic libraries are used by the linker/loader. However why not have a single type of library file accompanied by compiler flags which indicate how the library should be linked (static vs dynamic)? By the simple fact that we do have static and dynamic libraries I presume these files have specific contents which enable static and dynamic linking respectively. Can someone throw some light on the differences between the contents of static and shared library files? 回答1: