static-linking

Linking error: selective static linking of libm.a in GCC

浪尽此生 提交于 2021-02-19 03:52:28
问题 I want to selectively link libm.a statically, all the other libraries ( libc.so included) dinamically. But if I use the math functions from math.h , it almost always fails to link correctly. Why? And why does it work sometimes? (For example if I only use sqrt , fabs or, strangely, tanh , it seems to link correctly) myscript.sh: #!/bin/bash for i in sqrt tanh sin tan do echo "-----$i----------" sed "s/ciao/$i/" prova.c >provat.c gcc provat.c -fno-builtin -l:libm.a [[ $? -eq 0 ]] && { echo -n "

gcc ld: method to determine link order of static libraries

天大地大妈咪最大 提交于 2021-02-18 11:57:33
问题 My executables are linked with many static libraries, typically between 50 and 100 archives on Linux. Occasionally there are dependency cycles in these archives. The order that these libraries appear on the link command line is significant, see here. Attempting to manually order this many libraries is time-consuming at minimum, especially when there are cycles present. Question: is there a utility or technique that will analyze a code base and produce a correct link command line ordering? 回答1

How to clone, build, and link g2o framework in C++

血红的双手。 提交于 2021-02-11 06:25:42
问题 I want to use g2o library in my C++11 project on Ubuntu 18.04, but I cannot make build working. I have all the dependencies. But I cannot link g2o library to my project via CMakeLists.txt I am a newbie in C++ dependencies. I've tried cloning https://github.com/RainerKuemmerle/g2o repository and building it with cmake. The structure is as following: MY_PROJECT |__ cmake_modules |__ project_src |__ CMakeLists.txt |__ Thirdparty |____ g2o |____ bin |____ build |____ cmake_modules # findG2O.cmake

How to clone, build, and link g2o framework in C++

北慕城南 提交于 2021-02-11 06:23:16
问题 I want to use g2o library in my C++11 project on Ubuntu 18.04, but I cannot make build working. I have all the dependencies. But I cannot link g2o library to my project via CMakeLists.txt I am a newbie in C++ dependencies. I've tried cloning https://github.com/RainerKuemmerle/g2o repository and building it with cmake. The structure is as following: MY_PROJECT |__ cmake_modules |__ project_src |__ CMakeLists.txt |__ Thirdparty |____ g2o |____ bin |____ build |____ cmake_modules # findG2O.cmake

Linking static libraries into shared: enum class in header -> relocation R_X86_64_PC32 against undefined symbol

北战南征 提交于 2021-02-10 05:19:50
问题 What I want to do I try to separate my code into modules, which are compiled as static libraries with the -fPIC option. Finally, they are to be linked into a shared library using --whole-archive , also compiled with -fPIC . For the whole compilation, I use CMake generated make files and C++17 with GCC8 ! Problem Trying to do so with GCC8 x86_64 and libstdc++_pic fails with: /usr/bin/x86_64-linux-gnu-ld: CMakeFiles/shirabeengine.dir/code/source/core/engine.cpp.o: relocation R_X86_64_PC32

Linking static libraries into shared: enum class in header -> relocation R_X86_64_PC32 against undefined symbol

不问归期 提交于 2021-02-10 05:19:29
问题 What I want to do I try to separate my code into modules, which are compiled as static libraries with the -fPIC option. Finally, they are to be linked into a shared library using --whole-archive , also compiled with -fPIC . For the whole compilation, I use CMake generated make files and C++17 with GCC8 ! Problem Trying to do so with GCC8 x86_64 and libstdc++_pic fails with: /usr/bin/x86_64-linux-gnu-ld: CMakeFiles/shirabeengine.dir/code/source/core/engine.cpp.o: relocation R_X86_64_PC32

Linking static libraries into shared: enum class in header -> relocation R_X86_64_PC32 against undefined symbol

旧城冷巷雨未停 提交于 2021-02-10 05:19:12
问题 What I want to do I try to separate my code into modules, which are compiled as static libraries with the -fPIC option. Finally, they are to be linked into a shared library using --whole-archive , also compiled with -fPIC . For the whole compilation, I use CMake generated make files and C++17 with GCC8 ! Problem Trying to do so with GCC8 x86_64 and libstdc++_pic fails with: /usr/bin/x86_64-linux-gnu-ld: CMakeFiles/shirabeengine.dir/code/source/core/engine.cpp.o: relocation R_X86_64_PC32

Build library libtorrent debian and link it to program c++

房东的猫 提交于 2021-02-05 06:41:08
问题 I always have problems when building libraries and linking them, so I hope someone can give me a hand. I downloaded libtorrent from here and I've built it like they explain here in the building with autotools section (skipping step 1). The building process was successfull I think, but when I did make check the output was: ============================================================================ Testsuite summary for libtorrent-rasterbar 1.0.5 ===============================================

Xcode 11: Building a static framework which includes other frameworks/libs into its binary in iOS

為{幸葍}努か 提交于 2021-01-29 18:26:48
问题 I have a framework target in Xcode 11.x to build a Dynamic framework with statically linking some 3rd party libraries using pod file. platform :ios, '9.0' #use_frameworks! target 'Framework' do pod 'DeviceUtil', '~> 2.0' end Now I have a requirement to build a Static framework, and for this I changed the "Mach-O' type to Static Library in 'Framework's' target build settings and able to create Static framework. The generated framework shows all architectures correctly (for architecture i386):

g++: create a shared library (.so) with static glibc?

我与影子孤独终老i 提交于 2021-01-29 10:32:17
问题 I'm trying to create a shared library (.so file) that will include its own copy of glibc and link to it statically. I am already linking to libgcc and libstdc++ statically using -static-libgcc -static-libstdc++ in addition to -shared -fPIC and it works great. What combination of flags do I need to set to link to the static version of glibc as well? I tried adding -static to the lot but got this error: /usr/bin/ld: /home/.../x86_64-unknown-linux-gnu/4.6.2/crtbeginT.o: relocation R_X86_64_32