roc-streaming / roc-toolkit

Real-time audio streaming over the network.
https://roc-streaming.org
Mozilla Public License 2.0
1.06k stars 213 forks source link

Generate and install pkg-config file #347

Closed fusuiyi123 closed 4 years ago

fusuiyi123 commented 4 years ago

Fixes #271

fusuiyi123 commented 4 years ago

since I am new to the SCons I am not sure if I added to the right file and followed the right approach. I tried testing in ubuntu16.04 docker: I have

root@53b5d196e524:/Users/fusuiyi/Desktop/opensource/roc# scons -Q --enable-werror --build-3rdparty=openfec install
      GET   3rdparty/x86_64-pc-linux-gnu/gcc-5.4.0-release/build/openfec-1.4.2.4
[download] https://github.com/roc-project/openfec/archive/v1.4.2.4.tar.gz
[extract] openfec_v1.4.2.4.tar.gz
[execute] cmake .. -DBUILD_STATIC_LIBS=ON -DDEBUG:STRING=OFF -DCMAKE_FIND_ROOT_PATH='' -DCMAKE_SYSROOT='' -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_C_COMPILER=/usr/bin/gcc-5 -DCMAKE_LINKER=/usr/bin/gcc-5 -DCMAKE_AR=/usr/bin/ar -DCMAKE_RANLIB=/usr/bin/ranlib -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS_RELEASE:STRING='-fPIC -fvisibility=hidden'
[execute] make -j2
[install] 3rdparty/x86_64-pc-linux-gnu/gcc-5.4.0-release/build/openfec-1.4.2.4/include
[install] 3rdparty/x86_64-pc-linux-gnu/gcc-5.4.0-release/build/openfec-1.4.2.4/lib/libopenfec.a
/usr/lib/x86_64-linux-gnu/pkgconfig
  INSTALL   /usr/lib/x86_64-linux-gnu/pkgconfig/libroc.pc
  INSTALL   /usr/include/roc
  INSTALL   /usr/lib/x86_64-linux-gnu/libroc.so.0.1
scons: *** [install] bin/x86_64-pc-linux-gnu/libroc.so.0.1: No such file or directory

/usr/lib/x86_64-linux-gnu/pkgconfig/libroc.pc is

prefix=/usr
exec_prefix=${prefix}
libdir=/usr/lib/x86_64-linux-gnu
includedir=${prefix}/include

Name: libroc
Requires: ragel cpputest gcc posixtime stdio pulseaudio libuv libunwind posix linux sox gengetopt glibc alsa
Version: 0.1.5
Description: Real-time audio streaming over the network.
URL: https://roc-project.github.io

Libs: -L${libdir} -lroc -lrt -lpthread -lnsl -ldl -lm
Cflags: -I${includedir}
gavv commented 4 years ago
scons: *** [install] bin/x86_64-pc-linux-gnu/libroc.so.0.1: No such file or directory

Could you run scons without -Q and post the output?

fusuiyi123 commented 4 years ago

in ubuntu-16.04

root@211f6f4baa3c:/Users/fusuiyi/Desktop/opensource/roc# scons --enable-werror --build-3rdparty=openfec install
scons: Reading SConscript files ...
Searching CXX executable... (cached) /usr/bin/g++-5
Searching CONFIG_GUESS script... (cached) /usr/share/misc/config.guess
Searching CC executable... (cached) /usr/bin/gcc-5
Searching CXXLD executable... (cached) /usr/bin/g++-5
Searching CCLD executable... (cached) /usr/bin/gcc-5
Searching AR executable... (cached) /usr/bin/ar (/usr/bin/x86_64-linux-gnu-ar)
Searching RANLIB executable... (cached) /usr/bin/ranlib (/usr/bin/x86_64-linux-gnu-ranlib)
Searching STRIP executable... (cached) /usr/bin/strip (/usr/bin/x86_64-linux-gnu-strip)
error: no result
Checking for C library uv... yes
error: no result
Checking for C library unwind... yes
Package atomic_ops was not found in the pkg-config search path.
Perhaps you should add the directory containing `atomic_ops.pc'
to the PKG_CONFIG_PATH environment variable
No package 'atomic_ops' found
error: no result
Checking for C library atomic_ops... no
error: libatomic_ops not found (see 'config.log' for details)
gavv commented 4 years ago

Well, you need to install libatomic-ops-dev. It's a new dependency introduced recently.

fusuiyi123 commented 4 years ago

libroc.pc generated:

prefix=/usr
exec_prefix=${prefix}
libdir=/usr/lib/x86_64-linux-gnu
includedir=${prefix}/include

Name: libroc
Requires: libuv libunwind atomic_ops
Version: 0.1.5
Description: Real-time audio streaming over the network.
URL: https://roc-project.github.io

Libs: -L${libdir} -lrt -ldl -lm -lpthread
Cflags: -I${includedir}
fusuiyi123 commented 4 years ago
root@dcc8b5f06b99:/Users/fusuiyi/Desktop/opensource/roc# scons --enable-werror --build-3rdparty=openfec install
scons: Reading SConscript files ...
Searching CXX executable... (cached) /usr/bin/g++-5
Searching CONFIG_GUESS script... (cached) /usr/share/misc/config.guess
Searching CC executable... (cached) /usr/bin/gcc-5
Searching CXXLD executable... (cached) /usr/bin/g++-5
Searching CCLD executable... (cached) /usr/bin/gcc-5
Searching AR executable... (cached) /usr/bin/ar (/usr/bin/x86_64-linux-gnu-ar)
Searching RANLIB executable... (cached) /usr/bin/ranlib (/usr/bin/x86_64-linux-gnu-ranlib)
Searching STRIP executable... (cached) /usr/bin/strip (/usr/bin/x86_64-linux-gnu-strip)
error: no result
Checking for C library uv... yes
error: no result
Checking for C library unwind... yes
error: no result
Checking for C library atomic_ops... yes
error: no result
Checking for C library pulse... yes
error: no result
Checking for C library pulse-simple... yes
error: no result
Checking for C library sox... yes
Checking for executable ragel... (cached) /usr/bin/ragel
Checking for executable gengetopt... (cached) /usr/bin/gengetopt
error: no result
Checking for CXX library CppUTest... yes
python scripts/3rdparty.py 3rdparty/x86_64-pc-linux-gnu/gcc-5.4.0-release vendor '' release openfec-1.4.2.4 '' CXX=/usr/bin/g++-5 CXXLD=/usr/bin/g++-5 CC=/usr/bin/gcc-5 CCLD=/usr/bin/gcc-5 AR=/usr/bin/ar RANLIB=/usr/bin/ranlib
[download] https://github.com/roc-project/openfec/archive/v1.4.2.4.tar.gz
[extract] openfec_v1.4.2.4.tar.gz
[execute] cmake .. -DBUILD_STATIC_LIBS=ON -DDEBUG:STRING=OFF -DCMAKE_FIND_ROOT_PATH='' -DCMAKE_SYSROOT='' -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_C_COMPILER=/usr/bin/gcc-5 -DCMAKE_LINKER=/usr/bin/gcc-5 -DCMAKE_AR=/usr/bin/ar -DCMAKE_RANLIB=/usr/bin/ranlib -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS_RELEASE:STRING='-fPIC -fvisibility=hidden'
[execute] make -j2
[install] 3rdparty/x86_64-pc-linux-gnu/gcc-5.4.0-release/build/openfec-1.4.2.4/include
[install] 3rdparty/x86_64-pc-linux-gnu/gcc-5.4.0-release/build/openfec-1.4.2.4/lib/libopenfec.a
Searching for system library directory... (cached) /usr/lib/x86_64-linux-gnu
Searching PKG_CONFIG_PATH...(cached) error: no result
scons: done reading SConscript files.
scons: Building targets ...
install(/usr/include/roc)
install(/usr/lib/x86_64-linux-gnu/libroc.so.0.1)
scons: *** [install] bin/x86_64-pc-linux-gnu/libroc.so.0.1: No such file or directory
scons: building terminated because of errors.
fusuiyi123 commented 4 years ago

one concern is that I am not clear about the difference between

conf = Configure(env, custom_tests=env.CustomTests)
env.function()
conf.function()

since AddPkgConfigDependency is added in config.py I have to use conf. AddPkgConfigDependency

gavv commented 4 years ago

since AddPkgConfigDependency is added in config.py I have to use conf. AddPkgConfigDependency

Yep, your usage is correct.

Configure() returns a new object with methods for configuration. Internally it contains a copy of the to original env.

When you call AddPkgConfigDependency(), it invokes pkg-config, parses its outputs and adds parsed search path, library names, etc, the internal copy of env in Configure object.

When you call env = conf.Finish() you assign that internal environment back to the original environment.

gavv commented 4 years ago

scons: *** [install] bin/x86_64-pc-linux-gnu/libroc.so.0.1: No such file or directory

Unfortunately I can't reproduce this on your branch.

fusuiyi123 commented 4 years ago

ok, so it there any other change needs to be made?

fusuiyi123 commented 4 years ago

thanks for the review! I pulled the latest ubuntu16.04 and execute

scons -Q \
      --enable-werror \
      --enable-tests \
      --enable-benchmarks \
      --enable-examples \
      --build-3rdparty=openfec,google-benchmark:1.2.0 \
      install

I got libroc.pc

prefix=/usr
exec_prefix=${prefix}
libdir=/usr/lib/x86_64-linux-gnu
includedir=${prefix}/include

Name: roc
Requires: libuv libunwind atomic_ops
Version: 0.1.5
Description: Real-time audio streaming over the network.
URL: https://roc-project.github.io

Libs: -L${libdir} -lrt -ldl -lm -lpthread
Cflags: -I${includedir}

But I am still having the error as

Searching PKG_CONFIG_PATH...(cached) /usr/lib/x86_64-linux-gnu/pkgconfig
error: no result
error: no result
scons: done reading SConscript files.
scons: Building targets ...
install(/usr/include/roc)
install(/usr/lib/x86_64-linux-gnu/libroc.so.0.1)
scons: *** [install] bin/x86_64-pc-linux-gnu/libroc.so.0.1: No such file or directory
scons: building terminated because of errors.
fusuiyi123 commented 4 years ago

it installed successfully after I build first,

root@c552ee1884a6:/Users/fusuiyi/Desktop/opensource/roc# cat /usr/lib/x86_64-linux-gnu/pkgconfig/libroc.pc
prefix=/usr
exec_prefix=${prefix}
libdir=/usr/lib/x86_64-linux-gnu
includedir=${prefix}/include

Name: roc
Requires: libuv libunwind atomic_ops
Version: 0.1.5
Description: Real-time audio streaming over the network.
URL: https://roc-project.github.io

Libs: -L${libdir} -lrt -ldl -lm -lpthread
Cflags: -I${includedir}
gavv commented 4 years ago

it installed successfully after I build first,

OK, so I can reproduce it in a docker container with ubuntu 16.04. And yes, install works only after successful build. This problem is reproduced without your PR too.

Could you please file a new issue for that? This is a minor bug I think, I'll take a look at it later.

fusuiyi123 commented 4 years ago

the centos build failed with fatal error: sox.h: No such file or directory after sudo ln -s /usr/include/sox/sox.h /usr/include/sox.h it worked. ref: https://github.com/pytorch/audio/issues/53#issuecomment-425621514

gavv commented 4 years ago

the centos build failed with fatal error: sox.h: No such file or directory after sudo ln -s /usr/include/sox/sox.h /usr/include/sox.h it worked.

I guess that pkg-config stuff is somehow broken in this PR.

I pulled rocproject/travis-centos and here is what I see:

[root@05cf94ebe888 sox]# ls -l /usr/include/sox/
total 92
-rw-r--r-- 1 root root 92326 Aug  9  2019 sox.h
[root@05cf94ebe888 sox]# pkg-config --cflags sox
-I/usr/include/sox  

So pkg-config should tell us to add /usr/include/sox the search path and just including <sox.h> should work (and works in develop).

So adding a symlink should not be needed if we use pkg-config correctly.

fusuiyi123 commented 4 years ago

pkg-config --cflags sox -I/usr/include/sox

yes, I think that's the issue you suggested above!

gavv commented 4 years ago

LGTM!

NB: I've renamed libroc.pc to roc.pc.