Shaun
Shaun

Reputation: 2052

Building a C Program using PostgreSQL on Windows with Visual Studio Community 2015

I'm trying to go through an example using C and PostgreSQL, but I'm unable to find the libpq-fe.h when I try to compile through Visual Studio Community 2015 on Windows. I've looked at this answer related to adding aditional dependencies, but the compiler keeps giving me the error:

C1083: Cannot open include file: 'libpq-fe.h': No such file or directory

In the Project Properties > Configuration Properties I've added the location for the libpq-fe.h header:

C/C++ > General > Additional Include Directories: C:\Program Files\PostgreSQL\9.5\include\libpq

As well as the library location:

Linker > General > Additional Library Directories: C:\Program Files\PostgreSQL\9.5\lib
Linker > Input > Additional Dependencies: libpq.lib

I haven't even started adding the PostgreSQL related code yet, here's the start of my main application, the error comes from line 3:

#include<stdio.h>
#include<stdlib.h>
#include<libpq-fe.h>

int main(void) {

Is there a step I'm missing or am I using the wrong property settings for VS2015?

Upvotes: 0

Views: 4556

Answers (1)

Eelke
Eelke

Reputation: 22013

I assume you installed postgresql using the enterpriseDB installer.

The include path should be C:\Program Files\PostgreSQL\9.5\include without libpq. Also make sure you set the settings for the same combination of Configuration and Platform as you are building.

Upvotes: 2

Related Questions