[Qt-interest] Distributing Qt with source code usingVisualStudio

Daniel Bowen qtmailinglist1 at bowensite.com
Wed Jul 6 18:02:29 CEST 2011


So, for the scenario I had outlined earlier, here's where those Visual
Studio project properties are set (using Visual Studio 2008).  I wouldn't
set project debugging properties to find DLLs.  Project debugging properties
however are handy if you're going to specify command line arguments for your
own debugging (and like you noticed, those end up in the per-user .suo
file).

 

1. Project Include Path:

Project Properties -> (Select all Configurations and Platforms) ->
Configuration Properties -> C/C++ -> Additional Include Directories

Example: (For project under GroupAbc / Project1)

..\..\..\include;..\..\..\..\ThirdParty\include

NOTE: We don't put include\QtCore, etc. directory in the include path,
because we use #include <QtCore\QString>, etc.

 

2. Project Library Path:

Project Properties -> (Select all Configurations and Platforms) ->
Configuration Properties -> Linker -> General -> Additional Library
Directories

Example: (For project under GroupAbc / Project1)

"..\..\..\lib\Windows-$(PlatformName)\$(ConfigurationName)\";"..\..\..\..\Gr
oupDef\lib\Windows-$(PlatformName)\$(ConfigurationName)\";"..\..\..\..\Third
Party\lib\Windows-$(PlatformName)\$(ConfigurationName)\Qt\"

NOTE: $(PlatformName) is a Visual Studio variable, and ends up being Win32
(or x64, etc., depending on what platforms you have added).
$(ConfigurationName) is a Visual Studio variable that ends up being the name
of your configuration (such as Debug or Release).  Also note, that we put
all the .lib files for Qt related DLLs into the lib\(platform)\(config)\Qt
directory in source control.

 

3. Project Library Dependencies, Debug:

Project Properties -> (Select only Debug Configuration and all Platforms) ->
Configuration Properties -> Linker -> Input-> Additional Dependencies

Example: Ws2_32.lib Project2.lib Project3.lib QtCored4.lib QtNetworkd4.lib

NOTE: Debug Qt libraries have a "d" suffix.

 

4. Project Library Dependencies, Release:

Project Properties -> (Select only Release Configuration and all Platforms)
-> Configuration Properties -> Linker -> Input-> Additional Dependencies

Example: Ws2_32.lib Project2.lib Project3.lib QtCore4.lib QtNetwork4.lib

 

5. Project Post-Build Event:

Project Properties -> (Select all Configurations and Platforms) ->
Configuration Properties -> Build Events -> Post-Build Event -> Command Line

Example: For our projects, we always have a file for Windows called
"Publish-Windows.bat" that lives under the project directory (not under
src). We also reference this file in the project just for convenience by
making a Visual Studio folder "Script Files" and referencing the
Publish-Windows.bat under there.  Then, our post-build command line always
looks the same:

(hit the ... to edit - don't edit on the single line)

set _Build_ProjectDir=$(ProjectDir)

set _Build_TargetDir=$(TargetDir)

set _Build_TargetPath=$(TargetPath)

set _Build_ConfigurationName=$(ConfigurationName)

set _Build_PlatformName=$(PlatformName)

pushd $(ProjectDir)

Publish-Windows.bat

popd

An example Publish-Windows.bat might look like:

@echo off

 

SETLOCAL

 

:: NOTE: This script depends on the current directory being the project
directory

 

:: NOTE: We build our .exe/.dll and .lib directly to "published"
directories,

::  so there's nothing more we need to do with them, or with others in our
"group".

::  However, any dependencies outside our group we copy here, so that we can
debug.

 

:: Dependencies

 

:: Project3 from GroupDef

xcopy /Y /D /R /F
..\..\..\..\GroupDef\bin\Windows-%_Build_PlatformName%\%_Build_Configuration
Name%\Project3.* "%_Build_TargetDir%"

 

:: Qt

xcopy /Y /D /R /F
..\..\..\..\ThirdParty\bin\Windows-%_Build_PlatformName%\%_Build_Configurati
onName%\QtCore*.* "%_Build_TargetDir%"

xcopy /Y /D /R /F
..\..\..\..\ThirdParty\bin\Windows-%_Build_PlatformName%\%_Build_Configurati
onName%\QtNetwork*.* "%_Build_TargetDir%"

xcopy /Y /D /R /F
..\..\..\..\ThirdParty\bin\Windows-%_Build_PlatformName%\%_Build_Configurati
onName%\QtXml*.* "%_Build_TargetDir%"

 

:: QtNetwork depends on openssl

:: openssl (Win32, x64) - Always Release configuration

xcopy /Y /D /R /F
..\..\..\..\ThirdParty\bin\Windows-%_Build_PlatformName%\Release\libeay32.dl
l "%_Build_TargetDir%"

xcopy /Y /D /R /F
..\..\..\..\ThirdParty\bin\Windows-%_Build_PlatformName%\Release\libeay32.pd
b "%_Build_TargetDir%"

xcopy /Y /D /R /F
..\..\..\..\ThirdParty\bin\Windows-%_Build_PlatformName%\Release\ssleay32.dl
l "%_Build_TargetDir%"

xcopy /Y /D /R /F
..\..\..\..\ThirdParty\bin\Windows-%_Build_PlatformName%\Release\ssleay32.pd
b "%_Build_TargetDir%"

 

:: log4c

xcopy /Y /D /R /F
..\..\..\..\ThirdParty\bin\Windows-%_Build_PlatformName%\%_Build_Configurati
onName%\log4c*.* "%_Build_TargetDir%"

 

ENDLOCAL

 

@echo on

 

 

Hope this helps,

-Daniel

 

From: qt-interest-bounces+qtmailinglist1=bowensite.com at qt.nokia.com
[mailto:qt-interest-bounces+qtmailinglist1=bowensite.com at qt.nokia.com] On
Behalf Of Eli Hooten
Sent: Tuesday, July 05, 2011 6:52 PM
To: David Ching
Cc: qt-interest at qt.nokia.com
Subject: Re: [Qt-interest] Distributing Qt with source code
usingVisualStudio

 

Tony: That is what I am doing now manually. The problem is that the
environment changes are not specific to the .vcproj, but rather to the .suo.
Which is why I would have to distribute my .suo with the .vcproj, which I do
not want to do.

David: Interesting. I might give that approach a shot.

Any other suggestions are welcome.

Thanks,
Eli



On Tue, Jul 5, 2011 at 6:42 PM, David Ching <dc at dcsoft.com> wrote:

"Eli Hooten" <elir.hooten at gmail.com> wrote in message
news:<CAD7caDKbfW9urnXH5GHDXCSAYkXWTpmRhs1Ats1g6Uhw_yi4rA at mail.gmail.com>...

> (Note that if I don't add the $(QTDIR)\bin to PATH, the program launches
> but errors with the "..cannot find QtGuid4.dll.." error, which shouldn't
be
> that surprising since I haven't told the application where to look!)

Perhaps you could add a post-build step that copies QtGuid4.dll, etc. to the
folder containing your .exe?


-- David


_______________________________________________
Qt-interest mailing list
Qt-interest at qt.nokia.com
http://lists.qt.nokia.com/mailman/listinfo/qt-interest

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110706/78711f40/attachment.html 


More information about the Qt-interest-old mailing list