Menu

MSVC8_Build

Alexander Batishchev Christian Walther Andrea Viarengo

Introduction

Official Pipmak distribution is builded with GNU gcc. If you want to try building Pipmak from source on Windows, you have basically two choice:

  • MinGW (Opensource project)
  • Microsoft Visual Studio (Commercial, but there is also a free version)

This tutorial is a step-to-step guide to compile and build Pipmak with Microsoft Visual C++ Express 2005 on Windows Platform.

Get pipmak SVN

Download and Install TortoiseSVN-1.4.3.8645-win32-svn-1.4.3.msi from

 http://tortoisesvn.net/downloads

Create a directory

 D:\Projects\pipmak-SVN

Click on folder with right button and select TortoiseSVN on contextual menu and choise 'export' and set:

Download and Install "Microsoft Visual C++ 2005 Express Edition

It's free, but you have to register to get the installation key (by mail)

    http://msdn.microsoft.com/vstudio/express/downloads/

Download and Install "The Microsoft Platform SDK for Microsoft Visual C++ 2005 Express

   http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/

Install under D:\Projects\Microsoft Platform SDK

Download additional libraries

Download all of these additional libraries. Search for devel package because you need only include files (.h) and lib files (.lib).

If you don't found devel package, you have to download source distribution and compile it.

   http://www.libsdl.org/release/SDL-devel-1.2.11-VC6.zip
   http://www.libsdl.org/projects/SDL_image/release/SDL_image-devel-1.2.5-VC6.zip
   http://www.libsdl.org/projects/SDL_ttf/release/SDL_ttf-devel-2.0.8-VC6.zip
   http://icculus.org/physfs/downloads/physfs-1.1.1.tar.gz
   http://downloads.xiph.org/releases/ogg/libogg-1.1.3.zip
   http://downloads.xiph.org/releases/vorbis/libvorbis-1.1.2.zip
   http://luaforge.net/frs/download.php/1890/lua5_0_3_Win32_vc8_lib.zip
   http://www.openal.org/downloads.html  and click on "OpenAL 1.1 SDK for Windows"
     or go directly to
   http://developer.creative.com/articles/article.asp?cat=1&sbcat=31&top=38&aid=45
     and get "OpenAL11CoreSDK.exe"

Uncompress all zip file under D:\Projects and install OpenAL11CoreSDK.exe under D:\Projects, recreate following directory structure:

   D:\Projects\SDL-1.2.11           
   D:\Projects\SDL_ttf-2.0.8
   D:\Projects\SDL_image-1.2.5
   D:\Projects\physfs-1.1.1
   D:\Projects\lua-5.0.3
   D:\Projects\libogg-1.1.3
   D:\Projects\libvorbis-1.1.2
   D:\Projects\OpenAL 1.1 SDK

Create lib folder

   D:\Projects\lib

This directory must contents these libraries:

   SDL.lib                 copy from D:\Projects\SDL-1.2.11\lib 
   SDLmain.lib             copy from D:\Projects\SDL_ttf-2.0.8\lib 
   SDL_image.lib           copy from D:\Projects\SDL_image-1.2.5\lib 
   SDL_ttf.lib             copy from D:\Projects\SDL_image-1.2.5\lib 
   lua50.lib               copy from D:\Projects\lua-5.0.3 
   OpenAL32.lib            copy from D:\Projects\OpenALOpenAL 1.1 SDK\libs\Win32
   vorbis_static_d.lib     compile from D:\projects\libvorbis-1.1.2\win32\vorbis_static.dsp
   vorbisfile_static_d.lib compile from D:\projects\libvorbis-1.1.2\win32\vorbisfile_static.dsp
   ogg_static_d.lib        compile from D:\projects\libogg-1.1.3\win32\ogg_static.dsp
   zlib.lib                compile from D:\Projects\physfs-1.1.1\zlib123
   physfs.lib              compile from D:\Projects\physfs-1.1.1

Build vorbis_static_d.lib

You have to compile this one, but it's simple because project files for MS Vc++ are included:

  1. Open D:\projects\libvorbis-1.1.2\win32\vorbis_static.dsp with MS VC++ (dsp will be converted to vcproj)
  2. make|make vorbis_static
  3. Copy from D:\projects\libvorbis-1.1.2\win32\Vorbis_Static_Debug\vorbis_static_d.lib to D:\Projects\lib

Build vorbisfile_static_d.lib

You have to compile this one, but it's simple because project files for MS Vc++ are included:

  1. Open D:\projects\libvorbis-1.1.2\win32\vorbisfile_static.dsp with MS VC++
  2. make|make vorbisfile_static
  3. Copy from D:\projects\libvorbis-1.1.2\win32\Vorbisfile_Static_Debug\vorbisfile_static_d.lib to D:\Projects\lib

Build ogg_static_d.lib

You have to compile this one, but it's simple because project files for MS Vc++ are included:

  1. Open D:\projects\libogg-1.1.3\win32\ogg_static.dsp with MS VC++
  2. make|make ogg_static
  3. Copy from D:\projects\libogg-1.1.3\win32\Ogg_Static_Debug\ogg_static_d.lib to D:\Projects\lib

Build zlib.lib

  1. open Microsoft Visual C++
  2. In the menu, select File|New|Project from existent code and in the Wizard set:
    1. Type of project: Visual C++
    2. Set Project path: D:\Projects\physfs-1.1.\zlib123 and Project name: zlib
    3. Project type: Static library, uncheck support for ATL, MFC and Common Language Runtime
  3. Set Project|Settings|C/C++ tab|Code generation|Runtime Library: Multithread (/MDd)
  4. Make|Make zlib
  5. copy zlib.lib from D:\Projects\physfs-1.1.1\zlib123\Debug to D:\Projects\lib

Build physfs.lib

  1. Open Microsoft Visual C++
  2. File|New|Project from existent code and in the Wizard set:
    1. Type of project: Visual C++
    2. Project path: D:\Projects\physfs-1.1.1
      Project name: physfs
    3. Project type: Static library,uncheck support for ATL, MFC and Common Language Runtime
  3. Esclude next folders/file from project (click on folder/file with mouse right button), files different from .c/.h are automaticaly excluded.

    extras
    lzma
    platform (all except windows.c)
    test
    zlib123
    pay attention that directory archivers must be included.
    4. Project|Settings|C/C++ tab|Preprocessor|Additional include directories (/I)

    D:\Projects\physfs-1.1.1\zlib123
    D:\Projects\physfs-1.1.1
    5. Project|Settings|C/C++ tab|Preprocessor|Additional preprocessor definition (/D)

    WIN32
    _DEBUG
    _LIB
    _CRT_SECURE_NO_DEPRECATE
    _SZ_ONE_DIRECTORY
    _REENTRANT
    _THREAD_SAFE
    PHYSFS_SUPPORTS_ZIP=1
    6. Project|Settings|C/C++ tab|Optimization|Optimization: disable
    7. Project|Settings|C/C++ tab|Code generation|Runtime Library: Multithread (/MT)
    8. Project|Settings|C/C++ tab|Advanced|Compile as: C++ (/TP)
    9. Project|Settings|Linker tab|General|Additional Library Directories

    D:\Projects\Microsoft Platform SDK\Lib
    10. Project|Settings|Linker tab|input|Additional Dependencies

    comdlg32.lib
    11. Make|Make physfs
    12. copy physfs.lib from D:\Projects\physfs-1.1.1\Debug to D:\Projects\lib

Create Visual C++ Project for Pipmak

  1. Open Microsoft Visual C++
  2. File|New|Project from existent code and in the Wizard you set:
    1. Type of project: Visual C++
    2. Project path: D:\Projects\pipmak-SVN
    3. Project name: pipmak-SVN
    4. Project type: Windows Application (.exe), uncheck support for ATL, MFC and Common Language Runtime

Esclude some files from generation

Esclude the following files from the build, to do that click on the project files browser on the left, and right button on a file or folder icon and select esclude from project from the contextual menu

  D:\Projects\pipmak-SVN\source\pipmak_dummyplatform.c
  D:\Projects\pipmak-SVN\source\pipmak_gtk.c
  D:\Projects\pipmak-SVN\extras\makepatch.c

Set some compile/linker options

  1. Tools|Options|Projects and Solutions|VC++ Paths|Include Path

    $(VCInstallDir)include
    $(FrameworkSDKDir)include
    D:\Projects\Microsoft Platform SDK\Include
    D:\Projects\SDL-1.2.11\include
    D:\Projects\SDL_ttf-2.0.8
    D:\Projects\SDL_image-1.2.5
    D:\Projects\physfs-1.1.1\
    D:\Projects\lua-5.0.3\include
    D:\Projects\libogg-1.1.3\include
    D:\Projects\libvorbis-1.1.2\include
    D:\Projects\openal-1.1.1\include
    2. Tools|Options|Projects and Solutions|VC++ Paths|Library Path

    D:\Projects\Microsoft Platform SDK\Lib
    3. Tools|Options|Projects and Solutions|VC++ Paths|Binary Path

    D:\Projects\Microsoft Platform SDK\Bin
    4. Project|Settings|C/C++ tab|Preprocessor|Additional preprocessor definition (/D)

    WIN32
    _DEBUG
    _WINDOWS
    _USE_MATH_DEFINES
    _CRT_SECURE_NO_DEPRECATE
    5. Project|Settings|C/C++ tab|Optimization|Optimization: disable
    6. Project|Settings|C/C++ tab|Code generation|Runtime Library: Multithread (/MT)
    7. Project|Settings|C/C++ tab|Code generation|Floating Point Model: Fast (/fp:fast)
    8. Project|Settings|C/C++ tab|Advanced|Compile as: C++ (/TP)
    9. Project|Settings|Linker tab|General|Dependancy libraries path:

    D:\Projects\Lib**
    D:\Projects\Microsoft Platform SDK\Lib
    10.
    Project|Settings|Linker tab|Input|Additional Dependancy libraries:**

    vorbisfile_static_d.lib
    vorbis_static_d.lib
    ogg_static_d.lib
    zlib.lib
    physfs.lib
    opengl32.lib
    glu32.lib
    OpenAL32.lib
    SDL_ttf.lib
    SDL.lib
    SDLmain.lib
    SDL_image.lib
    oldnames.lib
    msvcrtd.lib
    libcmtd.lib
    lua50.lib
    11. Project|Settings|Linker|Input|Ignore Predefined libraries: Yes (/NODEFAULTLIB)

Compiling and linking from IDE

  1. Make|Make pipmak-build

Check errors - correct them and remake.

Here you can found a list of tweaks which I have made. Use this just an example.

Notice that Pipmak BUILD 172 will be compiled without any error issues (just few warnings), so no sources modification is required to generate a good pipmak.exe

Compiling and linking from command line

If you want to compile and link from command line, the best solution is create a file make.bat

Here I report a template (you have to modify):

  REM ===== MAKE.BAT =====

  REM ===== set enviroment variables =====
  PATH=%PATH%;C:\Program Files\Microsoft Visual Studio 8\VC\bin
  PATH=%PATH%;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE

  REM ===== set include directories =====
  set INCLUDE=%INCLUDE%;D:\Program Files\Microsoft Platform SDK\Include
  set INCLUDE=%INCLUDE%;C:\Program Files\Microsoft Visual Studio 8\VC\include
  set INCLUDE=%INCLUDE%;D:\Program Files\openal-1.1\include

  REM ===== set additional defines =====
  set DEFINE=
  set DEFINE=%DEFINE% /D_CRT_SECURE_NO_DEPRECATE 
  set DEFINE=%DEFINE% /D_CRT_NONSTDC_NO_DEPRECATE

  REM ===== set additional library path =====
  set LIB=%LIB%;D:\Projects\Microsoft Platform SDK\Lib;
  set LIB=%LIB%;C:\Program files\Microsoft Visual Studio 8\VC\lib

  REM ===== set compile options =====
  set CL_OPTS=/TP /MD /O2 /W3 /c

  REM ===== compile step =====
  cd .\source
  cl.exe %CL_OPTS% %DEFINE%  *.c

  REM ===== set compile options =====
  set LINK_OPTS=/VERBOSE /OUT:Debug\out.exe

  REM ===== link step ===== 
  link.exe %LINK_OPTS% *.obj

  REM ===== cleaning step =====
  del *.obj
  cd ..

Remember to move out files ".c" which you don't need and write explicitly subdirectories (if you have files in subdirs to compile, ie.: cl.exe %OPTS% .c foo/*.c)

In the next sections I reports options that you needs for pipmak

cl.exe options:

     /Od 
     /D "WIN32" 
     /D "_DEBUG" 
     /D "_WINDOWS" 
     /D "_USE_MATH_DEFINES"
     /D "_CRT_SECURE_NO_DEPRECATE"
     /FD 
     /MT 
     /Fo"Debug\\" 
     /Fd"Debug\vc80.pdb" 
     /W2 /nologo 
     /c 
     /TP 
     /errorReport:prompt

link.exe options:

     /VERBOSE 
     /OUT:"Debug\pipmak .exe" 
     /INCREMENTAL 
     /NOLOGO 
     /LIBPATH:"D:\Projects\Lib" 
     /LIBPATH:"D:\Projects\Microsoft Platform SDK\Lib" 
     /MANIFEST 
     /MANIFESTFILE:"Debug\pipmak .exe.intermediate.manifest" 
     /NODEFAULTLIB
     /DEBUG 
     /ASSEMBLYDEBUG 
     /PDB:"d:\Projects\pipmak-SVN\Debug\pipmak .pdb" 
     /SUBSYSTEM:WINDOWS 
     /MACHINE:X86 
     /ERRORREPORT:PROMPT 
      vorbisfile_static_d.lib vorbis_static_d.lib ogg_static_d.lib zlib.lib 
      physfs.lib opengl32.lib glu32.lib OpenAL32.lib 
      SDL_ttf.lib SDL.lib SDLmain.lib SDL_image.lib 
      oldnames.lib msvcrtd.lib libcmtd.lib lua50.lib  
      kernel32.lib user32.lib gdi32.lib winspool.lib 
      comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib

Deployment: Prepare package for pipmak

This procedure describe a method to prepare a standalone package will be able to run in every PC without having Microsoft Visual C++ express 2005 installed in. You cannot deploy a standalone application which use DEBUG libraries. So you must rebuild project disabling debugging from Tools|Options|Projects and Solutions Remember also to change the additional libraries:

  1. msvcrtd.lib substitute with msvcrt.lib (i.e.: without 'd')
  2. libcmtd.lib substitute with libcmt.lib

Create a folder pipmak-build where do you want, and put following files inside:

    pipmak-SVN.exe          copy from D:\Projects\pipmak-SVN\Debug
    jpeg.dll                copy from D:\Projects\SDL_image-1.2.5\lib 
    libpng12.dll            copy from D:\Projects\SDL_image-1.2.5\lib 
    libtiff.dll             copy from D:\Projects\SDL_image-1.2.5\lib 
    zlib1.dll               copy from D:\Projects\SDL_image-1.2.5\lib 
    SDL_image.dll           copy from D:\Projects\SDL_image-1.2.5\lib 
    SDL.dll                 copy from D:\Projects\SDL-1.2.11\lib
    SDL_ttf.dll             copy from D:\Projects\SDL_ttf-2.0.8\lib
    OpenAL32.dll            copy from D:\Projects\OpenAL 1.1 SDK\DLL
    wrap_oal.dll            copy from D:\Projects\OpenAL 1.1 SDK\DLL
    Pipmak Resources        zip the contents of D:\Projects\pipmak-SVN\resources
                            (go inside the folder, select all and select add to resources.zip)
                            rename resources.zip into "Pipmak Resources"
    Acknowledgements.txt    copy from standard pipmak distributions   
    COPYING.txt             copy from standard pipmak distributions

Add runtime Microsoft Runtime library

    pipmak-SVN.exe.manifest copy from D:\Projects\pipmak-SVN\Debug\pipmak-SVN.exe.intermediate.manifest

This manifest file (it's an XML) must be similar to:

 <assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
   <dependency>
     <dependentAssembly>
       <assemblyIdentity type='win32' 
        name='Microsoft.VC80.CRT' 
        version='8.0.50608.0' 
        processorArchitecture='x86' 
        publicKeyToken='1fc8b3b9a1e18e3b' />
     </dependentAssembly>
   </dependency>
 </assembly>

Create a directory called "Microsoft.VC80.CRT" which must contents two files:

 Microsoft.VC80.CRT.manifest  create as text file (see below)
 msvcr80.dll                  copy from C:\Windows\System32 (it was installed by MS Visual C++ 2005)

Edit Microsoft.VC80.CRT.manifest

 <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
   <noInheritable/>
   <assemblyIdentity 
       type="win32" 
       name="Microsoft.VC80.CRT" 
       version="8.0.50608.0" 
       processorArchitecture="x86" 
       publicKeyToken="1fc8b3b9a1e18e3b" />
   <file name="msvcr80.dll"/>
 </assembly>

Check that versions wrote in the manifest files match the version of msvcrt80.dll (property/version)

Troubleshooting

If your standalone application doesn't run and you get an error like:

  • The application failed to initialize properly (0xc0000135).
  • This application has failed to start because the application configuration is incorrect. Reinstalling application may fix this problem.
  • The system cannot execute the specified program.

Check double manifest contents and folder Microsoft.VC80.CRT

You can use the utility "dependency walker" by Steve P. Miller.

This very useful free utility is given in bundle with every versions of MS Visual Studio and you can also download from

http://www.dependencywalker.com/

Open pipmak-SVN.exe with "dependency walker" to check if all the DLL dependencies are satified.

Debugging Pipmak

If you want debug Pipmak with Microsoft Visual C++ internal debugger, don't forget to copy all file described in section "Deployment" (except Runtime library) into the folder:

    D:\Projects\pipmak-SVN\Debug

Set breaking points where you want and start debugger Debug|Start debug

For better debugging set Project|Settings|C/C++ tab|Output|Assembler output: Assembly, machine code abd source (/FAcs)

Compiling documentation

If you want to compile documentation (which are wrote using TeX language), you need a TeX compiler which transform .tex file into .pdf file.

A good TeX Tool for Windows can be found at address http://miktex.org

Note about this page

My english have a lots of bugs (like my softwares...). If english is your native language, feel free to edit this page.

Thank you!

Related Material

This section contain pages related to the article.

  1. Compiling log Build 156

Related

Wiki: Build_log_156
Wiki: Main_Page
Wiki: Source_Tweaks_on_SVN_Build155