V2X Hub is a message handler that acts as a translator and data aggregator/disseminator for infrastructure components of a connected vehicle deployment.
Apache License 2.0
118
stars
67
forks
source link
Cannot build CommandPlugin - undefined reference to 'cap' functions in libwebsockets #513
I am working on a method to build V2X-Hub for a device running Ubuntu 20.04. I don't want to use Docker so I'm actually building it on the system. I keep running into the same issue with undefined references to 'cap_get_proc', 'cap_set_proc', and 'cap_free' in libwebsockets:
Scanning dependencies of target CommandPlugin
[ 17%] Building CXX object CommandPlugin/CMakeFiles/CommandPlugin.dir/src/CommandControl.cpp.o
[ 18%] Building CXX object CommandPlugin/CMakeFiles/CommandPlugin.dir/src/CommandPlugin.cpp.o
[ 19%] Linking CXX executable ../bin/CommandPlugin
/usr/bin/ld: /usr/local/lib/libwebsockets.a(unix-caps.c.o): in function `_lws_plat_apply_caps':
unix-caps.c:(.text+0x1d): undefined reference to `cap_get_proc'
/usr/bin/ld: unix-caps.c:(.text+0x3d): undefined reference to `cap_set_flag'
/usr/bin/ld: unix-caps.c:(.text+0x49): undefined reference to `cap_set_proc'
/usr/bin/ld: unix-caps.c:(.text+0x79): undefined reference to `cap_free'
collect2: error: ld returned 1 exit status
make[2]: *** [CommandPlugin/CMakeFiles/CommandPlugin.dir/build.make:124: bin/CommandPlugin] Error 1
make[1]: *** [CMakeFiles/Makefile2:593: CommandPlugin/CMakeFiles/CommandPlugin.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
I used the Dockerfile provided in 7.4.0 as the base for my build script, so the steps are performed in the same order. The above error occurs when building in the v2i-hub directory:
run cd /opt/V2X-Hub/src/v2i-hub/
run cmake . -DqserverPedestrian_DIR=/usr/local/share/qserverPedestrian/cmake -Dv2xhubWebAPI_DIR=/usr/local/share/v2xhubWebAPI/cmake/
run make
I have tried various versions of libwebsockets: the usdot-fhwa-OPS branch, v4.3-stable branch of the main libwebsockets git repo, and libwebsockets-dev as supplied by Ubuntu apt; same issue in all cases.
Version
4.3.0 (Current)
Expected Behavior
CommandPlugin builds successfully without missing libwebsockets dependencies
Actual Behavior
CommandPlugin fails to build:
Scanning dependencies of target CommandPlugin
[ 17%] Building CXX object CommandPlugin/CMakeFiles/CommandPlugin.dir/src/CommandControl.cpp.o
[ 18%] Building CXX object CommandPlugin/CMakeFiles/CommandPlugin.dir/src/CommandPlugin.cpp.o
[ 19%] Linking CXX executable ../bin/CommandPlugin
/usr/bin/ld: /usr/local/lib/libwebsockets.a(unix-caps.c.o): in function `_lws_plat_apply_caps':
unix-caps.c:(.text+0x1d): undefined reference to `cap_get_proc'
/usr/bin/ld: unix-caps.c:(.text+0x3d): undefined reference to `cap_set_flag'
/usr/bin/ld: unix-caps.c:(.text+0x49): undefined reference to `cap_set_proc'
/usr/bin/ld: unix-caps.c:(.text+0x79): undefined reference to `cap_free'
collect2: error: ld returned 1 exit status
make[2]: *** [CommandPlugin/CMakeFiles/CommandPlugin.dir/build.make:124: bin/CommandPlugin] Error 1
make[1]: *** [CMakeFiles/Makefile2:593: CommandPlugin/CMakeFiles/CommandPlugin.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
Steps to Reproduce the Actual Behavior
Here's my build script for reference. The issue occurs in this section:
run cd /opt/V2X-Hub/src/v2i-hub/
run cmake . -DqserverPedestrian_DIR=/usr/local/share/qserverPedestrian/cmake -Dv2xhubWebAPI_DIR=/usr/local/share/v2xhubWebAPI/cmake/
run make
Full script (note that I commented out various methods I've tried to get libwebsockets):
#!/bin/bash
v2xhub_home='/home/jenkins/project_e/apps/V2X-Hub'
warn ()
{
printf '%s\n' "$*" >&2
}
die ()
{
warn "$*"
exit 1
}
run ()
{
printf "%s\n" "$*"
eval "$*" || die "FAILED: ($(pwd)) $*"
}
try ()
{
printf "%s\n" "$*"
eval "$*"
}
# HACK to download missing packages
run curl http://archive.ubuntu.com/ubuntu/pool/universe/h/hdf5/hdf5-helpers_1.10.4+repack-11ubuntu1_amd64.deb --output \
hdf5-helpers_1.10.4+repack-11ubuntu1_amd64.deb
run dpkg -i hdf5-helpers_1.10.4+repack-11ubuntu1_amd64.deb
run apt-get update
# run DEBIAN_FRONTEND=noninteractive apt-get install -y libcap-dev
run DEBIAN_FRONTEND=noninteractive apt-get install -y cmake gcc-7 g++-7 libboost1.71-all-dev libxerces-c-dev libcurl4-openssl-dev libsnmp-dev \
libmysqlclient-dev libjsoncpp-dev uuid-dev libusb-dev libusb-1.0-0-dev libftdi-dev swig liboctave-dev gpsd libgps-dev portaudio19-dev libsndfile1-dev \
libglib2.0-dev libglibmm-2.4-dev libpcre3-dev libsigc++-2.0-dev libxml++2.6-dev libxml2-dev liblzma-dev dpkg-dev libmysqlcppconn-dev libev-dev libuv1-dev git \
vim zip build-essential zlib1g libssl-dev qtbase5-dev qtbase5-dev-tools curl libqhttpengine-dev libgtest-dev libcpprest-dev librdkafka-dev wget
# libwebsockets-dev
# HACK to update libwebsockets
# run "sed -i '/-lwebsockets/ s/$/ -lcap/' /usr/lib/x86_64-linux-gnu/pkgconfig/libwebsockets.pc"
run cd /usr/src/googletest/googletest
run cmake .
run make
try cd lib
try cp libgtest* /usr/lib/
run cd /usr/src/googletest/googletest
try mkdir /usr/local/lib/googletest
try ln -s /usr/lib/libgtest.a /usr/local/lib/googletest/libgtest.a
try ln -s /usr/lib/libgtest_main.a /usr/local/lib/googletest/libgtest_main.a
run ldconfig
try mkdir /opt/V2X-Hub
try cp -r $v2xhub_home/* /opt/V2X-Hub
run cd /opt/V2X-Hub/src/tmx/
run cmake .
run make
run make install
run cd /opt/V2X-Hub/container/
run chmod +x /opt/V2X-Hub/container/library.sh
run /opt/V2X-Hub/container/library.sh
run ldconfig
run cd /opt/V2X-Hub/
try mkdir /opt/V2X-Hub/ext
run cd /opt/V2X-Hub/ext/
#try git clone https://github.com/usdot-fhwa-OPS/libwebsockets.git
try git clone -b v4.3-stable https://github.com/warmcat/libwebsockets.git
run cd /opt/V2X-Hub/ext/libwebsockets/
run cmake -DLWS_WITH_SHARED=OFF .
run make
run make install
run cd /opt/V2X-Hub/ext
run QHTTPENGINE_VERSION=1.0.1 && \
wget -O qhttpengine-${QHTTPENGINE_VERSION}.tar.gz https://github.com/nitroshare/qhttpengine/archive/refs/tags/${QHTTPENGINE_VERSION}.tar.gz && \
tar xvf qhttpengine-${QHTTPENGINE_VERSION}.tar.gz && \
cd qhttpengine-${QHTTPENGINE_VERSION}/ && \
cmake . && \
make -j && \
make install
run cd /opt/V2X-Hub/ext/
try git clone https://github.com/HowardHinnant/date.git
try cd /opt/V2X-Hub/ext/date
run cmake .
run make
run make install
run ldconfig
run cd /opt/V2X-Hub/ext/server
run cmake .
run make
run make install
run cd /opt/V2X-Hub/ext/ccserver
run cmake .
run make
run make install
run cd /opt/V2X-Hub/ext/pdclient
run cmake .
run make
run make install
### setup and install v2x-hub core and plugins
run cd /opt/V2X-Hub/src/v2i-hub/
run cmake . -DqserverPedestrian_DIR=/usr/local/share/qserverPedestrian/cmake -Dv2xhubWebAPI_DIR=/usr/local/share/v2xhubWebAPI/cmake/
run make
try ln -s ../bin CommandPlugin/bin
run zip CommandPlugin.zip CommandPlugin/bin/CommandPlugin CommandPlugin/manifest.json
try ln -s ../bin CswPlugin/bin
run zip CswPlugin.zip CswPlugin/bin/CswPlugin CswPlugin/manifest.json
try ln -s ../bin DmsPlugin/bin
run zip DmsPlugin.zip DmsPlugin/bin/DmsPlugin DmsPlugin/manifest.json
try ln -s ../bin DsrcImmediateForwardPlugin/bin
run zip DsrcImmediateForwardPlugin.zip DsrcImmediateForwardPlugin/bin/DsrcImmediateForwardPlugin DsrcImmediateForwardPlugin/manifest.json
try ln -s ../bin LocationPlugin/bin
run zip LocationPlugin.zip LocationPlugin/bin/LocationPlugin LocationPlugin/manifest.json
try ln -s ../bin MapPlugin/bin
run zip MapPlugin.zip MapPlugin/bin/MapPlugin MapPlugin/manifest.json
try ln -s ../bin MessageReceiverPlugin/bin
run zip MessageReceiverPlugin.zip MessageReceiverPlugin/bin/MessageReceiverPlugin MessageReceiverPlugin/manifest.json
try ln -s ../bin ODEPlugin/bin
run zip ODEPlugin.zip ODEPlugin/bin/ODEPlugin ODEPlugin/manifest.json
try ln -s ../bin RtcmPlugin/bin
run zip RtcmPlugin.zip RtcmPlugin/bin/RtcmPlugin RtcmPlugin/manifest.json
try ln -s ../bin SpatPlugin/bin
run zip SpatPlugin.zip SpatPlugin/bin/SpatPlugin SpatPlugin/manifest.json
try ln -s ../bin PreemptionPlugin/bin
run zip PreemptionPlugin.zip PreemptionPlugin/bin/PreemptionPlugin PreemptionPlugin/manifest.json
try ln -s ../bin SPaTLoggerPlugin/bin
run zip SPaTLoggerPlugin.zip SPaTLoggerPlugin/bin/SPaTLoggerPlugin SPaTLoggerPlugin/manifest.json
try ln -s ../bin MessageLoggerPlugin/bin
run zip MessageLoggerPlugin.zip MessageLoggerPlugin/bin/MessageLoggerPlugin MessageLoggerPlugin/manifest.json
try ln -s ../bin PedestrianPlugin/bin
run zip PedestrianPlugin.zip PedestrianPlugin/bin/PedestrianPlugin PedestrianPlugin/manifest.json
try ln -s ../bin TimPlugin/bin
run zip TimPlugin.zip TimPlugin/bin/TimPlugin TimPlugin/manifest.json
try ln -s ../bin CARMACloudPlugin/bin
run zip CARMACloudPlugin.zip CARMACloudPlugin/bin/CARMACloudPlugin CARMACloudPlugin/manifest.json
try ln -s ../bin PortDrayagePlugin/bin
run zip PortDrayagePlugin.zip PortDrayagePlugin/bin/PortDrayagePlugin PortDrayagePlugin/manifest.json
try ln -s ../bin ODELoggerPlugin/bin
run zip ODELoggerPlugin.zip ODELoggerPlugin/bin/ODELoggerPlugin ODELoggerPlugin/manifest.json
try ln -s ../bin CARMAStreetsPlugin/bin
run zip CARMAStreetsPlugin.zip CARMAStreetsPlugin/bin/CARMAStreetsPlugin CARMAStreetsPlugin/manifest.json
run cd /opt/V2X-Hub/src/tmx/TmxCore/
try cp tmxcore.service /lib/systemd/system/
try cp tmxcore.service /usr/sbin/
run cd /opt/V2X-Hub/container/
run chmod +x /opt/V2X-Hub/container/database.sh
run /opt/V2X-Hub/container/database.sh
run cd /opt/V2X-Hub/container/
run chmod +x /opt/V2X-Hub/container/service.sh
run chmod +x /opt/V2X-Hub/container/wait-for-it.sh
run cd /var/www/
try mkdir ~/plugins
run cd /opt/V2X-Hub/src/v2i-hub/
run cd /var/www/plugins/
try mkdir /var/www/plugins/MAP
try mkdir /var/www/plugins/.ssl
run chown plugin .ssl
run chgrp www-data .ssl
run cd /var/www/plugins/.ssl/
run openssl req -x509 -newkey rsa:4096 -sha256 -nodes -keyout tmxcmd.key -out tmxcmd.crt -subj "/CN= <127.0.0.1> " -days 3650
run chown plugin *
run chgrp www-data *
run cd /opt/V2X-Hub/src/v2i-hub/
try mkdir /opt/V2X-Hub/.base-image
ENV SONAR_DIR=/opt/sonarqube
# Pull scanner from internet
try mkdir $SONAR_DIR && \
curl -o $SONAR_DIR/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.4.0.2170-linux.zip && \
curl -o $SONAR_DIR/build-wrapper.zip https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip && \
# Install Dependancy of NodeJs 6+
curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
# Install JQ Json Parser Tool
mkdir /opt/jq && \
curl -L "https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64" -o /opt/jq/jq && \
chmod +x /opt/jq/jq
# Unzip scanner
try cd $SONAR_DIR && \
unzip $SONAR_DIR/sonar-scanner.zip -d . && \
unzip $SONAR_DIR/build-wrapper.zip -d . && \
# Remove zip files
rm $SONAR_DIR/sonar-scanner.zip && \
rm $SONAR_DIR/build-wrapper.zip && \
# Rename files
mv "$(ls $SONAR_DIR | grep "sonar-scanner-")" $SONAR_DIR/sonar-scanner/ && \
mv "$(ls $SONAR_DIR | grep "build-wrapper-")" $SONAR_DIR/build-wrapper/ && \
# Add scanner, wrapper, and jq to PATH
echo "export PATH=$PATH:/opt/jq/:$SONAR_DIR/sonar-scanner/bin/:$SONAR_DIR/build-wrapper/" >> /opt/V2X-Hub/.base-image/init-env.sh
# Install gcovr for code coverage tests and add code_coverage script folder to path
run apt-get -y install gcovr && \
echo "export PATH=$PATH:/opt/V2X-Hub/.ci-image/engineering_tools/code_coverage/" >> /opt/V2X-Hub/.base-image/init-env.sh
run /opt/V2X-Hub/container/service.sh
Summary
I am working on a method to build V2X-Hub for a device running Ubuntu 20.04. I don't want to use Docker so I'm actually building it on the system. I keep running into the same issue with undefined references to 'cap_get_proc', 'cap_set_proc', and 'cap_free' in libwebsockets:
I used the Dockerfile provided in 7.4.0 as the base for my build script, so the steps are performed in the same order. The above error occurs when building in the v2i-hub directory:
I have tried various versions of libwebsockets: the usdot-fhwa-OPS branch, v4.3-stable branch of the main libwebsockets git repo, and libwebsockets-dev as supplied by Ubuntu apt; same issue in all cases.
Version
4.3.0 (Current)
Expected Behavior
CommandPlugin builds successfully without missing libwebsockets dependencies
Actual Behavior
CommandPlugin fails to build:
Steps to Reproduce the Actual Behavior
Here's my build script for reference. The issue occurs in this section:
Full script (note that I commented out various methods I've tried to get libwebsockets):
Related Work
No response