简体   繁体   中英

XAudio2 in Qt Creator

I'm currently working on an audio project with XAudio2 and I've been using MSVC++ Express 2010. I wrote some basic functionalities, and I thought I'd try making a UI with Qt, so I followed the steps to be able to use Qt in my version of MSVC:

  • Download the Qt source code
  • Compile everything in MSVC with the cmd prompt
  • Create a Makefile project that uses qmake & nmake
  • Add the directories for the libs, includes, dlls in my project

And everything works fine.

Now, I would love to go the other way around and import my project into Qt Creator to use the Qt designer easily, and also because I would simply like to play with it and see if I like it.

So, I imported a simple console application I made using XAudio2, and I added the XAudio include path in the .pro:

INCLUDEPATH += "C:/Program Files/Microsoft DirectX SDK (June 2010)/Include"

The problem I get at compilation is:

main.obj:-1: error : LNK2019: unresolved external symbol __imp__CoInitializeEx@8 referenced in function _main
File not found: main.obj

The file is right there though, the compilation creates it:

C:\Qt\qtcreator-2.2.1\projects\test-build-desktop\debug

and I have no idea why Creator can't find it... Any ideas? Is it a libraby I need to include that would be automatically included when I worked in MSVC?

Well, I found my answer, but it was a hard one. So, 8 hours later, here it is. CoInitializeEx initializes a COM library for use by the calling thread, and some other stuff...

CoInitializeEx Function Reference

The following link explains how to use COM objects with Qt.

Using COM objects in Qt

Basically, you add

CONFIG += qaxcontainer

to your .pro file

Also, for some reason, even though it has nothing to do with this, I had to use jom because nmake wouldn't work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM