ld

Extracting archive file in linker script

ぐ巨炮叔叔 提交于 2021-02-19 06:47:06
问题 I am trying to deal with a problem like the following one: Assume that I have a library libxyz.a created from: /* main.c */ int main(void) { int a; } compiled and archived with: gcc -c main.c -o abc.o && ar cr libxyz.a abc.o How do I have to write linker script in order to put abc.o exactly where it is expected to be? I was trying to handle it in such way: /* script.ld */ SEARCH_DIR(.) INPUT(-lxyz) SECTIONS { .text : { xyz:abc(.text) } .data : { xyz:abc(.data) } .bss : { xyz:abc(.bss) } } but

Reason and solution for error -“/usr/bin/ld: cannot find -levent ”?

一曲冷凌霜 提交于 2021-02-19 03:36:27
问题 While compiling my program which is using libevent library I am using gcc option -levent. But I am getting this error - /usr/bin/ld: cannot find -levent I do not have libevent on my system so I am statically linking to it while compiling using gcc -o Hello -static -I libevent-1.4.12-stable/ hello.c -levent How can i resolve this? Thanks in advance! 回答1: Where is the libevent.(a|so) file on your system? If it isn't on your system's library path then you will have to add a -L option adding its

Linking with another start-up file

你说的曾经没有我的故事 提交于 2021-02-19 02:37:09
问题 I am trying to link a program with my own start-up file by using the STARTUP directive in a LD script: ... ENTRY(_start) STARTUP(my_crt1.o) ... GCC driver is used to link the program (not to bother with library paths like libgcc, etc.): gcc -T my_script.ld ... Unfortunately, it only works with a GCC compiled for powerpc targets, while arm or i686 targets don't and still include crt0.o in collect2. For example: arm-eabi-g++ -v -T my_script.ld ... gives me: collect2 ... /opt/lib/gcc/arm-eabi/4

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

Anaconda install pyipopt: libipopt.so.1

瘦欲@ 提交于 2021-02-11 15:52:35
问题 I'm completely new to Python and most aspects of compiling C. My default python interpreter is the anaconda interpreter for python 2.7. I'm trying to install pyipopt following these instructions: https://github.com/xuy/pyipopt. Pyipopt installed to /usr/local/lib/python2.7/dist-packages/pyipopt , but when I try import pyipopt I get an error saying that pyipopt wasn't found. I then tried copying the installed folder into Anaconda's pkgs folder. At first it said Error: import pyipopt

Anaconda install pyipopt: libipopt.so.1

大憨熊 提交于 2021-02-11 15:52:07
问题 I'm completely new to Python and most aspects of compiling C. My default python interpreter is the anaconda interpreter for python 2.7. I'm trying to install pyipopt following these instructions: https://github.com/xuy/pyipopt. Pyipopt installed to /usr/local/lib/python2.7/dist-packages/pyipopt , but when I try import pyipopt I get an error saying that pyipopt wasn't found. I then tried copying the installed folder into Anaconda's pkgs folder. At first it said Error: import pyipopt

How to support dynamic plugins when statically linking in standard libraries?

大城市里の小女人 提交于 2021-02-10 05:40:50
问题 Suppose an application myapp.exe is built using g++ and it uses the flag -static-libstdc++ so that it can be installed in enviroments without libstdc++.so . myapp.exe also adds plugin support for some function plugf that can be dynamically loading via dlopen from a shard library. If libplug.so is such a plugin library that also links to libstdc++ , how can it do so in a way to be able to work with myapp.exe ? This is straightforward if libstdc++ is linked in dynamically since both myapp.exe

How to support dynamic plugins when statically linking in standard libraries?

让人想犯罪 __ 提交于 2021-02-10 05:39:17
问题 Suppose an application myapp.exe is built using g++ and it uses the flag -static-libstdc++ so that it can be installed in enviroments without libstdc++.so . myapp.exe also adds plugin support for some function plugf that can be dynamically loading via dlopen from a shard library. If libplug.so is such a plugin library that also links to libstdc++ , how can it do so in a way to be able to work with myapp.exe ? This is straightforward if libstdc++ is linked in dynamically since both myapp.exe

How can I link dynamically to glibc in Ubuntu

十年热恋 提交于 2021-02-10 05:02:36
问题 I am trying to assemble and link this tiny x86 assembly code in Linux (Ubuntu 18.04 LTS): ;hello.asm global _start extern scanf, printf, exit section .data read_name db '%255s', 0 msg db 'Hello, %s', 0 section .text _start: sub esp, 256 push esp push read_name call scanf add esp, 8 push esp push msg call printf add esp, 264 push dword 0 call exit I am using nasm to assemble and ld to link. As you can probably tell, the code uses C functions, so it has to be linked to glibc . Since my code is

How can I link dynamically to glibc in Ubuntu

百般思念 提交于 2021-02-10 05:00:33
问题 I am trying to assemble and link this tiny x86 assembly code in Linux (Ubuntu 18.04 LTS): ;hello.asm global _start extern scanf, printf, exit section .data read_name db '%255s', 0 msg db 'Hello, %s', 0 section .text _start: sub esp, 256 push esp push read_name call scanf add esp, 8 push esp push msg call printf add esp, 264 push dword 0 call exit I am using nasm to assemble and ld to link. As you can probably tell, the code uses C functions, so it has to be linked to glibc . Since my code is