keroserene / go-webrtc

WebRTC for Go
Other
455 stars 76 forks source link

[BSD] ctestenums.cc:2:48: fatal error: webrtc/api/peerconnectioninterface.h: No such file or directory #76

Open anadahz opened 6 years ago

anadahz commented 6 years ago

Why I'm here: go-webrtc is a snowflake dependency

go get github.com/keroserene/go-webrtc results in

ctestenums.cc:2:48: fatal error: webrtc/api/peerconnectioninterface.h: No such file or directory
compilation terminated.

% go env

go env
GOARCH="amd64"
GOBIN="/home/user/go/bin"
GOCACHE="/home/user/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="dragonfly"
GOOS="dragonfly"
GOPATH="/home/user/go"
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/dragonfly_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build032258926=/tmp/go-build -gno-record-gcc-switches"

Happy to provide any required details in order to help resolve this issue.

uumaro commented 6 years ago

Note that this is an attempt to build on BSD (GOOS="dragonfly").

The immediate cause is that the build is missing the -I option to include the files in the include directory.

That's because the -I option comes from webrtc-darwin-amd64.pc, webrtc-linux-386.pc, webrtc-linux-amd64.pc, or webrtc-linux-arm.pc. There isn't one yet for BSD.

You could try making a new file webrtc-dragonfly-amd64.pc containing the necessary flags. (-I${pc}/include is the crucial one for including the proper headers.) You may have to also add a new #cgo line to certain .go files, like here.

But then there will still be a problem, because there's no precompiled library for BSD in the lib directory. go-webrtc is an interface to a massive underlying C++ library. So the build will fail at the linking stage. Until we have a prebuilt library for BSD, you will have to compile the webrtc library yourself, and unfortunately it's a little involved. See build.sh and the "hard way" of README#Building. I don't know if anyone has tried building the library on BSD yet.

anadahz commented 6 years ago

@uumaro Thanks for your response.

I can try build go-webrtc in BSD but it seems that are many dependencies and things that may go wrong. Is there any related BSD go build script were I can start from?

uumaro commented 6 years ago

It's not the Go part of go-webrtc that's difficult to build. It's the WebRTC native code library that's big. (It's not really difficult to build, just huge (source code is ~9 GB).) You can try making some minor modifications to build.sh and see if it works, but I suspect you would be the first one to try it. Unfortunately, https://webrtc.org/native-code/development/ says "The currently supported platforms are Windows, Mac OS X, Linux, Android and iOS."

It may work on BSD anyway; for example we are cross-compiling linux→mac for Tor Browser, which isn't a supported configuration. But it took some patches to make it work.

anadahz commented 6 years ago

@uumaro great thanks for the guidelines. @egypcio is working on a freebsd port of snowflake.