linker

Instruct CMake to use CXX and CXXFLAGS when driving link?

浪尽此生 提交于 2019-12-23 03:33:07
问题 We are catching link errors on Solaris with makefiles generated by CMake 3.6.2. In the testing below, we are using GCC and not SunCC. From the looks of it, CMake is applying our options inconsistently: Typical compile command [ 2%] Building CXX object CMakeFiles/cryptopp-object.dir/cpu.cpp.o /bin/c++ -fPIC -march=native -m64 -Wa,--divide -o CMakeFiles/cryptopp-object.dir/cryptlib.cpp.o -c /export/home/jwalton/cryptopp/cpu.cpp Abbreviated link command /bin/c++ CMakeFiles/cryptest.dir/bench1

Variable dissapears in binary which is available in static lib

拥有回忆 提交于 2019-12-23 03:27:30
问题 I have the problem mentioned. I create an object inside a static lib, it is there when I run nm on the static lib, but when i link the lib to a binary and run nm it has disappeared. I know this problem has been asked before, but I could not find any answers. It is important for me to be able to retain that variable in the binary because we are trying to implement version checks for static libs in a binary. Please help. Thank you. Example code follows: test.h #ifndef TEST_H #define TEST_H

Linking error “undefined reference” about boost static library during compiling

纵然是瞬间 提交于 2019-12-23 02:33:07
问题 I am trying to compile my C++ project on Linux x64 with boost libraries 1.57. This project is compiled with scons and I successfully compiled it on my Arch Linux, but this time failed on a Ubuntu machine. I added -lboost_coroutine flag for linking but the error "undefined reference" still existed. /usr/bin/g++ -o build/gcc.release/app -pthread -g build/gcc.release/src/han/unity/rpcx.o -lpthread -lz -lboost_coroutine -lboost_context -lboost_date_time build/gcc.release/src/han/unity/rpcx.o: In

How to force ld to use a static lib instead of shared lib?

一笑奈何 提交于 2019-12-23 01:53:23
问题 I am trying to build by source using the static version of the test library. I have both libtest.a and libtest.so available, so I am using the "-static" option. However, It looks like the gcc linker is also trying to search for static version the standard math library. Any idea what option I can use to link the shared versions of the standard libraries? g++ -static main.cpp -o a.out -L. -ltest Error: /usr/bin/ld: cannot find -lm 回答1: If you want to force the linker to use the static version

Linker error: undefined reference to `_fini'

泄露秘密 提交于 2019-12-23 01:45:31
问题 I am just getting strted with lpcXpresso for embedded system development. It uses a modifed Eclise as its IDE and an MCU C compiler and MCU linker. I imported some eisting code and had a few linker errors, which I soon sorted out. But the final one has me stumped: undefined reference to `_fini' I would expect that that means that some of my code calls a function called fini() - right? Except that I don't have one (admiteddly there is an InitialzeTracingSubsystem() ). And I don't believe that

Embed Python2 and Python3 interpreters, choose which one to use at runtime

假装没事ソ 提交于 2019-12-22 22:48:12
问题 Is there a good way to embed both a Python2 and a Python3 interpreter into a C program and then running either one or the other with the decision occurring at runtime? Here's an example attempt: Makefile: all: main main: main.c librun_in_py2.so librun_in_py3.so g++ main.c -lrun_in_py2 -lrun_in_py3 -L. -Wl,-rpath -Wl,$$ORIGIN -o main librun_in_py2.so: run_in_py2.c g++ $$(python2.7-config --cflags --ldflags) -shared -fPIC $< -o $@ librun_in_py3.so: run_in_py3.c g++ $$(python3.4-config --cflags

Dynamically link libgnat

只愿长相守 提交于 2019-12-22 22:17:03
问题 I'm trying to compile a very simple ADA code. Everything works like a charm but on one computer my executable is link dynamically to libgnat whereas on the other computer it's linked statically. In both cases I use gnatmake tool. Any idea why it's happening? Do you know a way to force GNAT to dynamically link libraries? 回答1: That would be the binder's -shared switch. If you are using project files, you can use: project Foo is ... package Binder is for Switches ("Ada") use ("-shared"); end

Xcode does not find C++ static library

可紊 提交于 2019-12-22 18:31:43
问题 So I had some issues with this before but I deleted my old question and updated it to this one. Here it goes: I want to use a C++ Library in my iOS Swift project. With the help of this community I compiled my library as a static library (.a file). Now I created a new project to test this and I did only the following steps : 1. Create new Swift Project 2. Under Build Phases -> Link Binary with Libraries add my library (like so) 3. Add a new C++ File without a header file and add a bridging

How to link to libc++ on /usr/local/lib?

孤街浪徒 提交于 2019-12-22 18:28:32
问题 I've tried to provide -L /usr/local/lib , tried -nostdinc++ , tried to set DYLD_LIBRARY_PATH and DYLD_FALLBACK_LIBRARY_PATH but otool aways gives me: otool -L sample sample: /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0) How to link to my custom compiled /usr/local/lib/libc++.dylib on OS X? Variations of compilation were upon basic clang++ -std=c++11 -stdlib=libc++ . 回答1: As you've

symbol versioning and dlsym

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-22 18:04:27
问题 I load the pthread library in my program using dlopen , and fetch handlers to pthread_create and pthread_join using dlsym . How can I ensure that both the handlers are of a compatible version? I do not care if the symbols are of new version or old versions. I just want that whatever pthread_create I use to work well with the pthread_join that I get. I know there is a dlvsym to which I can pass explicit version number, but I do not care about exact version numbers as I want my code to be