postgresqlgosqlc

how to install sqlc for golang in windows


when i run the command:

go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest

i get an error :

C:\Program Files\Go\pkg\tool\windows_amd64\link.exe: running gcc failed: exit status 1
C:\Users\aymen\AppData\Local\Temp\go-link-3004266855\000005.o: In function `_fingerprintVar':
C:/Users/aymen/go/pkg/mod/github.com/pganalyze/pg_query_go/v5@v5.1.0/parser/include/pg_query_fingerprint_defs.c:660: undefined reference to `__stack_chk_fail'  
C:\Users\aymen\AppData\Local\Temp\go-link-3004266855\000005.o: In function `_fingerprintJsonReturning':
C:/Users/aymen/go/pkg/mod/github.com/pganalyze/pg_query_go/v5@v5.1.0/parser/include/pg_query_fingerprint_defs.c:2547: undefined reference to `__stack_chk_fail' 
C:\Users\aymen\AppData\Local\Temp\go-link-3004266855\000005.o: In function `_fingerprintRTEPermissionInfo':
C:/Users/aymen/go/pkg/mod/github.com/pganalyze/pg_query_go/v5@v5.1.0/parser/include/pg_query_fingerprint_defs.c:5932: undefined reference to `__stack_chk_fail' 
C:\Users\aymen\AppData\Local\Temp\go-link-3004266855\000005.o: In function `_fingerprintNode':
C:\Users\aymen\go\pkg\mod\github.com\pganalyze\pg_query_go\v5@v5.1.0\parser/pg_query_fingerprint.c:310: undefined reference to `__stack_chk_fail'
C:\Users\aymen\AppData\Local\Temp\go-link-3004266855\000005.o: In function `_fingerprintTableFunc':
C:/Users/aymen/go/pkg/mod/github.com/pganalyze/pg_query_go/v5@v5.1.0/parser/include/pg_query_fingerprint_defs.c:505: undefined reference to `__stack_chk_fail'  
C:\Users\aymen\AppData\Local\Temp\go-link-3004266855\000005.o:C:/Users/aymen/go/pkg/mod/github.com/pganalyze/pg_query_go/v5@v5.1.0/parser/include/pg_query_fingerprint_defs.c:919: more undefined references to `__stack_chk_fail' follow
collect2.exe: error: ld returned 1 exit status

i tried to change the path but i didn't get any result


Solution

  • It looks very likely that gcc (a compiler for C++) is not installed, or the path to it is not specified, or the version is too old. To get started, you can try the following:

    1. Install a new version of gcc
    2. Write the path to it in %PATH%
    3. open a new console and enter the command g++ --version to make sure that the path to the compiler is entered correctly
    4. try installing sqlc again

    There is also a simpler option, you can simply download a ready-made binary from the sqlc website (https://downloads.sqlc.dev/), if the new version does not start for some reason, then you can take older versions