Important
To build your code with JetsonGPIO, C++11 or higher is required.
Add this to your CMakeLists.txt
find_package(JetsonGPIO)
assuming you added a target called mytarget
, then you can link it with:
target_link_libraries(mytarget JetsonGPIO::JetsonGPIO)
If you don't want to install the library you can add it as an external project with CMake's FetchContent
(cmake 3.11 or higher is required):
include(FetchContent)
FetchContent_Declare(
JetsonGPIO
GIT_REPOSITORY https://github.com/pjueon/JetsonGPIO.git
GIT_TAG master
)
FetchContent_MakeAvailable(JetsonGPIO)
target_link_libraries(mytarget JetsonGPIO::JetsonGPIO)
The code will be automatically fetched at configure time and built alongside your project.
Important
This method does not automatically set user permissions, so you will need to set them manually or run your code with root permissions.
To set user permissions, execute the scripts/post_install.sh
script. Assuming you are in build
directory:
sudo bash ../scripts/post_install.sh
The following example shows how to compile your code with JetsonGPIO:
# you can use any other compiler instead of g++
g++ -o your_program_name [your_source_codes...] -lJetsonGPIO -lpthread
Note
- All the header files are installed in
/usr/local/include
by default. - JetsonGPIO has dependency on
pthread
due to the use ofstd::thread
. Therefore,pthread
should be linked to your code as well.