Hi, I tried to write a function in assembly and got it to compile in nasm and I want to call on that function from c++.
I got the compilations to work... its just the linking that gives me undefined references.
Its just a test run before I want to start writing a few assembly stuff and linking them into c++.
I've written a simple test.cpp
#include <stdio.h>
#include <stdlib.h>
#include "assem.h"
int main()
{
int i = getFive();
printf("%d\n", i);
system("pause");
return 0;
}
Then I have a assem.h
#ifndef ASSEM_H
#define ASSEM_H
#ifdef __cplusplus
extern "C" {
#endif
int getFive();
#ifdef _cplusplus
}
#endif
#endif
Now I have assem.asm
section .data
section .text
global _getFive
_getFive:
mov eax, 5
ret
Then I've made a makefile but it basically does this:
g++ -c test.cpp -o test.o
nasm -fwin32 assem.asm -o assem.o
g++ test.o assem.o -o test.exe
Then I get an undefined reference to getFive()
Can anyone help me?
Thanks
[Edited by - Last Attacker on July 26, 2005 3:27:43 AM]