title: Include an assembly *.o file into a Qt C++ project
body: <p>I have a Qt C++ Project. </p>
  
  <p><strong>System</strong><br>
  Windows XP<br>
  QtCreator and QtSDK newest<br>
  C++<br>
  MinGW/gcc/g++  </p>
  
  <p>For performance reasons I need some functions to be done in assembly. My Project is mainly Qt and c++ but I need to link my C++ code to some assembly I wrote. I have an assembly *.o file but I can't access my assembly function from my c++ code. I complied the assembly calc.o file with nasm.</p>
  
  <p>Simplified example.</p>
  
  <p><strong>PRO FILE</strong></p>
  
  <pre><code>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
  </code></pre>
  
  <p><strong>MAIN.CPP</strong></p>
  
  <pre><code>#include &lt;QtCore/QCoreApplication&gt;
  #include &lt;QTextStream&gt;
  
  extern "C" int five();
  
  int main(int argc, char *argv[])
  {
      QCoreApplication a(argc, argv);
      QTextStream qout(stdout);
  
      int f = five();
  
      qout &lt;&lt; "five: " &lt;&lt; f &lt;&lt; endl;
  
      return a.exec();
  }
  </code></pre>
  
  <p><strong>ERROR</strong>  </p>
  
  <pre><code>main.cpp:11: undefined reference to `five'
  collect2: ld returned 1 exit status
  </code></pre>
  
  <hr>
  
  <p><strong>TRY #1 - Karlphillip's way (Does not work on Windows)</strong></p>
  
  <pre><code> Directory of C:\x
  
  16/03/2012  03:09 PM    &lt;DIR&gt;          .
  16/03/2012  03:09 PM    &lt;DIR&gt;          ..
  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&gt;qmake
  
  C:\x&gt;make
  'make' is not recognized as an internal or external command,
  operable program or batch file.
  
  C:\x&gt;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
  </code></pre>