Cannot run this sample
Hi,
I am fairly new to c++ building tools, and I cannot get this to compile.
I have git cloned BT.cppv4 and follow the conan/cmake build instructions, with an additionnal cmake --install . from the build directory. Everything went fine.
I git cloned this sample repo, and when I run something like :
> cd btcpp_sample
> mkdir build;cd build
> cmake ..
I get the following
-- The CXX compiler identification is GNU 11.4.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
CMake Error at CMakeLists.txt:8 (add_executable):
Target "btcpp_sample" links to target "SQLite::SQLite3" but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
I'd really appreciate any help.
Thanks
@baptose This is probably too late of a response. However, hope this helps anyone new trying to get btcpp_sample to work.
Cause Of Issue 🔍
The sqlite3 dependency seems to be missing from your local environment, thus causing CMake to throw an error trying to find it.
A quick way to address this missing dependency is to run the following command (assuming you are running in a Linux operating system):
sudo apt-get install libsqlite3-dev -y
However, that might not be the only missing dependency you have so to have a sure-fire to run btcpp_sample, please follow the steps below.
Instructions 📘
- Create a simple workspace:
mkdir btcpp_sample_ws && cd btcpp_sample
- Download the repository:
git clone https://github.com/BehaviorTree/btcpp_sample.git --depth 1 --single-branch && cd btcpp_sample
-
Create the
Dockerfilebelow:
touch Dockerfile
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y \
build-essential \
cmake \
git \
libzmq3-dev \
libsqlite3-dev \
libgtest-dev && \
rm -rf /var/lib/apt/lists/*
WORKDIR /usr/src/btcpp
RUN git clone https://github.com/BehaviorTree/BehaviorTree.CPP.git . --depth 1 --single-branch --branch 4.7.0
RUN mkdir build && \
cd build && \
cmake .. -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF -DBUILD_SHARED_LIBS=ON && \
make -j$(nproc) && \
make install
WORKDIR /usr/src/
COPY btcpp_sample btcpp_sample
WORKDIR /usr/src/btcpp_sample
RUN mkdir build && \
cd build && \
cmake .. && \
make -j$(nproc)
WORKDIR /usr/src/btcpp_sample/build
CMD ["./btcpp_sample"]
- Build the docker image:
docker build -t btcpp_sample:latest .
-
Run
btcpp_samplein a docker container:
docker run -it --rm \
--name btcpp_sample_c \
btcpp_sample:latest bash -c "./btcpp_sample"
Verify ✔️
You should see the following output to know that it worked:
this works too
The answer is 42
Hope this helps.