hi all
i want to learn asm inlining using codeblocks+GCC(MinGW32) and i came across this problem.
this is my code:
#include <iostream>
#include <Windows.h>
#include <winuser.h>
char * msg = "Hello, World!\n";
char * wMsg = "Content of the window..";
char * wCaption = "Window title";
int main (){
std::cout << "before call" << "\n";
asm(
"movl _msg,%eax\n\t"
"pushl %eax\n\t"
"calll _printf\n\t"
"popl %eax\n\t"
"movl $0, %eax\n\t"
"movl _wCaption, %ebx\n\t"
"movl _wMsg, %ecx\n\t"
"movl $0, %edx\n\t"
"pushl %eax\n\t"
"pushl %ebx\n\t"
"pushl %ecx\n\t"
"pushl %edx\n\t"
"calll MessageBoxA\n\t"
"popl %edx\n\t"
"popl %ecx\n\t"
"popl %ebx\n\t"
"popl %eax\n\t"
);
std::cout << "after call" << "\n";
}
and when i want to compile, i get:
undefined reference to `MessageBoxA'
i
think its config related; because when using MinGW64, this below code compiles just fine:
#include <iostream>
char * msg = "Hello, World!\n";
char * wMsg = "Content of the window..";
char * const wCaption = "Window title";
char * const wCaption222 = "Window title";
int var = 0;
int main (){
std::cout << "before call" << "\n";
asm(
"movq $0, %%rcx\n\t"
"movq %2, %%rdx\n\t"
"movq %4, %%r8\n\t"
"movq $0, %%r9\n\t"
"callq MessageBoxA\n\t"
: "=r" (var)
: "r" (msg), "r" (wMsg) , "r" (wCaption), "r" (wCaption222)
: "cc");
std::cout << var << "\n";
std::cout << "after call" << "\n";
}
i used "msys2-x86_64" to install MinGW32 and 64 and then set the directories in code blocks (creating two compiler profiles); so i don't know if messed up anything or its MinGW32's fault.
What I have tried:
googling, including various headers