Answer the question
In order to leave comments, you need to log in
Why is the definition not found when linking assembler and c++ objects?
There is the following c++ code (main.cpp file):
#include <iostream>
extern int _sub(int, int);
int main() {
std::cout << _sub(3, 15);
return 0;
}
section .text
global _sub
_sub:
mov rax, rcx
sub rax, rdx
ret
nasm -f elf64 -g sub_f.asm -o sub_f.o
g++ -c main.cpp -o main.o
g++ -o asm_test.exe main.o sub_f.o
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question