Hi @geopaxpvtltd ,
I have tried to manually copy the headers from /usr/include to the project/includes folder but it seems unnatural and gives other errors.
Can you provide any pointers? I have tried adding libserial-dev into deps.json in the .conf folder and torizonPackages.json in the app folder.
In order to add an external library to your ApolloX project you have to add it to your SDK container and in your debug/release container as well. For instance, in order to add LibSerial
you have to change the following files:
Dockerfile.sdk
: Addlibserial-dev:arm64
in theapt-get install
command, similar to this:
# __deps__
RUN apt-get -q -y update && \
apt-get -q -y install \
# ADD YOUR PACKAGES HERE
libserial-dev:arm64 \
&& \
apt-get clean && apt-get autoremove && \
rm -rf /var/lib/apt/lists/*
# __deps__
Dockerfile.debug
(debug container) andDockerfile
(release container): Similar to above, addlibserial-dev
orlibserial1
to theapt-get install
command.
You also have to include the library flag to your Makefile
, as otherwise you’ll get the undefined reference
errors. To do this add -lserial
to LDFLAGS
in your Makefile
:
LDFLAGS := -lserial
Once that’s done you can try to compile and deploy your program. You can ignore any include errors related to your library, as it will be installed in the containers.
With the steps above I was able to successfully run on ApolloX this sample code from the LibSerial repository: https://github.com/crayzeewulf/libserial/blob/master/examples/serial_port_read.cpp
EDIT: For the code above I also had to add /dev/ttyUSB0
as a device in docker-compose.yml
:
devices:
- "/dev/ttyUSB0:/dev/ttyUSB0"
As for the V1 issues, if devpackages
has libserial-dev:arm64
and extrapackages
has libserial1
or libserial-dev
then the problem can be a linking issue similar to the one you faced before. I don’t know for sure how to do this with CMake, but try to find an equivalent option to the -lserial
Makefile flag I mentioned above.
Hope this helps you.
Best regards,
Lucas Akira