ld

let's analyse “collect2: ld returned 1 exit status”?

非 Y 不嫁゛ 提交于 2019-12-18 18:55:09
问题 I know this indicates a linker problem, mostly unresolved symbols. I know that to resolve that problem / to get rid of that errormessage, one would have to provide much more information. I know there is a lot of questions on resolving this problems on SO already. My questions aims at helping to understand make and ld, to find out what (and who) is trying to express what with this line. collect2: ld returned 1 exit status What does "collect2:" mean? Is it a step make invokes ? I can't find an

ld cannot find -l<library>

不问归期 提交于 2019-12-18 14:18:29
问题 I am having trouble installing pyipopt on ubuntu 12.04. During linking, I receive the error: /usr/bin/ld: cannot find -lcoinhsl Even though I know that this library is installed and the .so and .la files are available in /home/mostafa/MyBuilds/CoinIpopt/build/lib/ does anyone have a solution for this? below is the complete return of running setup.py build: root@ubuntu:~/MyBuilds/pyipopt# sudo python setup.py build running build running build_ext building 'pyipopt' extension gcc -pthread -fno

Compile a binary file for linking OSX

空扰寡人 提交于 2019-12-18 12:37:23
问题 I'm trying to compile a binary file into a MACH_O object file so that it can be linked it into a dylib. The dylib is written in c/c++. On linux the following command is used: ld -r -b binary -o foo.o foo.bin I have tried various option on OSX but to no avail: ld -r foo.bin -o foo.o gives: ld: warning: -arch not specified ld: warning: ignoring file foo.bin, file was built for unsupported file format which is not the architecture being linked (x86_64) An empty .o file is created ld -arch x86_64

Compile and add an object file from a binary with CMake

老子叫甜甜 提交于 2019-12-18 11:06:01
问题 I am writing an Excel file builder in C++. I have everything I need working, but I still rely on an external empty .xlsx file which I unzip, iterate through, and add data too as needed to create the final file. I want to remove this dependency by turning the .xlsx file into a binary blob in the .rodata section of my executable, by turning it first into an object file like so: $ ld -r -b binary -o template.o template.xlsx $ objcopy --rename-section .data=.rodata,alloc,load,readonly,data

How to create a statically linked position independent executable ELF in Linux?

坚强是说给别人听的谎言 提交于 2019-12-18 08:58:40
问题 I have a working position independent Linux freestanding x86_64 hello world: main.S .text .global _start _start: asm_main_after_prologue: /* Write */ mov $1, %rax /* syscall number */ mov $1, %rdi /* stdout */ lea msg(%rip), %rsi /* buffer */ mov $len, %rdx /* len */ syscall /* Exit */ mov $60, %rax /* syscall number */ mov $0, %rdi /* exit status */ syscall msg: .ascii "hello\n" len = . - msg which I can assemble and run with: as -o main.o main.S ld -o main.out main.o ./main.out Since it is

Linking error - gcc -lm

▼魔方 西西 提交于 2019-12-18 06:57:39
问题 Well, I think my problem is a little bit interesting and I want to understand what's happening in my Ubuntu box. I compiled and linked with gcc -lm -o useless useless.c the following useless piece of code: /*File useless.c*/ #include <stdio.h> #include <math.h> int main() { int sample = (int)(0.75 * 32768.0 * sin(2 * 3.14 * 440 * ((float) 1/44100))); return(0); } So far so good. But when I change to this: /*File useless.c*/ #include <stdio.h> #include <math.h> int main() { int freq = 440; int

Resolving circular dependencies by linking the same library twice?

匆匆过客 提交于 2019-12-18 05:27:13
问题 We have a code base broken up into static libraries. Unfortunately, the libraries have circular dependencies; e.g., libfoo.a depends on libbar.a and vice-versa. I know the "correct" way to handle this is to use the linker's --start-group and --end-group options, like so: g++ -o myApp -Wl,--start-group -lfoo -lbar -Wl,--end-group But in our existing Makefiles, the problem is typically handled like this: g++ -o myApp -lfoo -lbar -lfoo (Imagine this extended to ~20 libraries with complex

Override weak symbols in static library

二次信任 提交于 2019-12-18 04:49:05
问题 I want to make a static .a library for my project from multiple sources, some of them define weak functions and others implements them. Let's say as example I have : lib1.c : void defaultHandler() { for(;;); } void myHandler() __attribute__((weak, alias ("defaultHandler"))); lib2.c : void myHandler() { /* do my stuff here */ } Then I want to put them into one single library, so that it seems transparent for the end application $ ar -r libhandlers.a lib1.o lib2.o But there is now 2 symbols

ld warning: too many personality routines for compact unwind to encode

自闭症网瘾萝莉.ら 提交于 2019-12-18 04:35:14
问题 The linker for an iOS simulator target I have is reporting the following warning: ld: warning: too many personality routines for compact unwind to encode No line number is given, nor anything else that is actionable. Googling turned up some Apple open source code, but I'm not groking it. What does it mean and what can I do to address it? 回答1: I found some information in the C++ ABI for Itanium docs that sheds some light on what this means. The personality routine is the function in the C++

GCC: how to tell GCC to put the 'main' function at the start of the .text section?

二次信任 提交于 2019-12-18 04:17:13
问题 I've just started learning some ARM programming and I've got stuck in a slightly annoying problem. The toolchain I'm using to compile my sources is Sourcery CodeBench Lite 2013.05-23 (can be found here: https://sourcery.mentor.com/GNUToolchain/release2449) What I would need is to tell GCC or LD or OBJCOPY to put the compiled bytecode of the 'main' function at the beginning of the .text section. Is there any way to achieve this? (maybe through a linker script?) Thank you 回答1: Solved the