我有以下问题。我有一个为每个OS和ARCH构建的简单Golang应用程序。我所说的操作系统是:
和拱门:
对于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
(源)。因此,仅Windows Server 2008不能满足内置二进制文件所需的最低Windows版本。
如果需要支持Windows Server 2008,请尝试使用Go 1.12进行构建。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句