Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem in building go software for windows #79

Open
BaseMax opened this issue Mar 23, 2021 · 4 comments
Open

Problem in building go software for windows #79

BaseMax opened this issue Mar 23, 2021 · 4 comments

Comments

@BaseMax
Copy link

BaseMax commented Mar 23, 2021

Hi everyone
Why cannot compile program for windows, while this works as well for Linux?

This library have neutralized the language cross platform supporting? Or i miss something?

[max@base test-program]$ env GOOS=windows GOARCH=amd64 go build

# github.com/basemax/test-program
./main.go:139:13: undefined: curl.EasyInit
./main.go:142:17: undefined: curl.OPT_URL
./main.go:164:17: undefined: curl.OPT_POSTFIELDS
./main.go:166:17: undefined: curl.OPT_HTTPHEADER
./main.go:179:17: undefined: curl.OPT_PROXY
./main.go:182:17: undefined: curl.OPT_PROXYTYPE
./main.go:182:37: undefined: curl.PROXY_SOCKS5
./main.go:184:17: undefined: curl.OPT_HEADER
./main.go:185:17: undefined: curl.OPT_WRITEFUNCTION

[max@base test-program]$ env GOOS=windows GOARCH=386 go build

# github.com/basemax/test-program
./main.go:139:13: undefined: curl.EasyInit
./main.go:142:17: undefined: curl.OPT_URL
./main.go:164:17: undefined: curl.OPT_POSTFIELDS
./main.go:166:17: undefined: curl.OPT_HTTPHEADER
./main.go:179:17: undefined: curl.OPT_PROXY
./main.go:182:17: undefined: curl.OPT_PROXYTYPE
./main.go:182:37: undefined: curl.PROXY_SOCKS5
./main.go:184:17: undefined: curl.OPT_HEADER
./main.go:185:17: undefined: curl.OPT_WRITEFUNCTION

[max@base test-program]$ env GOOS=linux GOARCH=amd64 go build

no error, and good

[max@base test-program]$ cat go.mod

module github.com/basemax/test-program

go 1.13

require github.com/andelf/go-curl v0.0.0-20200630032108-fd49ff24ed97 // indirect

[max@base test-program]$ cat go.sum

github.com/andelf/go-curl v0.0.0-20200630032108-fd49ff24ed97 h1:Nyfs+rh56aORy2tGMI9GCYEqTfePwL1v47qOzebfv/o=
github.com/andelf/go-curl v0.0.0-20200630032108-fd49ff24ed97/go.mod h1:WO1d2m1QDzkoPcgn9lgHVMi7qQR5j3jxYjIIvMTHpC0=

main.go source code:

package main

import (
    "io"
    "os"
    "time"
    "strings"
    "bytes"
    "math"
    "sync"
    "flag"
    "fmt"
    "runtime"
    "bufio"
    // "math/rand"
    curl "github.com/andelf/go-curl"
)

....
....
....

[max@base test-program]$ go version

go version go1.16.2 linux/amd64

[max@base test-program]$ uname -a

Linux base 5.9.16-1-MANJARO #1 SMP PREEMPT Mon Dec 21 22:00:46 UTC 2020 x86_64 GNU/Linux

[max@base test-program]$ curl --version

curl 7.75.0 (x86_64-pc-linux-gnu) libcurl/7.75.0 OpenSSL/1.1.1j zlib/1.2.11 zstd/1.4.9 libidn2/2.3.0 libpsl/0.21.1 (+libidn2/2.3.0) libssh2/1.9.0 nghttp2/1.43.0
Release-Date: 2021-02-03
Protocols: dict file ftp ftps gopher gophers http https imap imaps mqtt pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp 
Features: alt-svc AsynchDNS GSS-API HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL TLS-SRP UnixSockets zstd

[max@base test-program]$ yay mingw

5 community/mingw-w64-winpthreads 8.0.0-1 (213.6 KiB 1.8 MiB) [mingw-w64-toolchain mingw-w64] 
    MinGW-w64 winpthreads library
4 community/mingw-w64-headers 8.0.0-1 (9.4 MiB 112.5 MiB) [mingw-w64-toolchain mingw-w64] 
    MinGW-w64 headers for Windows
3 community/mingw-w64-gcc 10.2.0-2 (143.5 MiB 885.1 MiB) [mingw-w64-toolchain mingw-w64] 
    Cross GCC for the MinGW-w64 cross-compiler
2 community/mingw-w64-crt 8.0.0-1 (5.5 MiB 141.0 MiB) [mingw-w64-toolchain mingw-w64] 
    MinGW-w64 CRT for Windows
1 community/mingw-w64-binutils 2.35.1-1 (4.3 MiB 46.4 MiB) [mingw-w64-toolchain mingw-w64] 
    Cross binutils for the MinGW-w64 cross-compiler
==> Packages to install (eg: 1 2 3, 1-3 or ^4)
==> 1,2,3,4,5
resolving dependencies...
looking for conflicting packages...

Packages (5) mingw-w64-binutils-2.35.1-1  mingw-w64-crt-8.0.0-1  mingw-w64-gcc-10.2.0-2  mingw-w64-headers-8.0.0-1  mingw-w64-winpthreads-8.0.0-1

Total Download Size:    162.96 MiB
Total Installed Size:  1186.75 MiB

:: Proceed with installation? [Y/n] y
:: Retrieving packages...
 mingw-w64-winpthreads-8.0.0-1-any                                                     213.6 KiB   234 KiB/s 00:01 [####################################################################]   0%
 mingw-w64-headers-8.0.0-1-any                                                           9.6 MiB   408 KiB/s 00:24 [####################################################################]   5%
 mingw-w64-crt-8.0.0-1-any                                                              15.2 MiB   450 KiB/s 00:34 [####################################################################]   9%
 mingw-w64-binutils-2.35.1-1-x86_64                                                     19.5 MiB   471 KiB/s 00:42 [####################################################################]  11%
 mingw-w64-gcc-10.2.0-2-x86_64                                                         163.0 MiB   656 KiB/s 04:14 [####################################################################] 100%
(5/5) checking keys in keyring                                                                                     [####################################################################] 100%
(5/5) checking package integrity                                                                                   [####################################################################] 100%
(5/5) loading package files                                                                                        [####################################################################] 100%
(5/5) checking for file conflicts                                                                                  [####################################################################] 100%
(5/5) checking available disk space                                                                                [####################################################################] 100%
:: Processing package changes...
(1/5) installing mingw-w64-winpthreads                                                                             [####################################################################] 100%
(2/5) installing mingw-w64-headers                                                                                 [####################################################################] 100%
(3/5) installing mingw-w64-crt                                                                                     [####################################################################] 100%
(4/5) installing mingw-w64-binutils                                                                                [####################################################################] 100%
(5/5) installing mingw-w64-gcc                                                                                     [####################################################################] 100%
:: Running post-transaction hooks...
(1/2) Arming ConditionNeedsUpdate...
(2/2) Updating the info directory file...
@sergerdn
Copy link

sergerdn commented Sep 1, 2021

Have you tried with CGO_ENABLED=1?
E.g.:

env GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build ....

@abelhoula
Copy link

cc @andelf

@andelf
Copy link
Owner

andelf commented Jun 23, 2022

@abelhoula I haven't written in Go for some years.
Will try to find a Windows machine and check this. Thanks for your report.

@SaraTahiri97
Copy link

wondering if this issue was fixed or not ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants