У меня есть проект Qt C ++.
Система
Windows XP
QtCreator и QtSDK новейшие
C ++
MinGW / gcc / g ++
Из соображений производительности мне нужно выполнить некоторые функции при сборке. Мой проект в основном Qt и c ++, но мне нужно связать мой код C ++ с какой-то сборкой, которую я написал. У меня есть файл сборки * .o, но я не могу получить доступ к своей функции сборки из моего кода C ++. Я собрал файл calc.o сборки с помощью nasm.
Упрощенный пример.
ПРОФИЛЬ
QT += core
QT -= gui
TARGET = Test_asm
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
LIBS += C:/Users/David/Test_asm/calc.o
SOURCES += main.cpp
main.cpp
#include <QtCore/QCoreApplication>
#include <QTextStream>
extern "C" int five();
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QTextStream qout(stdout);
int f = five();
qout << "five: " << f << endl;
return a.exec();
}
ОШИБКА
main.cpp:11: undefined reference to `five'
collect2: ld returned 1 exit status
TRY # 1 - путь Карлфиллипа (не работает в Windows)
Directory of C:\x
16/03/2012 03:09 PM <DIR> .
16/03/2012 03:09 PM <DIR> ..
16/03/2012 03:07 PM 82 calc.pro
16/03/2012 03:10 PM 178 calc.S
16/03/2012 03:10 PM 164 main.c
3 File(s) 424 bytes
2 Dir(s) 78,905,851,904 bytes free
C:\x>qmake
C:\x>make
'make' is not recognized as an internal or external command,
operable program or batch file.
C:\x>mingw32-make
mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/x'
gcc -c -g -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -I"..\QtSDK\Desktop\Qt\4.7.3\mi
ngw\mkspecs\default" -o debug\main.o main.c
gcc -c -g -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -I"..\QtSDK\Desktop\Qt\4.7.3\mi
ngw\mkspecs\default" -o debug\calc.o calc.S
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-rel
oc -Wl,-subsystem,console -mthreads -Wl -o debug\calc.exe debug/main.o debug/cal
c.o
debug/main.o: In function `main':
C:\x/main.c:9: undefined reference to `helloasm'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\calc.exe] Error 1
mingw32-make[1]: Leaving directory `C:/x'
mingw32-make: *** [debug] Error 2