Can I bind .asm files containing x64 assembly code to my c++ project?
-
-
No it is not. Have you read the documentation carefully? It should look something like:
ASM_FILES += asm.s asm_cl.output = ${QMAKE_FILE_OUT} asm_cl.commands = ml /c /Cx /coff /Fo${QMAKE_FILE_OUT} ${QMAKE_FILE_NAME} asm_cl.input = ASM_FILES asm_cl.variable_out = OBJECTS QMAKE_EXTRA_COMPILERS += asm_cl
-
Hi,
I haven't tried it but did you add your assembler files to the
SOURCES
variable ? -
Sorry for late reply.
Yes, I think I did. But I don't think I've done it properly.
.pro:QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = test--- TEMPLATE = app DEFINES += QT_DEPRECATED_WARNINGS SOURCES += main.cpp\ mainwindow.cpp\ asm.o HEADERS += mainwindow.h FORMS += mainwindow.ui DISTFILES += \ asm.o LIBS += asm.o
.mainWindow.cpp:
//some code extern "C" __int64 assembly(); //some code void MainWindow::on_pushButton_clicked() { QString s = QString::number(assembly()); // compiling fails here ui->label_2->setText(s); }
asm.o:
.code assembly proc mov rax, 1 ret xor rax, rax assembly endp end
I get an error message stating that the object "assembly" cannot be found
-
What OS are you running ?
What compiler are you using ? -
@KratzKatz said in Can I bind .asm files containing x64 assembly code to my c++ project?:
Have you compiled your assembly file? You can't link text files ... Also this:
LIBS += asm.o
doesn't look right.
-
As I said, you have to compile the assembly file. For that to happen in QtCreator you need to add an extra compiler and after that add the resulting object files to the OBJECTS qmake variable, so the linker will put it all together. Your asm compiler for VS is called
ml
(see here - the second post - for a long explanation of what switches you might need). -
@kshegunov is this the right way?:
SOURCES += main.cpp\ mainwindow.cpp\ asm.s HEADERS += mainwindow.h FORMS += mainwindow.ui new_moc.output = moc_${QMAKE_FILE_BASE}.cpp new_moc.commands = moc ${QMAKE_FILE_NAME} -o ${QMAKE_FILE_OUT} new_moc.depend_command = g++ -E -M ${QMAKE_FILE_NAME} | sed "s,^.*: ,," new_moc.input = NEW_HEADERS QMAKE_EXTRA_COMPILERS += new_moc OBJECTS += asm.s input = asm.s output = asm.bin
But still no compilation. I do know how to compile assembly code to an .exe in VS, but I don't want to use it for GUI programming. But does this mean I can compile my assembly file with VS and link it to my QT project?
-
No it is not. Have you read the documentation carefully? It should look something like:
ASM_FILES += asm.s asm_cl.output = ${QMAKE_FILE_OUT} asm_cl.commands = ml /c /Cx /coff /Fo${QMAKE_FILE_OUT} ${QMAKE_FILE_NAME} asm_cl.input = ASM_FILES asm_cl.variable_out = OBJECTS QMAKE_EXTRA_COMPILERS += asm_cl