Difference between revisions of "Install (MSVC)"

From Open Babel
Jump to: navigation, search
(Initial info on compiling OpenBabel on Windows)
 
(Revise instructions based on my recent experience)
Line 1: Line 1:
Here we describe how to compile OpenBabel on Windows using the Microsoft Visual C++ compiler (MSVC). We recommend the following compiler which is available for free:
+
Here we describe how to compile OpenBabel on Windows using the Microsoft Visual C++ compiler (MSVC). We recommend the following compiler which is available for free:  
 
* [http://msdn.microsoft.com/vstudio/express/visualc/download/ Visual C++ 2005 (8.0) Express Edition ]
 
* [http://msdn.microsoft.com/vstudio/express/visualc/download/ Visual C++ 2005 (8.0) Express Edition ]
 +
Microsoft would prefer you use the .NET framework, but they also support "native" code - it's just that they don't make it ''too'' easy.
  
You also need to install the [http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/ Platform SDK].
+
You also need to install the Platform SDK to provide the Windows files. Don't be put off because it is called "Microsoft Platform SDK for Windows Server 2003 R2"
 +
Follow the instructions in [http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/].  
 +
At Step 4 when updating the corewin_express.vsprops file, the list of libraries should be
 +
"kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comctl32.lib rpcrt4.lib".
 +
Also just before this add a section:
 +
<pre>
 +
  <Tool
 +
    Name="VCCLCompilerTool"
 +
    PreprocessorDefinitions=
 +
    "_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES"
 +
  />
 +
</pre>
 +
This (usually) avoids warnings about unsafe functions like sprintf for which Microsoft have provided "safe" alternatives. Read a critique of these [http://www.informit.com/guides/content.asp?g=cplusplus&seqNum=259&rl=1 here]. They are not usable in cross-platform code because they are non-standard. Ignore any such warnings that have failed to be supressed.
 +
 
 +
At Step 5 the line numbers now seem to be pp478-481.
 +
 
 +
At this stage you should be able to compile the command-line version of OpenBabel. (Open openbabel.sln and build the project OBComLn. OpenBabelDLL.dll, which contains most of OpenBabel is built first.)
  
 
=== Compiling wxWidgets ===
 
=== Compiling wxWidgets ===
  
To compile the Windows GUI, you will need to install and compile [http://www.wxwidgets.org/ wxWidgets]. We are currently using [http://downloads.sourceforge.net/wxwindows/wxWidgets-2.6.1.zip wxWidgets 2.6.1]. To compile it...
+
To compile the Windows GUI, you will need to install and compile [http://www.wxwidgets.org/ wxWidgets]. We are currently using [http://downloads.sourceforge.net/wxwindows/wxWidgets-2.8.3.zip wxWidgets 2.6.1]. To compile it...
 
* Unzip it into a folder that doesn't contain spaces
 
* Unzip it into a folder that doesn't contain spaces
 
* Read the install notes in the distribution
 
* Read the install notes in the distribution
 
* Read more [http://www.wxwidgets.org/wiki/index.php/MSVC_.NET_Setup_Guide install notes] on the web site
 
* Read more [http://www.wxwidgets.org/wiki/index.php/MSVC_.NET_Setup_Guide install notes] on the web site
* Open "build\msw\wx.dsw"
+
* Set the environment variable WXWIN to the installation directory of wxWidgets, e.g. E:\wxWidgets-2.8.3, and restart MSVC.
* Under the default target 'wxregex', open "setup.h" and change
+
* In the file$(WXWIN)/include/wx/msw/setup.h change
 
<pre>
 
<pre>
 
#define wxUSE_STD_IOSTREAM  0
 
#define wxUSE_STD_IOSTREAM  0
Line 19: Line 36:
 
#define wxUSE_STD_IOSTREAM  1
 
#define wxUSE_STD_IOSTREAM  1
 
</pre>
 
</pre>
* On the menu, choose "Batch Build", and sort by "Configuration". Select only those configurations of type "Release", and click on Build All.
+
* In the file $(WXWIN)/include/wx/msw/wx.rc find the section "Manifest file for Windows XP" and add immediately after it:
* Set the environment variable WXWIN to the installation directory of wxWidgets, and restart MSVC.
+
<pre>
 
+
//For Visual Studio 2005
=== Compiling one of the OpenBabel GUI targets ===
+
#define wxUSE_NO_MANIFEST 1
 
+
#if defined(__WXMSW__) && !defined(__WXWINCE__)
The GUI targets, OBGUII and OBabelGUI, need some extra tweaking to get them to work. Here we describe the procedure for OBGUII, but it is the same for OBabelGUI.
+
#pragma comment(linker, "\"/manifestdependency:type='Win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='X86' publicKeyToken='6595b64144ccf1df'\"")
 +
#endif
 +
//
 +
</pre>
 +
This ensures that the latest version of Common Controls is used.
 +
* Open "build\msw\wx.dsw" and answer "Yes to All" for the format conversion. (There is no need to save the converted project files.)
 +
* On the menu, choose "Batch Build", and sort by "Configuration". Select only those configurations of type "Release" and, possibly "Debug", and click on Build All.
  
* Make sure you have carried out all of the instructions in the section on [Install (MSVC)#Compiling wxWidgets | Compiling wxWidgets].
+
The GUI can be built by opening openbabel.sln and building the project OBGUII.
* Open the OBGUII Properties dialog (by right-clicking on the project name), choose "Preprocessor definitions" and add the following:
+
<pre>_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES</pre>
+
* In the same dialog box, add the following to "Linker", "Additional Dependencies":
+
:: user32.lib
+
:: gdi32.lib
+
:: oleaut32.lib
+
:: ole32.lib
+
:: comdlg32.lib
+
:: shell32.lib
+
:: advapi32.lib
+
:: comctl32.lib
+

Revision as of 04:00, 17 April 2007

Here we describe how to compile OpenBabel on Windows using the Microsoft Visual C++ compiler (MSVC). We recommend the following compiler which is available for free:

Microsoft would prefer you use the .NET framework, but they also support "native" code - it's just that they don't make it too easy.

You also need to install the Platform SDK to provide the Windows files. Don't be put off because it is called "Microsoft Platform SDK for Windows Server 2003 R2" Follow the instructions in [1]. At Step 4 when updating the corewin_express.vsprops file, the list of libraries should be "kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comctl32.lib rpcrt4.lib". Also just before this add a section:

  <Tool
    Name="VCCLCompilerTool" 
    PreprocessorDefinitions=
    "_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES"
  />

This (usually) avoids warnings about unsafe functions like sprintf for which Microsoft have provided "safe" alternatives. Read a critique of these here. They are not usable in cross-platform code because they are non-standard. Ignore any such warnings that have failed to be supressed.

At Step 5 the line numbers now seem to be pp478-481.

At this stage you should be able to compile the command-line version of OpenBabel. (Open openbabel.sln and build the project OBComLn. OpenBabelDLL.dll, which contains most of OpenBabel is built first.)

Compiling wxWidgets

To compile the Windows GUI, you will need to install and compile wxWidgets. We are currently using wxWidgets 2.6.1. To compile it...

  • Unzip it into a folder that doesn't contain spaces
  • Read the install notes in the distribution
  • Read more install notes on the web site
  • Set the environment variable WXWIN to the installation directory of wxWidgets, e.g. E:\wxWidgets-2.8.3, and restart MSVC.
  • In the file$(WXWIN)/include/wx/msw/setup.h change
#define wxUSE_STD_IOSTREAM  0

to

#define wxUSE_STD_IOSTREAM  1
  • In the file $(WXWIN)/include/wx/msw/wx.rc find the section "Manifest file for Windows XP" and add immediately after it:
//For Visual Studio 2005
#define wxUSE_NO_MANIFEST 1
#if defined(__WXMSW__) && !defined(__WXWINCE__)
#pragma comment(linker, "\"/manifestdependency:type='Win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='X86' publicKeyToken='6595b64144ccf1df'\"")
#endif
//

This ensures that the latest version of Common Controls is used.

  • Open "build\msw\wx.dsw" and answer "Yes to All" for the format conversion. (There is no need to save the converted project files.)
  • On the menu, choose "Batch Build", and sort by "Configuration". Select only those configurations of type "Release" and, possibly "Debug", and click on Build All.

The GUI can be built by opening openbabel.sln and building the project OBGUII.