views:

537

answers:

3

Right now I have some libraries that link easily to Visual Studio projects but I can't figure out how to link them with Qt. My idea is to write a VS project that wraps the functionality I need from the libraries, then compile that to a library which can be linked to Qt. From my understanding, VS and Qt use compilers that create incompatibile libraries. My questions are:

  1. Can I modify VS or Qt in a way that I can compile a library in VS which can be linked to Qt?
  2. Is there a simpler solution to this problem?

The specific library I'm using is Nitro-Nitf. For my Qt project I'm using Qt Creator and for Visual Studio I'm using VS 2008.

+4  A: 

Yes, the Windows binaries provided by Qt are built using MinGW. If you build Qt from source using Visual Studio, then your libraries will be compatible.

Although I haven't tried it, Qt Creator 1.2 introduces support for MS compilers, so you should be able to continue to develop your Qt projects in Creator.

swongu
Thanks, this is probably what I'll end up doing. Does this apply to Qt Creator or just the Qt Libraries?
Graphics Noob
Just the Qt libraries. You should be able to use Qt Creator as-is.
swongu
+2  A: 

Qt is available as source code, you can build it with whatever toolchain you like. Visual Studio is an IDE (integrated development environment) that normally invokes the microsoft compiler (cl) and linker (ld), although you can configure a Visual Studio project file to do a makefile build, or IIRC, invoke any other program you like to do the build step (at my previous job, we built our Qt apps with cl and ld, and could debug with Visual Studio just fine, since about 2005).

Also, it appears this "NITRO" project is open source, so you can download the source instead of a pre-built binary, and build it using MinGW if you'd like to build Qt apps with MinGW, or if you are using pre-built Qt libraries that were built with MinGW.

KeyserSoze
+1  A: 

To build Qt4.5 with visual studio

  1. Download the source
  2. ./configure.exe -platform win32-msvc2008
  3. nmake

There is even a free beta release of the visual studio plugin to make handling all the autogenerated code automatic in visual studio

Martin Beckett