Questions tagged [ld]

The ld (linker or loader) program combines object files, archive files and (references from) shared libraries, relocates their data and addresses together with symbol references. Linking is usually the final step of compiling a program.

2795 questions
1
vote
0 answers

How to determinate if d_ptr from ElfW(Dyn) from link_map is an address or offset (c/c++)?

I have a C++ program that reads link_map obtained from dlinfo(handle, RTLD_DI_LINKMAP, &link_map); where handle was obtained by dlopen(NULL, RTLD_LAZY); The program displays information about dynamic section for every library in link_map. I'm trying…
mojes
  • 11
  • 3
1
vote
3 answers

How to trace the need of a library when linking?

Quick version: why gcc is asking for a specific library? How to trace its dependency while executing gcc? Long version: I am trying to compile c++ code that uses opencv, which uses ffmpeg. Errors appear When…
Alejandro Silvestri
  • 3,706
  • 31
  • 43
1
vote
2 answers

How to link to an object with main in it?

I'd like to link an object file (.o file) with a main() to another object file that also has a main(). I'd like to ignore the main() in the second file, but use the main() in the second .o file. Is there a way to do so? Thanks.
user1424739
  • 11,937
  • 17
  • 63
  • 152
1
vote
0 answers

Linker Errors when Using Interface Libraries with Multiple Implementations

I am working moving a code base to cmake where depending on which executable is getting built different implementations of a particular library are needed. In some cases this is because the resultant executables have different…
Jon
  • 23
  • 4
1
vote
0 answers

Setting symbol to location counter inside output section in linker script

I want to set symbols to the start and end of a section, so a define my section like this: .mysec : { _mysec_start = .; *(.bss) *(COMMON) _mysec_end = .; } However, I get the same value for both start and end symbols which…
josecm
  • 413
  • 3
  • 15
1
vote
1 answer

Exclude dynamic dependencies from build command?

Let's suppose we have a library libutils.so: ldd libutils.so ... libdependency.so ... Let's further suppose that we need to build an application: g++ appliation.cpp -lutils -o application May we omit -ldependency in the above command or must we…
Alexey
  • 710
  • 3
  • 7
  • 19
1
vote
1 answer

Does gcc -static affect all provided libraries?

Does the gcc's option -static affect only one library that follows immediately or does it affect all libraries provided on command line? g++ -static -lutils1 -lutils2
Alexey
  • 710
  • 3
  • 7
  • 19
1
vote
1 answer

Cross-compile software for a root file system

I would like to cross-compile software (libdrm-armada) for an armhf architecture. I have the root file system (~/rootfs) which contains the shared objects needed. This file system will be flashed onto eMMC and runs on a custom device. Libdrm-armada…
Bayou
  • 3,293
  • 1
  • 9
  • 22
1
vote
2 answers

what can I do about GNU ld 'legacy __sync_synchronize' warning?

I have some C++ code that uses a local-scope, program-lifetime object, e.g. void testFunction(int arg) { static Tested tested(0); tested.use(arg); } which built fine with older versions of GCC. With GCC 8.2.0, I get a puzzling warning at link…
PypeBros
  • 2,607
  • 24
  • 37
1
vote
2 answers

Can't link to .so file on Mac with CMake

I'm working on a PHP 7 extension using Swig and am trying to link to libphp7.so. From my CMakeLists.txt file: find_library(php7_lib php7 PATHS "/usr/local/Cellar/php/7.3.0/lib/httpd/modules"…
Jason
  • 531
  • 6
  • 19
1
vote
1 answer

Does ldd reports all dependencies of a library?

Let's suppose we have a shared library named utils.so. It may contain undefined symbols. Suppose also that ldd reports that this library depends on some other libraries: $ ldd utils.so library1.so library2.so ... libraryN.so (Bt the way is…
Alexey
  • 710
  • 3
  • 7
  • 19
1
vote
0 answers

Problems and doubts when using gcc's -shared and -pie options

I want to generate a PIE file which can be executed normally and can be linked dynamically by other files, so I used gcc's -fPIE, -shared, and -pie options. But I meet some problems. I have 3 files as follows: $ cat add.c int add(int a, int b) { …
1
vote
1 answer

Missing framework is red and project still builds

I have a missing framework shown in red in a pod project. The project still builds for running when selecting "Generic iOS Device". However, if I remove the red framework then the project stops building and Xcode reports "Undefined symbols for…
bhartsb
  • 1,316
  • 14
  • 39
1
vote
1 answer

GCC (minGW - Windows 10) report that there is no reference to symbol defined in .o file when I'm trying to embed the binary into executable

creating .o file ld -r -b binary -o baked.o baked.txt λ nm baked.o 0000000f D _binary_baked_txt_end 0000000f A _binary_baked_txt_size 00000000 D _binary_baked_txt_start Code: #include #include extern char…
Caliban
  • 94
  • 4
1
vote
2 answers

Why does this VLC Media Player Build Fail?

When building VLC on Ubuntu 18 using the following configure invocation: First I obtain the source like so: % git clone git://git.videolan.org/vlc.git % cd vlc % ./bootstrap Then I build like so: make clean ./configure --disable-lua…
MrSynAckSter
  • 1,681
  • 1
  • 18
  • 34