Welcome to http://www.marssoft.de/
 
Tuesday, 11th December 2018 21:23:20 (GMT+1) 

Visual Studio Setup

Visual Studio Variables

Here are the most important Variables that are set when compiling a project:

  • $(SolutionDir) - path to the sln-file
  • $(PlatformName) - usually [Win32|x64]
  • $(ConfigurationName) - usually [Debug|Release]
  • $(OutDir) - The (usually relative) path that is set at 'Configuration Properties' → 'General' → 'Output Directory'
  • $(IntDir) - The (usually relative) path that is set at 'Configuration Properties' → 'General' → 'Intermediate Directory'
  • $(ProjectName) - Name of the Project (i.e. the name you type in Visual Studio)
  • $(SolutionName) - Name of the Solution file (i.e. the name the file has on disk)
  • $(TargetName) - not sure, seems identical to $(ProjectName)

Visual Studio Project Files

Often it is helpful to edit a Visual Studio Project from the command line. Here are some important variables:

  • AdditionalOptions=“” - Command Line Parameters for the C++ Compiler

Using the Intel Compiler

To enable the intel compiler, do the following:

  • Right-click the Project, and select 'Use Intel Compiler' at the bottom of the menu.

Setting up a new Project

'Configuration Properties' →

  • 'General' → 'Output Directory': $(PlatformName)
  • 'General' → 'Intermediate Directory': $(PlatformName)\$(ConfigurationName)
  • 'C/C++' → 'General' → 'Additional Include Directories': “..\..\<libname>\$(PlatformName)\include”
  • to disable the warnings about old or unsave code:
    • 'C/C++' → 'Preprocessor' → 'Preprocessor Definitions': _CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE
  • 'C/C++' → 'Code Generation' → 'Runtime Library': “Multi-Threaded DLL (/MD)”
  • 'C/C++' → 'Code Generation' → 'Enable Enhanced Instruction Set': “None”
  • 'C/C++' → 'Code Generation' → 'Enable Minimal Rebuild': “No”
  • 'Linker' → 'General' → 'Enable Incremental Linking': “No (/INCREMENTAL:NO)”
  • Debug:
    • 'C/C++' → 'Code Generation' → 'Runtime Library': “Multi-Threaded Debug DLL (/MDd)”
    • 'C/C++' → 'Output Files' → 'Program Database File Name': “$(OutDir)\$(ProjectName)_d.pdb”
    • 'Librarian' → 'General' → 'Output File': “$(OutDir)\$(ProjectName)_d.lib”
  • Release:
    • 'C/C++' → 'Output Files' → 'Program Database File Name': “$(OutDir)\$(ProjectName).pdb”
    • 'Librarian' → 'General' → 'Output File': “$(OutDir)\$(ProjectName).lib”
  • x64 platform:
    • 'C/C++' → 'Preprocessor' → 'Preprocessor Definitions': WIN64
  • Win32 platform:
    • 'C/C++' → 'Preprocessor' → 'Preprocessor Definitions': WIN32
  • Dynamic (DLL) build:
    • 'Linker' → 'General' → 'Additional Library Directories': “..\..\<libname>\$(PlatformName)\lib”

Optimization Settings

To optimize your program, set the following options (only for release builds)

  • 'C/C++' → 'Optimization' → 'Optimization': “Maximixe Speed plus High-Level Optimizations (/O2)”
  • 'C/C++' → 'Optimization' → 'Inline Function Expansion': “Any Suitable (/Ob2)”
  • 'C/C++' → 'Optimization' → 'Enable Intrinsic Functions': “Yes (/Oi)”
  • 'C/C++' → 'Optimization' → 'Favor Size or Speed': “Favor Fast Code (/Ot)”
  • 'C/C++' → 'Optimization' → 'Omit Frame Pointers': “Yes (/Oy)”
  • Note: Makes libs incompatible to other Visual Studios! 'General' → 'Whole Program Optimization': “ (/GL)”

To set them more easily, add them to the Command Line Section and disable them in the settings window:

  • Command Line: /O2 /Ob2 /Ot /Oi /Oy

Add for Intel Compiler optimizations:

  • 'C/C++' → 'Optimization' → 'Optimization': “Maximixe Speed plus High-Level Optimizations (/O3)”
  • 'C/C++' → 'Optimization' → 'Global Optimizations': “Yes (/Og)”
  • 'C/C++' → 'Optimization' → 'Use Intel Processor Extensions': “”
  • 'C/C++' → 'Optimization' → 'Require Intel Processor Extensions': “”

Or on the Command Line:

  • Command Line: /Ox /QxW /QaxWPTS

Notes and common problems

  • if the linker complains about MSCVRT vs LIBCMT multiple defines, you have set the 'Configuration Properties' → 'C/C++' → 'Code Generation' → 'Runtime Library' → 'Multi-threaded DLL' instead of 'Multi-threaded'. Set it to 'Multi-threaded' in all projects.

Tools and useful things

To pack up all Visual Studio Project files again use:

zip windows/newall.zip `find . \( -iname '*.vcproj' -o -iname '*.bat' -o -iname '*.sln' -o -iname '*.suo' \)`

Compiled Projects and Libs

Status of the Projects

Win32 static (LIB) Win32 dynamic (DLL) x64 static (LIB) x64 dynamic (DLL)
lmbBlitz CHK CHK
lmbQT CHK CHK
lmbFFTW CHK ERR ERR
lmbHDF5: szip CHK CHK CHK CHK
lmbHDF5: zlib CHK CHK CHK CHK
lmbHDF5 CHK CHK CHK CHK
lmbNetCDF CHK CHK
lmbGSL CHK CHK
libcmdline CHK CHK CHK CHK
libBlitzHDF5 CHK CHK
libBlitzFFTW CHK CHK
libBlitzNetCDF CHK CHK
xuvtools CHK

Legend: CHK: works; ERR: will not work; —: not yet done or unneeded, but will probably work

lmbBlitz

Compilation Notes

  • Compiled using the supplied Blitz-VS2005.zip project files (i.e. unzip extsrc/blitz-cvs-<version>/Blitz-VS2005.zip, then open extsrc/blitz-cvs-<version>/blitz/blitz.sln and compile)
    • use extsrc/blitz-cvs-<version>/blitz/blitz.vcproj (and not the tests and examples project files)
  • To install blitz, use the following:
lmbBlitz quick build

To quickly build and install blitz++ from the command line, use:

Z:\lmbBlitz\extsrc\recompile_lmbBlitz.bat
Z:\lmbBlitz\extsrc\install_lmbBlitz.bat
Settings:
Project: lmbBlitz\extsrc\blitz-cvs-2008.02.11\blitz\blitz.sln
Include: lmbBlitz\$(PlatformName)\include
Library: blitz.lib
         lmbBlitz\$(PlatformName)\lib

lmbQT

Compilation Notes

  • Static build after the HowTo in lmbQT/doc/HowTo_Win32u64_Compile_QT4_statically.txt
lmbQT quick build

To quickly build and install QT from the command line, use:

Z:\lmbQT\extsrc\recompile_lmbQT.bat
Z:\lmbQT\extsrc\install_lmbQT.bat
Settings:
Project: uses configure / qmake for generating
Include: lmbQT\$(PlatformName)\include
Library: many, check lib directory
         lmbQT\$(PlatformName)\lib

lmbFFTW

Compilation Notes

  • Used the project files from Jin Tian http://www.fftw.org/install/windows.html
    • open \lmbFFTW\extsrc\fftw-3.1.2\windows\libfftw.sln
  • Important: Visual Studio 2008 (at least) does not have
    __mm_malloc

    functions, so edit config.h and comment out

    #define HAVE__MM_MALLOC 1

    at the bottom of the file.

  • The x64 build needs SSE/SSE2 in order to be reasonably fast. So you need the Intel compilers.

No debug build and no dynamic build (dll) available.

lmbFFTW quick build

To quickly build and install FFTW from the command line, use:

Z:\lmbFFTW\extsrc\recompile_lmbFFTW.bat
Z:\lmbFFTW\extsrc\install_lmbFFTW.bat
lmbFFTW Settings:
Project: lmbFFTW\extsrc\fftw-3.1.2\windows\libfftw.sln
Include: lmbFFTW\$(PlatformName)\include
Library: libfftw.lib libfftwf.lib libfftw_sse2.lib libfftwf_sse.lib
         lmbFFTW\$(PlatformName)\lib

lmbGSL

  • starting with the Visual Studio Project files from David Geldreich http://david.geldreich.free.fr/dev.html
    unzip gsl-1.10-windows-sources.zip
  • open gsl\gsl.sln and convert the Solution to Visual Studio 2008
  • made some changes, i.e.:
    • set the output directory from 'lib\' to '$(PlatformName)\'
    • set the intermediate directory from 'lib\$(configurationnname)' to '$(PlatformName)\$(ConfigurationnName)'
    • added _CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE to preprocessor flags
    • removed the 64bit error message flag (deprecated in VS 2008)
lmbGSL quick build

To quickly build and install FFTW from the command line, use:

Z:\lmbGSL\extsrc\recompile_lmbGSL.bat
Z:\lmbGSL\extsrc\install_lmbGSL.bat
lmbGSL Settings:
Project:         lmbGSL\extsrc\gsl\gsl.sln
Include:         lmbGSL\$(PlatformName)\include
Release Library: cblas.lib gsl.lib
                 lmbGSL\$(PlatformName)\lib

lmbHDF5: szip

Compilation Notes

  • extract szip, rename folder to 'szip'
tar -xvzf szip-2.1.tar.gz
mv szip-2.1 szip
unzip szip/windows/szipproj.zip
  • open the Visual Studio project file szip\all\all.dsw
  • Set 'Release' at the Configuration Manager under Properties
  • build the project. To relocate the install files open a DOS box and go to szip's parent directory:
Z:
cd lmbHDF5\extsrc\szip\
windows\install_szip.bat ..\..\

lmbHDF5: zlib

Compilation Notes

  • open the Visual Studio project file projects\visualc6\zlib.dsw
  • set 'Configuration Properties' → 'C/C++' → 'Code Generation' → 'Runtime Library' → 'Multi-threaded' or 'Multi-threaded Debug' for all 'LIB Release' Projects of 'zlib' (and of 'example' and 'minigzip' if you build them)
  • set 'DLL Release' at the Configuration Manager under Properties
    • build the project
  • set 'LIB Release' at the Configuration Manager under Properties
    • build the project
  • copy the relevant files:
Z:
cd lmbHDF5\extsrc\zlib-1.2.3\projects\visualc6\
install_zlib.bat ..\..\..\..\

lmbHDF5

Compilation Notes

  • extract the project files from windows\all.zip
tar -xvzf hdf5-1.6.7.tar.gz
cd hdf5-1.6.7/
unzip windows/all.zip
  • open the Visual Studio project file proj\all\all.dsw and convert it to the new format, then close Visual Studio. From Linux, run:
find . -iname '*ds[pw]' -exec rm \{\} \;
# to enable compression support:
find . -iname '*vcproj' -exec perl -pi -e \
  's/\$\(HDF5_EXT_ZLIB\)/zlib1.lib/g' \{\} \;
find . -iname '*vcproj' -exec perl -pi -e \
  's/\$\(HDF5_EXT_SZIP\)/szlibdll.lib/g' \{\} \;
# stupid bugfix:
find . -iname '*vcproj' -exec perl -pi -e \
  's/.*AdditionalLibraryDirectories="D:\\szip\\.*"\s+//g' \{\} \;
find . -iname '*vcproj' -exec perl -pi -e \
  's/AdditionalIncludeDirectories="(.*)"/AdditionalIncludeDirectories="$1,..\\..\\..\\..\\\$\(PlatformName\)\\include"/g;s/",(.*)"/"$1"/g' \{\} \;
find . -iname '*vcproj' -exec perl -pi -e \
  's/(.*)AdditionalDependencies="(.*)zlib(.*)"/${1}AdditionalDependencies="${2}zlib${3}"\n${1}AdditionalLibraryDirectories="..\\..\\..\\..\\\$\(PlatformName\)\\dll"/g' \{\} \;
# set nicer output and intermediate directories, so x64 target can work:
find . -iname '*vcproj' -exec perl -pi -e \
  's/OutputDirectory=".*"/OutputDirectory="\$(PlatformName)\\\$(ConfigurationName)"/g' \{\} \;
find . -iname '*vcproj' -exec perl -pi -e \
  's/IntermediateDirectory=".*"/IntermediateDirectory="\$(PlatformName)\\\$(ConfigurationName)"/g' \{\} \;
find . -iname '*vcproj' -exec perl -pi -e \
  's/\.\\Release/\$(IntDir)/g;s/\.\\Debug/\$(IntDir)/g' \{\} \;
find . -iname '*vcproj' -exec perl -pi -e \
  's/\\Release/\\\$(PlatformName)\\\$(ConfigurationName)/g;s/\\Debug/\\\$(PlatformName)\\\$(ConfigurationName)/g' \{\} \;
# I'n not sure about these three:
find . -iname '*vcproj' -exec perl -pi -e \
  's/PreprocessorDefinitions="(.*)"/PreprocessorDefinitions="WIN32;$1"/g' \{\} \;
find . -iname '*vcproj' -exec perl -pi -e \
  's/PreprocessorDefinitions="WIN32;(.*)WIN32;(.*)"/PreprocessorDefinitions="WIN32;$1$2"/g' \{\} \;
find . -iname '*vcproj' -exec perl -pi -e \
  's/ForceSymbolReferences=".*"/ForceSymbolReferences=""/g' \{\} \;
# optional to avoid deprecation warnings:
find . -iname '*vcproj' -exec perl -pi -e \
  's/PreprocessorDefinitions="(.*)"/PreprocessorDefinitions="$1;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"/g;s/";(.*)"/"$1"/g' \{\} \;
  • go to the menu 'Project' → 'Build Dependencies' and mark the checkboxes: 'dsets_cpp', 'dsets_cppdll', 'hdf5_cpp', 'hdf5_cppdll', 'testhdf5_cpp', 'testhdf5_cppdll'
  • go to the configuration manager, and
    • un-check all '*f90*' and '*fortran*' projects from the build selection for both 'Debug' and 'Release'
  • build the project for 'Debug' and for 'Release' to enable automatic testing.
  • To test the build and finally relocate the install files open a dos box and go to hdf5's parent directory:

Note: This test is not working on Vista because it needs (or just wants?) to copy needed dll's to Windows system folder.

Z:
cd lmbHDF5\extsrc\hdf5-1.6.7\
# Note: zlib is missing, but that did not help:
#copy ..\..\Win32\dll\*zlib*.dll proj\hdf5dll\Release\
hdf5check enablecpp
# check test results
# on Vista x64: "C:\Program Files (x86)\Windows NT\Accessories\wordpad.exe" tests_results.txt

To install the debug or release version of the library, run from the dos box:

Z:
cd lmbHDF5\extsrc\hdf5-1.6.7\
..\install_hdf5.bat ..\..\
lmbHDF5 quick build

To quickly build and install HDF5 from the command line, use:

Z:\lmbHDF5\extsrc\recompile_lmbHDF5.bat
Z:\lmbHDF5\extsrc\install_lmbHDF5.bat
Z:\lmbHDF5\extsrc\install_szip.bat
Z:\lmbHDF5\extsrc\install_zlib.bat
Settings:
Project: lmbHDF5\extsrc\hdf5-1.6.7\proj\all\all.sln
Include: lmbHDF5\$(PlatformName)\include
Library: zlib1.lib szlibdll.lib hdf5dll.lib hdf5_cppdll.lib hdf5_hldll.lib
         lmbHDF5\$(PlatformName)\lib
         lmbHDF5\$(PlatformName)\dll
Preprocessor needs for DLL use: _HDF5USEDLL_;HDF5CPP_USEDLL

lmbNetCDF

Compilation Notes

  • Uses self-created project files because Unidata does not provide the standard project files.
    • These are fairly simple, drop in all needed source files and compile into a library.
lmbNetCDF quick build

To quickly build and install NetCDF from the command line, use:

Z:\lmbNetCDF\extsrc\recompile_lmbNetCDF.bat
Z:\lmbNetCDF\extsrc\install_lmbNetCDF.bat
Settings:
Project: 
Include: lmbNetCDF\$(PlatformName)\include
Library: netcdf.lib netcdf_cpp.lib
         lmbNetCDF\$(PlatformName)\lib

libcmdline

Compilation Notes only for creating the project from scratch:

  • Open Visual Studio, select in the Menu 'File' → 'New' → 'Project from existing Code'
    • Project type is 'Visual C++'
    • for 'Project file location' create a 'windows\' subdirectory
    • Project name is 'libcmdline'
    • Add files from: 'src\libcmdline'
    • Finally select 'DLL' for the build
    • close the Solution, and copy 'windows\libcmdline.vcproj' to 'windows\libcmdlinedll.vcproj'
    • open the solution again, and add the newly copied 'windows\libcmdlinedll.vcproj' to it via menu 'File' → 'Add' → 'Existing Project'
    • right-click 'libcmdline' → 'Properties' → 'Configuration Properties' → 'General' → 'Configuration Type' → 'Static library (.lib)' for both Release and Debug targets.
    • set 'Configuration Properties' → 'C/C++' → 'Code Generation' → 'Runtime Library' → 'Multi-threaded' or 'Multi-threaded Debug' for the static lib project
    • you might also want to fiddle with some build parameters, but its not needed
libcmdline quick build

To quickly build and install libcmdline from the command line, use:

Z:\libcmdline\extsrc\recompile_libcmdline.bat
Z:\libcmdline\extsrc\install_libcmdline.bat
Settings:
Project: libcmdline\windows\libcmdline.sln
Include: libcmdline\$(PlatformName)\include
Library: libcmdline.lib|libcmdline.dll|libcmdline_d.lib|libcmdline_d.dll
         libcmdline\$(PlatformName)\lib

libBlitzNetCDF

Compilation Notes only for creating the project from scratch:

  • See libcmdline above
  • add to Additional Include Directories:
    • '..\..\lmbBlitz\$(PlatformName)\include'
    • '..\..\lmbNetCDF\$(PlatformName)\include'
  • add to Additional Library Directories of the static project:
    • '..\..\lmbBlitz\$(PlatformName)\lib'
    • '..\..\lmbNetCDF\$(PlatformName)\lib'
  • add to Additional Library Directories of the dll dynamic project:
    • 'lmbNetCDF\$(PlatformName)\dll'
libBlitzNetCDF quick build

To quickly build and install libBlitzNetCDF from the command line, use:

Z:\libBlitzNetCDF\extsrc\recompile_libBlitzNetCDF.bat
Z:\libBlitzNetCDF\extsrc\install_libBlitzNetCDF.bat
Settings:
Project: libBlitzNetCDF\windows\libBlitzNetCDF.sln
Include: libBlitzNetCDF\$(PlatformName)\include
Library: libBlitzNetCDF.dll
         libBlitzNetCDF\$(PlatformName)\dll
         libBlitzNetCDF.lib
         libBlitzNetCDF\$(PlatformName)\lib

libBlitzHDF5

Note: dynamic (DLL) build does not create import library (.lib) because nothing is exported from the dll? see http://www.devinrose.heroicvirtuecreations.com/blog/2005/07/30/dll-import-library-not-created/

Compilation Notes only for creating the project from scratch:

  • See libcmdline above
  • add to Additional Include Directories:
    • '..\..\lmbBlitz\$(PlatformName)\include'
    • '..\..\lmbHDF5\$(PlatformName)\include'
  • add to Additional Library Directories of the static project:
    • '..\..\lmbBlitz\$(PlatformName)\lib'
    • '..\..\lmbHDF5\$(PlatformName)\lib'
  • add to Additional Library Directories of the dll dynamic project:
    • 'lmbHDF5\$(PlatformName)\dll'
  • add to Preprocessor Definitions '_HDF5USEDLL_;HDF5CPP_USEDLL' for the dll (dynamic) project
libBlitzHDF5 quick build

To quickly build and install libBlitzHDF5 from the command line, use:

Z:\libBlitzHDF5\extsrc\recompile_libBlitzHDF5.bat
Z:\libBlitzHDF5\extsrc\install_libBlitzHDF5.bat
Settings:
Project: libBlitzHDF5\windows\libBlitzHDF5.sln
Include: libBlitzHDF5\$(PlatformName)\include
Library: libBlitzHDF5.dll
         libBlitzHDF5\$(PlatformName)\dll
         libBlitzHDF5.lib
         libBlitzHDF5\$(PlatformName)\lib

libBlitzFFTW

Compilation Notes only for creating the project from scratch:

  • See libcmdline above
  • add to Additional Include Directories:
    • '..\..\lmbBlitz\$(PlatformName)\include'
    • '..\..\lmbFFTW\$(PlatformName)\include'
  • add to Additional Library Directories of the static project:
    • '..\..\lmbBlitz\$(PlatformName)\lib'
    • '..\..\lmbFFTW\$(PlatformName)\lib'
libBlitzFFTW quick build

To quickly build and install libBlitzFFTW from the command line, use:

Z:\libBlitzFFTW\extsrc\recompile_libBlitzFFTW.bat
Z:\libBlitzFFTW\extsrc\install_libBlitzFFTW.bat
Settings:
Project: libBlitzFFTW\windows\libBlitzFFTW.sln
Include: libBlitzFFTW\$(PlatformName)\include
Library: libBlitzFFTW.lib
         + wsock32.lib
         libBlitzFFTW\$(PlatformName)\lib

xuvtools

  • Define, depending on what you have available (add to 'Configuration Properties' → 'C/C++' → 'Preprocessor' → 'Preprocessor Definitions'):
    • HAVE_BLITZ
    • HAVE_BLITZHDF5
    • HAVE_BLITZNETCDF
    • HAVE_GSL
xuvtools quick build

To quickly build and install xuvtools from the command line, use:

Z:\xuvtools\windows\recompile_xuvtools.bat
Z:\xuvtools\windows\install_xuvtools.bat
Settings:
Project: xuvtools\windows\xuvtools.sln

xuvtools_gui

  • QT: You need to have QT4 installed in order to build xuvtools_gui.
    • Add the path to qmake to your environment variables (go to 'Control Panel' → 'System' → 'Advanced' → 'Environment Variables' and add to your 'User Variables' → 'New' the pair “Path” “<path/to/qt4/bin/>;%Path%”
  • Open the Visual Studio x64 command prompt and go to the xuvtools_gui directory
  • run 'qmake -t vcapp xuvtools_gui.pro'
  • open the project in Visual Studio:
    • Add your preferred optimization settings to Release target (Intel Compiler: /Ox /QxW /QaxWPTS)
    • In the configuration editor, add the 'x64' target
    • Set the output directory of all targets to $(PlatformName)
    • Set the intermediate directory of all targets to $(PlatformName)\$(ConfigurationName)
    • 'Linker' → 'General' → 'Enable Incremental Linking': “No (/INCREMENTAL:NO)”
    • Set for Debug-target all Platforms 'Linker' → 'Output Filename': $(PlatformName)\xuvtools_gui_d.exe
    • Set for Release-target all Platforms 'Linker' → 'Output Filename': $(PlatformName)\xuvtools_gui.exe
xuvtools_gui quick build

To quickly build and install xuvtools_gui from the command line, use:

Z:\xuvtools\windows\recompile_xuvtools_gui.bat
REM Now open the project file 'xuvtools_gui.icproj' with visual studio and apply above settings
REM Press return in the command prompt once you have saved the project file again
Z:\xuvtools\windows\install_xuvtools_gui.bat
Settings:
Project: xuvtools_gui\xuvtools_gui.vcproj
guides/lmbsoft_visual_studio_batch.txt · Last modified: 2014/04/02 22:39 (external edit)