pion / mediadevices

Go implementation of the MediaDevices API.
https://pion.ly/
MIT License
535 stars 122 forks source link

Compile error when using `codec/opus` in Ubuntu 22.04 #442

Open santiagos01 opened 2 years ago

santiagos01 commented 2 years ago

Your environment.

What did you do?

I tried importing github.com/pion/mediadevices/pkg/codec/opus.

What did you expect?

Successful compilation.

What happened?

Initially, I got the following error:

# github.com/pion/mediadevices/pkg/codec/opus
vendor/github.com/pion/mediadevices/pkg/codec/opus/opus.go:17:10: fatal error: opus.h: No such file or directory
   17 | #include <opus.h>
      |          ^~~~~~~~
compilation terminated.

After realizing that the package couldn't seem to locate opus.h, I tried to add #cgo pkg-config: opus above the include and got the following new error:

# github.com/pion/mediadevices/pkg/codec/opus
/usr/bin/ld: cannot find vendor/github.com/pion/mediadevices/pkg/codec/opus/lib/libopus-linux-x64.a: No such file or directory
collect2: error: ld returned 1 exit status

Note: I had already installed the dependencies using sudo apt-get install libopus-dev libopus0 opus-tools.


I suspect the initial issue happened because the package is within the vendor directory, not sure if I'm supposed to somehow use the Makefile within the codec/opus package. The second issue I guess happened because I don't seem to have libopus-linux-x64.a. Not sure if this is already documented somewhere? Any help would be appreciated!

Also, fyi, I could successfully compile examples/webrtc when I git clone this repository (which imports the codec/opus package). I only encounter this compilation error when importing mediadevices into my own project, where the package would be placed under vendor directory.