'Compiling a C++ program with g++
I am having issues compiling my C++ program on g++ on Windows. My program is comprised of of the following files: one cpp file, two header files, and an asm file in MASM format. I tried using the following command to compile the x64 PE file:
g++ test.asm test.cpp -o test.exe
I am getting the following exception: file format not recognized; treating as linker script.
Could someone point me in the right direction? Thanks in advance!
Solution 1:[1]
There are different dialects of assembler. MSVC uses MASM while GCC uses GAS.
If your .asm file's format isn't understood by GCC try a different assembler like JWasm, UASM, SASM or NASM to compile it to COFF object file (e.g. jwasm -coff -win64 test.asm -Fo test.o) and then use GCC to link your C++ program with it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Brecht Sanders |
