在 Windows Server 2008 上出现“不是有效的 Win32 应用程序”错误
来源:stackoverflow
时间:2024-03-03 13:57:26 183浏览 收藏
一分耕耘,一分收获!既然打开了这篇文章《在 Windows Server 2008 上出现“不是有效的 Win32 应用程序”错误》,就坚持看下去吧!文中内容包含等等知识点...希望你能在阅读本文后,能真真实实学到知识或者帮你解决心中的疑惑,也欢迎大佬或者新人朋友们多留言评论,多给建议!谢谢!
我遇到以下问题。我有一个为每个操作系统和 arch 构建的简单 golang 应用程序。我的意思是操作系统:
- windows(goos=windows)
- osx(它是在 osx 机器上构建的)
和拱门:
- 32 (goarch=amd64)
- 64 (goarch=386)
在 mac os x、windows server 2008+ 上一切正常。但当我尝试在 windows server 2008 sp2 上运行已编译的应用程序时遇到问题。我收到以下错误:
app.exe is not a valid win32 application
当尝试从 powershell 运行时:
the specified executable is not a valid application for this os platform
我的申请与此几乎是 1:1
如果链接将来不起作用,请使用以下代码:
package main import ( "fmt" "time" "github.com/pion/webrtc/v3" "github.com/pion/webrtc/v3/examples/internal/signal" ) func main() { // Everything below is the Pion WebRTC API! Thanks for using it ❤️. // Prepare the configuration config := webrtc.Configuration{ ICEServers: []webrtc.ICEServer{ { URLs: []string{"stun:stun.l.google.com:19302"}, }, }, } // Create a new RTCPeerConnection peerConnection, err := webrtc.NewPeerConnection(config) if err != nil { panic(err) } // Set the handler for ICE connection state // This will notify you when the peer has connected/disconnected peerConnection.OnICEConnectionStateChange(func(connectionState webrtc.ICEConnectionState) { fmt.Printf("ICE Connection State has changed: %s\n", connectionState.String()) }) // Register data channel creation handling peerConnection.OnDataChannel(func(d *webrtc.DataChannel) { fmt.Printf("New DataChannel %s %d\n", d.Label(), d.ID()) // Register channel opening handling d.OnOpen(func() { fmt.Printf("Data channel '%s'-'%d' open. Random messages will now be sent to any connected DataChannels every 5 seconds\n", d.Label(), d.ID()) for range time.NewTicker(5 * time.Second).C { message := signal.RandSeq(15) fmt.Printf("Sending '%s'\n", message) // Send the message as text sendErr := d.SendText(message) if sendErr != nil { panic(sendErr) } } }) // Register text message handling d.OnMessage(func(msg webrtc.DataChannelMessage) { fmt.Printf("Message from DataChannel '%s': '%s'\n", d.Label(), string(msg.Data)) }) }) // Wait for the offer to be pasted offer := webrtc.SessionDescription{} signal.Decode(signal.MustReadStdin(), &offer) // Set the remote SessionDescription err = peerConnection.SetRemoteDescription(offer) if err != nil { panic(err) } // Create an answer answer, err := peerConnection.CreateAnswer(nil) if err != nil { panic(err) } // Create channel that is blocked until ICE Gathering is complete gatherComplete := webrtc.GatheringCompletePromise(peerConnection) // Sets the LocalDescription, and starts our UDP listeners err = peerConnection.SetLocalDescription(answer) if err != nil { panic(err) } // Block until ICE Gathering is complete, disabling trickle ICE // we do this because we only can exchange one signaling message // in a production application you should exchange ICE Candidates via OnICECandidate <-gatherComplete // Output the answer in base64 so we can paste it in browser fmt.Println(signal.Encode(*peerConnection.LocalDescription())) // Block forever select {} }
我正在使用 go 1.14 并通过以下方式构建它:
go build -ldflags "-s -w" app.go
- 我也尝试过
go build app.go
但它没有改变:(
解决方案
我相信这是因为自 Go 1.13 起,内部链接的 Windows 二进制文件指定的 Windows 版本现在是 Windows 7:
内部链接的 Windows 二进制文件指定的 Windows 版本现在是 Windows 7 而不是 NT 4.0。这已经是 Go 所需的最低版本,但可能会影响具有向后兼容模式的系统调用的行为。这些现在将按照记录的方式运行。外部链接的二进制文件(任何使用 cgo 的程序)始终指定更新的 Windows 版本。
Windows 7 已发布版本 NT 6.1
,Windows Server 2008 已发布版本 NT 6.0
(source)。因此,Windows Server 2008 不满足构建的二进制文件所需的最低 Windows 版本。
如果您需要支持 Windows Server 2008,请尝试使用 Go 1.12 构建它。
到这里,我们也就讲完了《在 Windows Server 2008 上出现“不是有效的 Win32 应用程序”错误》的内容了。个人认为,基础知识的学习和巩固,是为了更好的将其运用到项目中,欢迎关注golang学习网公众号,带你了解更多关于的知识点!
-
502 收藏
-
502 收藏
-
501 收藏
-
501 收藏
-
501 收藏
-
139 收藏
-
204 收藏
-
325 收藏
-
477 收藏
-
486 收藏
-
439 收藏
-
357 收藏
-
352 收藏
-
101 收藏
-
440 收藏
-
212 收藏
-
143 收藏
-
- 前端进阶之JavaScript设计模式
- 设计模式是开发人员在软件开发过程中面临一般问题时的解决方案,代表了最佳的实践。本课程的主打内容包括JS常见设计模式以及具体应用场景,打造一站式知识长龙服务,适合有JS基础的同学学习。
- 立即学习 542次学习
-
- GO语言核心编程课程
- 本课程采用真实案例,全面具体可落地,从理论到实践,一步一步将GO核心编程技术、编程思想、底层实现融会贯通,使学习者贴近时代脉搏,做IT互联网时代的弄潮儿。
- 立即学习 508次学习
-
- 简单聊聊mysql8与网络通信
- 如有问题加微信:Le-studyg;在课程中,我们将首先介绍MySQL8的新特性,包括性能优化、安全增强、新数据类型等,帮助学生快速熟悉MySQL8的最新功能。接着,我们将深入解析MySQL的网络通信机制,包括协议、连接管理、数据传输等,让
- 立即学习 497次学习
-
- JavaScript正则表达式基础与实战
- 在任何一门编程语言中,正则表达式,都是一项重要的知识,它提供了高效的字符串匹配与捕获机制,可以极大的简化程序设计。
- 立即学习 487次学习
-
- 从零制作响应式网站—Grid布局
- 本系列教程将展示从零制作一个假想的网络科技公司官网,分为导航,轮播,关于我们,成功案例,服务流程,团队介绍,数据部分,公司动态,底部信息等内容区块。网站整体采用CSSGrid布局,支持响应式,有流畅过渡和展现动画。
- 立即学习 484次学习