eBPF (bcc) on centos - linux

It's possible deploy bcc --> https://iovisor.github.io/bcc/
... on centos /redhat SO?
someone knows what's the problem to compile bcc tools from centos? (all dependencies are installed), but when I execute the last step:
cmake .. -DCMAKE_INSTALL_PREFIX=/usr
Returns:
[root#ebpf build]# cmake -DCMAKE_INSTALL_PREFIX=/usr ..
-- Latest recognized Git tag is v0.3.0
-- Git HEAD is 007d28c534e1a98e6017ac9f4c8cb1c0f5244388
-- Revision is 0.3.0-007d28c5 CMake Error at CMakeLists.txt:22 (find_package): Could not find a package configuration file provided
by "LLVM" with any of the following names:
LLVMConfig.cmake
llvm-config.cmake
Add the installation prefix of "LLVM" to CMAKE_PREFIX_PATH or set
"LLVM_DIR" to a directory containing one of the above files. If
"LLVM" provides a separate development package or SDK, be sure it
has been installed.
-- Configuring incomplete, errors occurred! See also "/root/bcc/build/CMakeFiles/CMakeOutput.log".

for llvm issue. just run below CLI:
cp /usr/share/llvm/cmake/LLVM-Config.cmake /usr/share/llvm/cmake/llvm-config.cmake

Related

CMake: how to get PATHS variable for find_package?

Here is an example how to specify PATHS variable to make cmake be able to find library:
cmake find_package specify path
But how to get this PATHS variable for specific library?
For example I have installed apt-get install libharfbuzz-dev and dpkg -L libharfbuzz-dev shows me:
/usr
/usr/include
/usr/include/harfbuzz
/usr/include/harfbuzz/hb-blob.h
/usr/include/harfbuzz/hb-buffer.h
/usr/include/harfbuzz/hb-common.h
/usr/include/harfbuzz/hb-deprecated.h
/usr/include/harfbuzz/hb-face.h
/usr/include/harfbuzz/hb-font.h
/usr/include/harfbuzz/hb-ft.h
/usr/include/harfbuzz/hb-glib.h
/usr/include/harfbuzz/hb-gobject-enums.h
/usr/include/harfbuzz/hb-gobject-structs.h
/usr/include/harfbuzz/hb-gobject.h
/usr/include/harfbuzz/hb-graphite2.h
/usr/include/harfbuzz/hb-icu.h
/usr/include/harfbuzz/hb-ot-font.h
/usr/include/harfbuzz/hb-ot-layout.h
/usr/include/harfbuzz/hb-ot-math.h
/usr/include/harfbuzz/hb-ot-shape.h
/usr/include/harfbuzz/hb-ot-tag.h
/usr/include/harfbuzz/hb-ot-var.h
/usr/include/harfbuzz/hb-ot.h
/usr/include/harfbuzz/hb-set.h
/usr/include/harfbuzz/hb-shape-plan.h
/usr/include/harfbuzz/hb-shape.h
/usr/include/harfbuzz/hb-unicode.h
/usr/include/harfbuzz/hb-version.h
/usr/include/harfbuzz/hb.h
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/libharfbuzz-gobject.a
/usr/lib/x86_64-linux-gnu/libharfbuzz-icu.a
/usr/lib/x86_64-linux-gnu/libharfbuzz.a
/usr/lib/x86_64-linux-gnu/pkgconfig
/usr/lib/x86_64-linux-gnu/pkgconfig/harfbuzz-gobject.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/harfbuzz-icu.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/harfbuzz.pc
/usr/share
/usr/share/doc
/usr/share/doc/libharfbuzz-dev
/usr/share/doc/libharfbuzz-dev/copyright
/usr/share/gir-1.0
/usr/share/gir-1.0/HarfBuzz-0.0.gir
/usr/lib/x86_64-linux-gnu/libharfbuzz-gobject.so
/usr/lib/x86_64-linux-gnu/libharfbuzz-icu.so
/usr/lib/x86_64-linux-gnu/libharfbuzz.so
/usr/share/doc/libharfbuzz-dev/changelog.Debian.gz
Which path should I use?
Update:
Error message:
CMake Error at <some_path>/CMakeLists.txt:6 (find_package):
By not providing "FindHarfbuzz.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Harfbuzz",
but CMake did not find one.
Could not find a package configuration file provided by "Harfbuzz" with any
of the following names:
HarfbuzzConfig.cmake
harfbuzz-config.cmake
Add the installation prefix of "Harfbuzz" to CMAKE_PREFIX_PATH or set
"Harfbuzz_DIR" to a directory containing one of the above files. If
"Harfbuzz" provides a separate development package or SDK, be sure it has
been installed.
I tried to add path via CMAKE_PREFIX_PATH like cmake .. -DCMAKE_PREFIX_PATH=/usr/lib/x86_64-linux-gnu but it doesn't help.

Error building go compiler from source

I am trying to build the latest version (tip of the master branch) of Go from source.
The official Go documentation (https://golang.org/doc/install/source) states that you should download Go 1.4 binaries to build a more recent version. However it should be possible to build all from source.
To do this, I set variables in .bashrc :
PATH="$HOME/go/bin:$PATH"
export GOPATH=$HOME
then to build go 1.4 from source :
source ~/.bashrc
git clone https://go.googlesource.com/go
mkdir ~/go1.4
cd ~/go
git archive --format=tar go1.4.3 |tar -xv -C ~/go1.4
cd ~/go1.4/src
./make.bash
and finally build the latest version :
cd ~/go/src/
GOROOT_BOOTSTRAP=$HOME/go1.4 ./make.bash
I remember doing this months ago without problems, but today I get these errors building go 1.4 make.bash:
# cmd/pprof
.../go1.4/pkg/linux_amd64/runtime/cgo.a(_all.o): unknown relocation type 42; compiled without -fpic?
.../go1.4/pkg/linux_amd64/runtime/cgo.a(_all.o): unknown relocation type 42; compiled without -fpic?
runtime/cgo(.text): unexpected relocation type 298
runtime/cgo(.text): unexpected relocation type 298
...
Is there something wrong in my method ?
The error messages point to CGO, and environment variables that control make.bash are explained at the beginning of the file :
CGO_ENABLED: Controls cgo usage during the build. Set it to 1
to include all cgo related files, .c and .go file with "cgo"
build directive, in the build. Set it to 0 to ignore them.
so if you disable CGO while building GO 1.4 :
cd ~/go1.4/src
CGO_ENABLED=0 ./make.bash
everything works and pass the tests.

Linux opencv independent installation : not found in CMake

I am creating an object tracking program which rely on OpenCV. Thus I want to be able to test it with different versions of OpenCV but I have linking errors.
I installed the last version of OpenCV (a69b435c928f422fb5f99c02cf2dcae57dcf820a) in the following folder : /usr/local/opencv/opencv-trunk instead of the usual /usr/local.
Then I followed also the official tutorial to use OpenCV with CMake in Linux, but I had the following "normal" error :
CMake Error at CMakeLists.txt:11 (find_package):
By not providing "FindOpenCV.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "OpenCV", but CMake did not find one.
Could not find a package configuration file provided by "OpenCV" with any of the following names:
OpenCVConfig.cmake
opencv-config.cmake
Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set "OpenCV_DIR" to a directory containing one of the above files. If "OpenCV" provides a separate development package or SDK, be sure it has been installed.
-- Configuring incomplete, errors occurred!
So I did what was suggested and added the following line in my CMakeLists.txt :
# Find independently installed OpenCV libraries
set(OpenCV_DIR "/usr/local/opencv/opencv-trunk/share/OpenCV")
This is the complete CMakeLists.txt file :
# Find independently installed OpenCV libraries
set(OpenCV_DIR "/usr/local/opencv/opencv-trunk/share/OpenCV")
cmake_minimum_required(VERSION 2.8)
project( DisplayImage )
add_executable( DisplayImage DisplayImage.cpp )
find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )
target_link_libraries( DisplayImage ${OpenCV_LIBS} )
Now I have the following error and I don't find how to deal with it.
CMake Error at CMakeLists.txt:12 (find_package):
Found package configuration file:
/usr/local/opencv/opencv-trunk/share/OpenCV/OpenCVConfig.cmake
but it set OpenCV_FOUND to FALSE so package "OpenCV" is considered to be NOT FOUND.
-- Configuring incomplete, errors occurred!
If you have already faced that issue in such context your solutions are welcomed ;)
If you are running IntelliJ or any other IDE, just try re-building CMake cache (or just remove your build directory and run cmake utility again).
I believe this is not the best practice - to set the configuration variable like OpenCV_DIR hard-coded in the CMakeLists.txt. Try setting it manually, as an environment variable to the cmake utility:
OpenCV_DIR=/usr/local/Cellar/opencv3/3.1.0_2/share/OpenCV/ cmake ..
or set your IDE to make this for you:

CMake Error: The following variables are used in this project, but they are set to NOTFOUND

I am trying to configure the whalebot crawler with the tar file whalebot-0.02.00.tar.gz. I have extracted it correctly with:
root#Admin1:~/dls# tar xvzf whalebot-0.02.00.tar.gz
After that I want to configure it with:
root#Admin1:~/dls/whalebot# ./configure
It gives me error:
bash: ./configure: No such file or directory
also I have run the command:
root#Admin1:~/dls/whalebot# cmake ./
It gives me the following result:
root#Admin1:~/dls/whalebot# cmake ./
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Boost version: 1.44.0
-- Found the following Boost libraries:
-- filesystem
-- system
-- thread
-- program_options
-- date_time
CMake Warning (dev) at webspider/CMakeLists.txt:25 (link_directories):
This command specifies the relative path
../statsem_string/bin
as a link directory.
Policy CMP0015 is not set: link_directories() treats paths relative to the
source dir. Run "cmake --help-policy CMP0015" for policy details. Use the
cmake_policy command to set the policy and suppress this warning.
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning (dev) at webspider/CMakeLists.txt:25 (link_directories):
This command specifies the relative path
../3dparty/google-url
as a link directory.
Policy CMP0015 is not set: link_directories() treats paths relative to the
source dir. Run "cmake --help-policy CMP0015" for policy details. Use the
cmake_policy command to set the policy and suppress this warning.
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
HTMLCXX_LIBRARY
linked by target "whalebot" in directory /root/dls/whalebot/webspider
-- Configuring incomplete, errors occurred!
How do I proceed?
It appears that CMake is unable to find the htmlcxx library.
In the whalebot documentation, htmlcxx is listed as a dependency.
You need to download htmlcxx, unzip it, then install it:
cd <path to unzipped htmlcxx>
./configure --enable-static=on --enable-shared=off
make
sudo make install
You may need to add #include <cstddef> to the top of html/tree.h to get it to build successfully. It will install to usr/local/ by default.
You also need icu installed if you don't already have it:
sudo apt-get install libicu-dev
Finally, you can now build and install whalebot. Again, making might fail if you have a reasonably up-to-date boost installation.
In line 57 of webspider/src/webspider_options.cpp, you need to replace boost::filesystem::initial_path().native_directory_string() with boost::filesystem::initial_path().string(). Then you should be good to build and install:
cd <path to unzipped whalebot>
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make
sudo make install
This too will install to usr/local/ by default.
Check if in CMakeLists you have written find_library(..) or find_path(.), then replace it by find_package(..).
It solved the error in my case.

Creating binary with CMake removes runtime path

I am using CMake to build a program on linux. The program compiles successfully and runs from the project build directory. The program is linked with a custom library in the directory ${HOME}/build/lib
I have an install stage with:
install(TARGETS ProgName RUNTIME DESTINATION bin)
When I run make install the program gets put in the correct place, but the cmake installer removes the runtime path from the binary.
-- Install configuration: "Debug"
-- Installing: *binary name*
-- Removed runtime path from "*binary name*"
I have read articles on the internet discussing the misuse of the LD_LIBRARY_PATH variable so I like to keep mine limited to system library locations if possible. I am not sysadmin so I cannot add the location to the default linker search path either.
Does anyone know how I can keep the development-time linking paths when installing or at least customising which paths are added to the runtime?
Cheers
Note: if you don't want to modify the cmake scripts themselves, setting property around, you can launch you cmake with a directive asking to not remove the runtime path:
See "Variables that Control the Build", with variable: "CMAKE_SKIP_RPATH"
If true, do not add run time path information.
If this is set to TRUE, then the rpath information is not added to compiled executables.
The default is to add rpath information if the platform supports it. This allows for easy running from the build tree.
To omit RPATH in the install step, but not the build step, use CMAKE_SKIP_INSTALL_RPATH instead.
If the deliveries already contained the right runtime path, that directive will avoid cmake to do any modification to the current runtime path included in said deliveries.
cmake -DCMAKE_SKIP_RPATH=ON xxx.cmake
You should look at set_target_properties command and the property BUILD_WITH_INSTALL_RPATH
http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:set_target_properties
This works for CMake 2.8
set_target_properties(foo PROPERTIES INSTALL_RPATH_USE_LINK_PATH TRUE)
where foo is the target you defined earlier:
project(foo)
add_executable(foo ...)
...
install(TARGETS foo DESTINATION bin)
...
Before
% sudo make install
Install the project...
-- Install configuration: ""
-- Installing: /opt/mystuff/bin/foo
-- Removed runtime path from "/opt/mystuff/bin/foo"
After
% sudo make install
Install the project...
-- Install configuration: ""
-- Installing: /opt/mystuff/bin/foo
-- Set runtime path of "/opt/mystuff/bin/foo" to "/opt/zzyzx/lib:/opt/bar/lib/x86_64"

Resources