• 2023.09.30使用golang1.18编译Hel10-Web/Databasetools的windows版


    #Go 1.21新增的 log/slog 完美解决了以上问题,并且带来了很多其他很实用的特性。

    本次编译不使用log/slog 包

    1. su -
    2. echo $GOPATH ;echo $GOROOT;
    3. cd /tmp;
    4. busybox wget --no-check-certificate https://go.dev/dl/go1.18.linux-amd64.tar.gz;\
    5. which tar&&tar -xvf go1.18.linux-amd64.tar.gz >/dev/null &
    6. cd /tmp;
    7. git clone https://github.com/Hel10-Web/Databasetools;
    8. cd /tmp/Databasetools;
    9. /tmp/go/bin/go env -w GO111MODULE=on ;
    10. /tmp/go/bin/go get github.com/godror/godror@v0.36.0
    11. /tmp/go/bin/go get ;
    12. /tmp/go/bin/go install;
    13. /tmp/go/bin/go build -ldflags="-s -w" -o Databasetools_x64.elf main.go;
    14. ./Databasetools_x64.elf --help

    package log/slog is not in GOROOT (/opt/hostedtoolcache/go/1.20.8/x64/src/log/slog)

    #/root/go/pkg/mod/github.com/godror/godror@v0.40.2/drv.go:85:2: package log/slog is not in GOROOT (/opt/hostedtoolcache/go/1.20.8/x64/src/log/slog)

    1. root@fv-az180-891:/tmp/Databasetools# go install github.com/godror/godror@v0.36.0
    2. package github.com/godror/godror is not a main package
    3. root@fv-az180-891:/tmp/Databasetools#
    1. root@fv-az180-891:/tmp/Databasetools# go list -m github.com/godror/godror
    2. github.com/godror/godror v0.36.0
    3. root@fv-az180-891:/tmp/Databasetools#

    继续编译Windows下的exe文件:

    1. #apt-get update;
    2. apt-get install -y gcc-multilib gcc-mingw-w64
    3. /tmp/go/bin/go env -w CGO_ENABLED=1
    4. /tmp/go/bin/go env -w GOOS=windows
    5. /tmp/go/bin/go env -w GO111MODULE=on
    6. /tmp/go/bin/go env -w CC=x86_64-w64-mingw32-gcc
    7. #/tmp/go/bin/go env -w CXX_FOR_TARGET=i686-w64-mingw32-g++
    8. #/tmp/go/bin/go env -w CC_FOR_TARGET=i686-w64-mingw32-gcc
    9. #/tmp/go/bin/go build -ldflags="-s -w" -buildmode=c-shared -o Databasetools_x64.exe main.go
    10. /tmp/go/bin/go build -ldflags="-s -w" -o Databasetools_x64a.exe main.go

    1. root@fv-az180-891:/tmp/Databasetools# file Databasetools_x64.exe
    2. Databasetools_x64.exe: PE32+ executable (DLL) (console) x86-64 (stripped to external PDB), for MS Windows
    3. root@fv-az180-891:/tmp/Databasetools# file Databasetools_x64.elf
    4. Databasetools_x64.elf: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=6f277746fbc5dc1b221106549984bd56072a5059, for GNU/Linux 3.2.0, stripped
    5. root@fv-az180-891:/tmp/Databasetools# /tmp/go/bin/go build -ldflags="-s -w" -o Databasetools_x64a.exe main.go
    6. root@fv-az180-891:/tmp/Databasetools# file Databasetools_x64a.exe
    7. Databasetools_x64a.exe: PE32+ executable (console) x86-64 (stripped to external PDB), for MS Windows
    8. root@fv-az180-891:/tmp/Databasetools#
    9. root@fv-az180-891:/tmp/Databasetools# ls -al
    10. total 35980
    11. drwxr-xr-x 6 root root 4096 Sep 30 05:21 .
    12. drwxrwxrwt 21 root root 4096 Sep 30 05:21 ..
    13. drwxr-xr-x 8 root root 4096 Sep 30 05:02 .git
    14. -rw-r--r-- 1 root root 66 Sep 30 05:01 .gitattributes
    15. -rwxr-xr-x 1 root root 12170392 Sep 30 05:02 Databasetools_x64.elf
    16. -rw-r--r-- 1 root root 12254208 Sep 30 05:17 Databasetools_x64.exe
    17. -rwxr-xr-x 1 root root 12255744 Sep 30 05:21 Databasetools_x64a.exe
    18. -rw-r--r-- 1 root root 57 Sep 30 05:01 crontab.txt
    19. drwxr-xr-x 2 root root 4096 Sep 30 05:01 driver
    20. -rw-r--r-- 1 root root 16896 Sep 30 05:01 exp.dll
    21. -rw-r--r-- 1 root root 44320 Sep 30 05:01 exp.so
    22. -rw-r--r-- 1 root root 1041 Sep 30 05:01 go.mod
    23. -rw-r--r-- 1 root root 7667 Sep 30 05:01 go.sum
    24. -rw-r--r-- 1 root root 75 Sep 30 05:01 main.go
    25. -rw-r--r-- 1 root root 62 Sep 30 05:01 out.json
    26. drwxr-xr-x 2 root root 4096 Sep 30 05:01 pac
    27. -rw-r--r-- 1 root root 25960 Sep 30 05:01 readme.md
    28. drwxr-xr-x 2 root root 4096 Sep 30 05:01 shell
    29. -rw-r--r-- 1 root root 18 Sep 30 05:01 shell.txt
    30. -rw-r--r-- 1 root root 1 Sep 30 05:01 ssh.txt
    31. root@fv-az180-891:/tmp/Databasetools#

    golang在 ubuntu下交叉编译报错 gcc: error: unrecognized command line option ‘-mthreads’; did you mean ‘-pthread’?icon-default.png?t=N7T8https://www.cnblogs.com/gatling/p/17203379.htmlGolang CGO Mac 交叉编译 Windows | Razeen`s Blog

    1. root@fv-az589-754:/tmp/Databasetools# GO111MODULE=on CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-w -s" -o gossh99.exe main.go;
    2. # github.com/godror/godror
    3. /root/go/pkg/mod/github.com/godror/godror@v0.36.0/orahlp.go:531:19: undefined: VersionInfo
    4. /root/go/pkg/mod/github.com/godror/godror@v0.36.0/orahlp.go:532:19: undefined: VersionInfo
    5. /root/go/pkg/mod/github.com/godror/godror@v0.36.0/orahlp.go:533:10: undefined: StartupMode
    6. /root/go/pkg/mod/github.com/godror/godror@v0.36.0/orahlp.go:534:11: undefined: ShutdownMode
    7. /root/go/pkg/mod/github.com/godror/godror@v0.36.0/orahlp.go:536:31: undefined: Event
    8. /root/go/pkg/mod/github.com/godror/godror@v0.36.0/orahlp.go:536:42: undefined: SubscriptionOption
    9. /root/go/pkg/mod/github.com/godror/godror@v0.36.0/orahlp.go:536:64: undefined: Subscription
    10. /root/go/pkg/mod/github.com/godror/godror@v0.36.0/orahlp.go:537:31: undefined: ObjectType
    11. /root/go/pkg/mod/github.com/godror/godror@v0.36.0/orahlp.go:538:59: undefined: Data
    12. /root/go/pkg/mod/github.com/godror/godror@v0.36.0/orahlp.go:539:28: undefined: DirectLob
    13. /root/go/pkg/mod/github.com/godror/godror@v0.36.0/orahlp.go:539:28: too many errors

  • 相关阅读:
    DispatcherServlet源码详解
    Mysql数据库和SQL语句
    未来数字化转型发展的前景如何,企业又该怎么实现?
    【docker-compose 跨节点部署 kafka-kraft SASL用户加密集群】全网最新!
    Java中的泛型
    肝了30天,终于整出这份Java面试九大核心专题,收割4个大厂offer
    【YashanDB知识库】数据变化率超过阈值统计信息失效
    面向对象编程原则(06)——依赖倒转原则
    BI如何配置“花生壳”,看这一篇就够了
    项目中索引的真实应用场景-2022新项目
  • 原文地址:https://blog.csdn.net/qq_29060627/article/details/133431658