pg_query_go icon indicating copy to clipboard operation
pg_query_go copied to clipboard

Not able to build on windows

Open dharmjit opened this issue 5 years ago • 2 comments

Hi, I am tryoing to build this project on windows and getting below error

$ go get github.com/lfittl/pg_query_go                                                                                                 # github.com/lfittl/pg_query_go/parser                                                                                                 In file included from .\include/c.h:1129:0,                                                                                                             from .\include/postgres.h:47,                                                                                                          from contrib_pgcrypto_sha1.c:50:                                                                                      .\include/port.h:17:19: fatal error: netdb.h: No such file or directory                                                                compilation terminated.

I have tried the modules step as well but no success. I have searched for netdb.h and this file is not there in the include folder. How I can resolve this. Thanks

dharmjit avatar Jan 23 '20 06:01 dharmjit

Hi, Any update on this.

dharmjit avatar Jan 27 '20 11:01 dharmjit

I guess I have the same error as @dharmjit but the inline formatting really doesn't help in reading it 😅 (please fix it)

Microsoft Windows [Version 10.0.18363.778]
(c) 2019 Microsoft Corporation. All rights reserved.

D:\Federico\Projects>go get github.com/lfittl/pg_query_go
# github.com/lfittl/pg_query_go/parser
In file included from C:\Users\maxir\go\pkg\mod\github.com\lfittl\[email protected]\parser\include/c.h:1129,
                 from C:\Users\maxir\go\pkg\mod\github.com\lfittl\[email protected]\parser\include/postgres.h:47,
                 from contrib_pgcrypto_sha1.c:50:
C:\Users\maxir\go\pkg\mod\github.com\lfittl\[email protected]\parser\include/port.h:17:10: fatal error: netdb.h: No such file or directory
   17 | #include <netdb.h>
      |          ^~~~~~~~~
compilation terminated.

I really don't know what this is and what I'm talking about, so I tried a bare bone "googling" and a quick browsing led to similar issues in other codebases like here and here but you can find tons of them across multiple programming languages. From my understanding it all boils down to different dependencies under Windows and Unix.

Here is some info on the library.

The general agreement I found on the subject is to use a conditional including, under windows host the library to be used should be #include <winsock2.h> but further analysis is needed to pinpoint the fix.

Anyway the bug clearly isn't related specifically to github.com/lfittl/pg_query_go but rather to its external dependencies needs.


A temporary workaround I am using is to build my application in a linux docker container, not the best workflow but works.

maxiride avatar May 03 '20 11:05 maxiride