Skip to content

Unable to build on Windows #137

Open
@CaptainKraft

Description

@CaptainKraft

When trying to build via the Windows command prompt, I get these errors:

# crawshaw.io/sqlite
In file included from _cgo_export.c:4:
cgo-gcc-export-header-prolog:49:34: error: redeclaration of 'go_sqlite_auth_tramp' cannot add 'dllexport' attribute
auth.go:5:13: note: previous declaration is here
cgo-gcc-export-header-prolog:50:35: warning: redeclaration of 'func_tramp' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
func.go:22:14: note: previous declaration is here
cgo-gcc-export-header-prolog:51:35: warning: redeclaration of 'step_tramp' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
func.go:23:14: note: previous declaration is here
cgo-gcc-export-header-prolog:52:35: warning: redeclaration of 'final_tramp' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
func.go:24:14: note: previous declaration is here
cgo-gcc-export-header-prolog:54:34: warning: redeclaration of 'go_strm_w_tramp' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
session.go:22:13: note: previous declaration is here
cgo-gcc-export-header-prolog:55:34: warning: redeclaration of 'go_strm_r_tramp' should not add 'dllexport' attribute [-Wdll-attribute-on-redeclaration]
session.go:23:13: note: previous declaration is here
cgo-gcc-export-header-prolog:58:35: error: redeclaration of 'log_fn' cannot add 'dllexport' attribute
sqlite.go:55:14: note: previous declaration is here

After installing cygwin and the appropriate libraries, I get this error when trying to build:

C:\Program Files\Go\pkg\tool\windows_amd64\link.exe: running gcc failed: exit status 1
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: cannot find -lwinpthread: No such file or directory
collect2: error: ld returned 1 exit status

This is at the bottom of the README: By default it requires some pthreads DLL on Windows. To avoid it, supply CGOLDFLAGS="-static" when building your application.

But, setting CGOLDFLAGS to "-static" does nothing. However, in cygwin, if I export CGO_LDFLAGS to "-static", then I get a new error:

# runtime/cgo
gcc_libinit_windows.c: In function ‘_cgo_beginthread’:
gcc_libinit_windows.c:136:27: error: implicit declaration of function ‘_beginthread’; did you mean ‘_cgo_beginthread’? [-Werror=implicit-function-declaration]
  136 |                 thandle = _beginthread(func, 0, arg);
      |                           ^~~~~~~~~~~~
      |                           _cgo_beginthread
cc1: all warnings being treated as errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions