linker

clang++ 3.2 linker not finding C++ stdlib

被刻印的时光 ゝ 提交于 2021-01-27 03:50:39
问题 I've installed clang 3.2 on my Ubuntu 13.04 machine, and have compiled and built libc++, and everything is in place. However, when I try to link my (really simple) code, the linker reports that references to std::cout etc. are undefined. If anyone could advise me what I could do to solve this, I'd be very grateful -- I've tried everything I can think of. The commands and output are here: $ clang++ -v -stdlib=libc++ -lpthread -ldl sqlite3/sqlite3.o src/world.o -o bin/world Ubuntu clang version

How to link a project to two different versions of the same C static library?

扶醉桌前 提交于 2021-01-24 09:17:33
问题 I am working on a complex C ecosystem where different packages/libraries are developed by different people. I would like to create a new project named foobar . This project uses two libraries, the library foo and the library bar . Unfortunately, bar does not require the same version that foo requires. Both use say so there is a conflict. If all the packages are on Git with submodules, the foobar project cannot be built when cloned recursively because two say functions exist in different

Executing the assembly generated by Numba

帅比萌擦擦* 提交于 2021-01-22 05:04:42
问题 In a bizarre turn of events, I've ended up in the following predicament where I'm using the following Python code to write the assembly generated by Numba to a file: @jit(nopython=True, nogil=True) def six(): return 6 with open("six.asm", "w") as f: for k, v in six.inspect_asm().items(): f.write(v) The assembly code is successfully written to the file but I can't figure out how to execute it. I've tried the following: $ as -o six.o six.asm $ ld six.o -o six.bin $ chmod +x six.bin $ ./six.bin

Executing the assembly generated by Numba

断了今生、忘了曾经 提交于 2021-01-22 05:01:43
问题 In a bizarre turn of events, I've ended up in the following predicament where I'm using the following Python code to write the assembly generated by Numba to a file: @jit(nopython=True, nogil=True) def six(): return 6 with open("six.asm", "w") as f: for k, v in six.inspect_asm().items(): f.write(v) The assembly code is successfully written to the file but I can't figure out how to execute it. I've tried the following: $ as -o six.o six.asm $ ld six.o -o six.bin $ chmod +x six.bin $ ./six.bin

Correctly set Visual Studio linker flag /SUBSYSTEM in CMAKE

不问归期 提交于 2021-01-21 12:36:12
问题 I am trying to set up an old project using cmake and I would like to keep all flags the same as before. The old project generator has the linker flag /SUBSYSTEM with minimum subystem version number 5.01 set like this: /SUBSYSTEM:WINDOWS,"5.01" I tried the same in cmake by adding this: set_target_properties(mytarget PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS,\"5.01\"") However the result is wrong. Cmake seems to remove the (escaped) double quotes and places the linker flag to "Addition

How to get a pointer to a binary section in Mac OS X?

点点圈 提交于 2021-01-20 20:11:25
问题 I'm writing some code which stores some data structures in a special named binary section. These are all instances of the same struct which are scattered across many C files and are not within scope of each other. By placing them all in the named section I can iterate over all of them. This works perfectly with GCC and GNU ld. Fails on Mac OS X due to missing __start___mysection and __stop___mysection symbols. I guess llvm ld is not smart enough to provide them automatically. In GCC and GNU

ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

两盒软妹~` 提交于 2021-01-20 12:23:57
问题 I have to do a custom "vector" class in c++ as homework for my university but I'm struggling with the templates. I get this error after I change all the variables' types to the type template 'typename T'. The thing is that the compiler only points at the functions that are declared as "friend" functions. Namely (operators '==' and '<<') as seen from compiler's message: Undefined symbols for architecture x86_64: "operator==(Vector const&, Vector const&)", referenced from: _main in main.o

Why `-fvisibility-inlines-hidden` is not the default?

↘锁芯ラ 提交于 2021-01-18 06:30:30
问题 I am asking to see whether my understandings are correct. inline is a suggestion to C++ compiler for substituting a function whenever it sees better, therefore calling a procedure flagged as inlined from outside of a library shouldn't be reliable and they logically should be hidden by default, preventing others to call them as an update to a compiler or codebase can be change the decision (thus removal of the inline d function and ABI breakage?). However it seems that is not the default

Why `-fvisibility-inlines-hidden` is not the default?

送分小仙女□ 提交于 2021-01-18 06:28:06
问题 I am asking to see whether my understandings are correct. inline is a suggestion to C++ compiler for substituting a function whenever it sees better, therefore calling a procedure flagged as inlined from outside of a library shouldn't be reliable and they logically should be hidden by default, preventing others to call them as an update to a compiler or codebase can be change the decision (thus removal of the inline d function and ABI breakage?). However it seems that is not the default

what is segment 00 in my Linux executable program (64 bits)

让人想犯罪 __ 提交于 2021-01-03 09:41:31
问题 Here is a very simple assembly program, just return 12 after executed. $ cat a.asm global _start section .text _start: mov rax, 60 ; system call for exit mov rdi, 12 ; exit code 12 syscall It can be built and executed correctly: $ nasm -f elf64 a.asm && ld a.o && ./a.out || echo $? 12 But the size of a.out is big, it is more than 4k: $ wc -c a.out 4664 a.out I try to understand it by reading elf content: $ readelf -l a.out Elf file type is EXEC (Executable file) Entry point 0x401000 There are