ld

Ld magically overrides statically linked symbols

假如想象 提交于 2019-12-21 05:07:22
问题 For a few days we are dealing with very strange problem. I can't understand how it even happens - when a third-party (MATLAB) program uses our shared library, it somehow overrides some of our symbols (boost, to be precise) with it's own. Those symbols are statically linked and (!!) local. Here is the deal - we use boost 1.47, MATLAB has boost 1.40. Currently, library call segfaults on a call from OUR library to their boost (regex). So, here is the magic: We have no library dependencies, ldd:

Using Go 1.5 buildmode=c-archive with net/http.Server linked from C

吃可爱长大的小学妹 提交于 2019-12-21 04:37:13
问题 The upcoming release of Go 1.5 comes with new buildmodes which allow for exporting Go symbols to be linked and called from C code. I've been playing around with it and got basic "Hello world" examples working, but now I'm trying to link a Go library which starts a net/http.Server and it's failing. The code looks like this (it's also available here): gohttplib.go: package main import "C" import "net/http" //export ListenAndServe func ListenAndServe(caddr *C.char) { addr := C.GoString(caddr)

Xcode: ld: library not found for -lAFNetworking

断了今生、忘了曾经 提交于 2019-12-20 09:57:23
问题 Because of this one reason, build always fails...Any ideas about what I could try? EDIT: the solution is to open the xcworkspace instead of the xcproject! 回答1: Might be you are opening .xcodeproj file after installing pods. Close the project and open .xcworkspace file. 回答2: Have the same issue. What I did with the help of https://premium.wpmudev.org/forums/topic/anybody-solved-this-linker-command-failed-with-exit-code-1 and Adlair Cerecedo-Mendez Delete the "Pods" project on the left panel of

How do I determine the fastest link order?

柔情痞子 提交于 2019-12-20 09:27:46
问题 I have about 50 different static libraries being linked into my c++ project and the linking takes on average 70s. I've found that moving around with the link order of the libraries changes this time. This is expected I guess if the linker doesn't have to keep searching for a set of symbols throughout the entire symbol table it has built upto that point. I suppose I could use "nm" to get a dependency graph between the static libraries. However, that would only give me one "correct" link order.

What's the difference between `-rpath-link` and `-L`?

余生颓废 提交于 2019-12-20 09:20:32
问题 The man for gold states: -L DIR, --library-path DIR Add directory to search path --rpath-link DIR Add DIR to link time shared library search path The man for bfd ld makes it sort of sound like -rpath-link is used for recursively included sos. ld.lld doesn't even list it as an argument. Could somebody clarify this situation for me? 回答1: Here is a demo, for GNU ld , of the difference between -L and -rpath-link - and for good measure, the difference between -rpath-link and -rpath . foo.c

Any difference between “-Wl,option” and “-Xlinker option” syntax for gcc

和自甴很熟 提交于 2019-12-20 09:11:50
问题 I have been looking through some configuration files and I've seen both being used (albeit on different architectures). If you're using gcc on a linux box is there any difference between the two syntax for passing options to the linker? Reading the gcc manual they are explained almost identical as far as I could tell. 回答1: I don't really know what else to do than look up man gcc , which you should keep in mind for future questions pertaining to gcc invocation. So: -Xlinker option Pass option

Is there a way to set the elf NEEDED field at link time?

倾然丶 夕夏残阳落幕 提交于 2019-12-20 05:11:36
问题 Given a executable such that: >objdump -x someprog | grep c++ NEEDED libstdc++.so.6 I want to change the requirement to the full version (including the minor version and patch level): >objdump -x someprog | grep c++ NEEDED libstdc++.so.6.0.22 I know of two ways to do this: create a dummy library as per this question (Forcing or preventing use of a particular minor version of libstdc++) use patchelf >patchelf --add-needed libstdc++.so.6.0.22 someprog >objdump -x someprog | grep c++ NEEDED

Is there a way to set the elf NEEDED field at link time?

耗尽温柔 提交于 2019-12-20 05:11:34
问题 Given a executable such that: >objdump -x someprog | grep c++ NEEDED libstdc++.so.6 I want to change the requirement to the full version (including the minor version and patch level): >objdump -x someprog | grep c++ NEEDED libstdc++.so.6.0.22 I know of two ways to do this: create a dummy library as per this question (Forcing or preventing use of a particular minor version of libstdc++) use patchelf >patchelf --add-needed libstdc++.so.6.0.22 someprog >objdump -x someprog | grep c++ NEEDED

Linking OpenCV 2.3 program in Mac OS X Lion: symbol(s) not found for architecture x86_64

血红的双手。 提交于 2019-12-20 04:19:43
问题 I'm having a problem when trying to compile the program in this tutorial from the OpenCV 2.3 official documentation. I have created the CMakeList.txt like it's said in the link. Well, it didn't work. After a good time searching Google and trying to fix it, I have added the correct lib and include folders to the OpenCVConfig.make (at /opt/local/share/opencv here). Well, this is the output when I try to make it: $ cmake . -- Configuring done -- Generating done -- Build files have been written

Manually specify remapping of specific linking symbols

旧城冷巷雨未停 提交于 2019-12-20 04:07:36
问题 Without modifying these two source files, is there a way to take the object files produced by compiling them, and convincing a linker to link foo in main_v1.c to bar in bar.c? main_v1.c void foo(void); int main(void) { foo(); } bar.c #include <stdio.h> void bar(void) { puts("bar()!"); } Modifying the object files themselves is fair game but assume that we might not even have the source code available. The platform is Linux. By insisting on a modest change to main_v1.c, and linking in an