Skip to content

Commit 63876d3

Browse files
committed
Support for building with MS Visual Studio 2010.
Brar Piening, reviewed by Craig Ringer.
1 parent f132824 commit 63876d3

File tree

13 files changed

+1079
-294
lines changed

13 files changed

+1079
-294
lines changed

doc/src/sgml/install-windows.sgml

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
There are several different ways of building PostgreSQL on
2121
<productname>Windows</productname>. The simplest way to build with
2222
Microsoft tools is to install a supported version of the
23-
<productname>Microsoft Platform SDK</productname> and use the included
23+
<productname>Microsoft Windows SDK</productname> and use the included
2424
compiler. It is also possible to build with the full
25-
<productname>Microsoft Visual C++ 2005 or 2008</productname>. In some cases
26-
that requires the installation of the <productname>Platform SDK</productname>
25+
<productname>Microsoft Visual C++ 2005, 2008 or 2010</productname>. In some cases
26+
that requires the installation of the <productname>Windows SDK</productname>
2727
in addition to the compiler.
2828
</para>
2929

@@ -69,32 +69,26 @@
6969

7070
<sect1 id="install-windows-full">
7171
<title>Building with <productname>Visual C++</productname> or the
72-
<productname>Platform SDK</productname></title>
72+
<productname>Microsoft Windows SDK</productname></title>
7373

7474
<para>
7575
PostgreSQL can be built using the Visual C++ compiler suite from Microsoft.
7676
These compilers can be either from <productname>Visual Studio</productname>,
7777
<productname>Visual Studio Express</productname> or some versions of the
78-
<productname>Platform SDK</productname>. If you do not already have a
78+
<productname>Microsoft Windows SDK</productname>. If you do not already have a
7979
<productname>Visual Studio</productname> environment set up, the easiest
80-
way us to use the compilers in the <productname>Platform SDK</productname>,
80+
way is to use the compilers in the <productname>Windows SDK</productname>,
8181
which is a free download from Microsoft.
8282
</para>
8383

8484
<para>
85-
PostgreSQL supports the compilers from
86-
<productname>Visual Studio 2005</productname> and
87-
<productname>Visual Studio 2008</productname>. When using the Platform SDK
88-
only, or when building for 64-bit Windows, only
89-
<productname>Visual Studio 2008</productname> is supported.
90-
<productname>Visual Studio 2010</productname> is not yet supported.
91-
</para>
92-
93-
<para>
94-
When building using the <productname>Platform SDK</productname>, versions
95-
6.0 to 7.0 of the SDK are supported. Older or newer versions will not work.
96-
In particular, versions from 7.0a and later will not work, since
97-
they include compilers from <productname>Visual Studio 2010</productname>.
85+
PostgreSQL is known to support compilation using the compilers shipped with
86+
<productname>Visual Studio 2005</productname> to
87+
<productname>Visual Studio 2010</productname> (including Express editions),
88+
as well as standalone Windows SDK releases 6.0 to 7.1.
89+
64-bit PostgreSQL builds are only supported with
90+
<productname>Microsoft Windows SDK</productname> version 6.0a and above or
91+
<productname>Visual Studio 2008</productname> and above.
9892
</para>
9993

10094
<para>
@@ -104,11 +98,13 @@
10498
<productname>Cygwin</productname> present in your system PATH. Also, make
10599
sure you have all the required Visual C++ tools available in the PATH. In
106100
<productname>Visual Studio</productname>, start the
107-
<application>Visual Studio Command Prompt</application>. In the
108-
<productname>Platform SDK</productname>, start the
109-
<application>CMD shell</application> listed under the SDK on the Start Menu.
101+
<application>Visual Studio Command Prompt</application>.
110102
If you wish to build a 64-bit version, you must use the 64-bit version of
111103
the command, and vice versa.
104+
In the <productname>Microsoft Windows SDK</productname>, start the
105+
<application>CMD shell</application> listed under the SDK on the Start Menu.
106+
In recent SDK versions you can change the targeted CPU architecture by using
107+
the <command>setenv</command> command.
112108
All commands should be run from the <filename>src\tools\msvc</filename>
113109
directory.
114110
</para>
@@ -148,17 +144,17 @@ $ENV{PATH}=$ENV{PATH} . ';c:\some\where\bison\bin';
148144

149145
<variablelist>
150146
<varlistentry>
151-
<term><productname>Microsoft Platform SDK</productname></term>
147+
<term><productname>Microsoft Windows SDK</productname></term>
152148
<listitem><para>
153149
It is recommended that you upgrade to the latest supported version
154-
of the <productname>Microsoft Platform SDK</productname> (currently
155-
version 7.0), available for download from
150+
of the <productname>Microsoft Windows SDK</productname> (currently
151+
version 7.1), available for download from
156152
<ulink url="http://www.microsoft.com/downloads/"></>.
157153
</para>
158154
<para>
159155
You must always include the
160156
<application>Windows Headers and Libraries</application> part of the SDK.
161-
If you install the <productname>Platform SDK</productname>
157+
If you install the <productname>Windows SDK</productname>
162158
including the <application>Visual C++ Compilers</application>,
163159
you don't need <productname>Visual Studio</productname> to build.
164160
</para></listitem>
@@ -202,6 +198,10 @@ $ENV{PATH}=$ENV{PATH} . ';c:\some\where\bison\bin';
202198
Bison can be downloaded from <ulink url="http://gnuwin32.sourceforge.net"></>.
203199
Flex can be downloaded from
204200
<ulink url="http://www.postgresql.org/ftp/misc/winflex/"></>.
201+
If you are using <productname>msysGit</productname> for accessing the
202+
PostgreSQL <productname>Git</productname> repository you probably already
203+
have recent versions of bison and flex in your <productname>Git</productname>
204+
binary directory.
205205
</para>
206206

207207
<note>
@@ -479,7 +479,7 @@ $ENV{DOCROOT}='c:\docbook';
479479
static library to link into an application. For normal use the
480480
<productname>MinGW</productname> or
481481
<productname>Visual Studio</productname> or
482-
<productname>Platform SDK</productname> method is recommended.
482+
<productname>Windows SDK</productname> method is recommended.
483483
</para>
484484

485485
<para>

src/include/port/win32.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@
103103
#define IPC_STAT 4096
104104

105105
#define EACCESS 2048
106+
#ifndef EIDRM
106107
#define EIDRM 4096
108+
#endif
107109

108110
#define SETALL 8192
109111
#define GETNCNT 16384
@@ -299,6 +301,26 @@ typedef int pid_t;
299301
#define EOPNOTSUPP WSAEOPNOTSUPP
300302
#endif
301303

304+
/*
305+
* For Microsoft Visual Studio 2010 and above we intentionally redefine
306+
* the regular Berkeley error constants and set them to the WSA constants.
307+
* Note that this will break if those constants are used for anything else
308+
* than Windows Sockets errors.
309+
*/
310+
#if _MSC_VER >= 1600
311+
#pragma warning(disable:4005)
312+
#define EMSGSIZE WSAEMSGSIZE
313+
#define EAFNOSUPPORT WSAEAFNOSUPPORT
314+
#define EWOULDBLOCK WSAEWOULDBLOCK
315+
#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
316+
#define ECONNRESET WSAECONNRESET
317+
#define EINPROGRESS WSAEINPROGRESS
318+
#define ENOBUFS WSAENOBUFS
319+
#define ECONNREFUSED WSAECONNREFUSED
320+
#define EOPNOTSUPP WSAEOPNOTSUPP
321+
#pragma warning(default:4005)
322+
#endif
323+
302324
/*
303325
* Extended locale functions with gratuitous underscore prefixes.
304326
* (These APIs are nevertheless fully documented by Microsoft.)

src/tools/msvc/Install.pm

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,8 @@ sub Install
5656
my $majorver = DetermineMajorVersion();
5757
print "Installing version $majorver for $conf in $target\n";
5858

59-
EnsureDirectories(
60-
$target, 'bin', 'lib', 'share',
61-
'share/timezonesets','share/extension', 'share/contrib','doc',
62-
'doc/extension', 'doc/contrib','symbols', 'share/tsearch_data'
63-
);
59+
EnsureDirectories($target, 'bin', 'lib', 'share','share/timezonesets','share/extension',
60+
'share/contrib','doc','doc/extension', 'doc/contrib','symbols', 'share/tsearch_data');
6461

6562
CopySolutionOutput($conf, $target);
6663
lcopy($target . '/lib/libpq.dll', $target . '/bin/libpq.dll');
@@ -186,6 +183,13 @@ sub CopySolutionOutput
186183
my $rem = qr{Project\("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}"\) = "([^"]+)"};
187184

188185
my $sln = read_file("pgsql.sln") || croak "Could not open pgsql.sln\n";
186+
187+
my $vcproj = 'vcproj';
188+
if ($sln =~ /Microsoft Visual Studio Solution File, Format Version (\d+)\.\d+/ && $1 >= 11)
189+
{
190+
$vcproj = 'vcxproj';
191+
}
192+
189193
print "Copying build output files...";
190194
while ($sln =~ $rem)
191195
{
@@ -195,26 +199,48 @@ sub CopySolutionOutput
195199

196200
$sln =~ s/$rem//;
197201

198-
my $proj = read_file("$pf.vcproj") || croak "Could not open $pf.vcproj\n";
199-
if ($proj !~ qr{ConfigurationType="([^"]+)"})
202+
my $proj = read_file("$pf.$vcproj") || croak "Could not open $pf.$vcproj\n";
203+
if ($vcproj eq 'vcproj' && $proj =~ qr{ConfigurationType="([^"]+)"})
200204
{
201-
croak "Could not parse $pf.vcproj\n";
202-
}
203-
if ($1 == 1)
204-
{
205-
$dir = "bin";
206-
$ext = "exe";
205+
if ($1 == 1)
206+
{
207+
$dir = "bin";
208+
$ext = "exe";
209+
}
210+
elsif ($1 == 2)
211+
{
212+
$dir = "lib";
213+
$ext = "dll";
214+
}
215+
else
216+
{
217+
218+
# Static lib, such as libpgport, only used internally during build, don't install
219+
next;
220+
}
207221
}
208-
elsif ($1 == 2)
222+
elsif ($vcproj eq 'vcxproj' && $proj =~ qr{<ConfigurationType>(\w+)</ConfigurationType>})
209223
{
210-
$dir = "lib";
211-
$ext = "dll";
224+
if ($1 eq 'Application')
225+
{
226+
$dir = "bin";
227+
$ext = "exe";
228+
}
229+
elsif ($1 eq 'DynamicLibrary')
230+
{
231+
$dir = "lib";
232+
$ext = "dll";
233+
}
234+
else # 'StaticLibrary'
235+
{
236+
237+
# Static lib, such as libpgport, only used internally during build, don't install
238+
next;
239+
}
212240
}
213241
else
214242
{
215-
216-
# Static lib, such as libpgport, only used internally during build, don't install
217-
next;
243+
croak "Could not parse $pf.$vcproj\n";
218244
}
219245
lcopy("$conf\\$pf\\$pf.$ext","$target\\$dir\\$pf.$ext")
220246
|| croak "Could not copy $pf.$ext\n";
@@ -470,8 +496,7 @@ sub CopyIncludeFiles
470496
$target . '/include/server/',
471497
'src/include/', 'pg_config.h', 'pg_config_os.h'
472498
);
473-
CopyFiles('Grammar header', $target . '/include/server/parser/','src/backend/parser/',
474-
'gram.h');
499+
CopyFiles('Grammar header', $target . '/include/server/parser/','src/backend/parser/','gram.h');
475500
CopySetOfFiles('',[ glob("src\\include\\*.h") ],$target . '/include/server/');
476501
my $D;
477502
opendir($D, 'src/include') || croak "Could not opendir on src/include!\n";

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy