I'm trying to build a. dll file to extend the postgres server with C functions.
I'm using visual studio 2012 to build the dll, and PostgreSQL 9.2. I imported all directories postgres "\include\server*"
But I'm having the errors:
error C2011: 'timezone': 'struct' type redefinition
error C2011: 'itimerval': 'struct' type redefinition
In the file *pg_confi_os.h* at line 205 and 214
I tried this solution but had no success.
How to solve this problem?
I took a look at this today and found that it's a bug in the PostgreSQL include files. See this mailing list post.
You can work around it by explicitly defining WIN32 in your project file's preprocessor directives.
See my blog post on the topic today
The postgresql team did answer me:
In the first place, Note that VS2012 is not (yet) a supported build
environment for Postgres. See
http://www.postgresql.org/docs/current/static/install-windows-full.html
cheers
The another answer:
First, you'll want to build with Visual Studio 2010 or older. The Express edition works fine.
Second, it's very unlikely that you can just compile the extension .c file stand-alone. You'll need to set a bunch of preprocesor definitions, some of which are somewhat configuration/environment specific.
The best way to compile extensions at the moment may be to get the PostgreSQL source tree, add your extension as a folder inside the contrib/ directory with a Makefile, then use the tooling in src/tools/msvc to compile the source tree including the extension.
I would really like to see this improve, with a working PGXS alternative for Windows MSVC builds. I'm not presently aware of anything, but I haven't investigated building extensions out of tree under Windows/MSVC in detail yet.
--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services