Difference between revisions of "Mraa"
(5 intermediate revisions by the same user not shown) | |||
Line 142: | Line 142: | ||
<pre> | <pre> | ||
− | root@rockpin10bc:/home/rock# apt-get install -y git build-essential swig3.0 python-dev python3-dev | + | root@rockpin10bc:/home/rock# apt-get install -y git build-essential swig3.0 python-dev python3-dev libnode-dev cmake libjson-c-dev |
root@rockpin10bc:/home/rock# apt-get install -y libc6 libgcc1 libstdc++6 python python2.7 libpython2.7 python3.8 libpython3.8 python3-dev python3 | root@rockpin10bc:/home/rock# apt-get install -y libc6 libgcc1 libstdc++6 python python2.7 libpython2.7 python3.8 libpython3.8 python3-dev python3 | ||
root@rockpin10bc:/home/rock# apt-get install -y libgtest-dev pkg-config cmake-data | root@rockpin10bc:/home/rock# apt-get install -y libgtest-dev pkg-config cmake-data | ||
Line 188: | Line 188: | ||
root@rockpin10bc:/home/rock/mraa/build# mraa-gpio version | root@rockpin10bc:/home/rock/mraa/build# mraa-gpio version | ||
Version v2.1.0-11-g06b2be2 on ROCK Pi 4 | Version v2.1.0-11-g06b2be2 on ROCK Pi 4 | ||
+ | </pre> | ||
+ | |||
+ | |||
+ | ==== Install example: Install Mraa on ROCK Pi 4C Debian Bullseye system ==== | ||
+ | |||
+ | |||
+ | Configure the linux java environment | ||
+ | <pre> | ||
+ | Download jdk for linux arm64 version, for example, openjdk-18.0.2.1_linux-aarch64 | ||
+ | root@rock-4c-plus:/home/rock# cd /usr/local | ||
+ | root@rock-4c-plus:/home/rock# mkdir java | ||
+ | root@rock-4c-plus:/home/rock# cd java | ||
+ | root@rock-4c-plus:/home/rock# tar xzvf openjdk-18.0.2.1_linux-aarch64_bin.tar.gz | ||
+ | root@rock-4c-plus:/home/rock# ls | ||
+ | jdk-18.0.2.1 openjdk-18.0.2.1_linux-aarch64_bin.tar.gz | ||
+ | root@rock-4c-plus:/home/rock# mv jdk-18.0.2.1 jdk18 | ||
+ | |||
+ | # modify /etc/profile | ||
+ | root@rock-4c-plus:/usr/local/java# cat /etc/profile | ||
+ | # /etc/profile: system-wide .profile file for the Bourne shell (sh(1)) | ||
+ | # and Bourne compatible shells (bash(1), ksh(1), ash(1), ...). | ||
+ | |||
+ | if [ "$(id -u)" -eq 0 ]; then | ||
+ | PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" | ||
+ | else | ||
+ | PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games" | ||
+ | fi | ||
+ | export PATH | ||
+ | |||
+ | if [ "${PS1-}" ]; then | ||
+ | if [ "${BASH-}" ] && [ "$BASH" != "/bin/sh" ]; then | ||
+ | # The file bash.bashrc already sets the default PS1. | ||
+ | # PS1='\h:\w\$ ' | ||
+ | if [ -f /etc/bash.bashrc ]; then | ||
+ | . /etc/bash.bashrc | ||
+ | fi | ||
+ | else | ||
+ | if [ "$(id -u)" -eq 0 ]; then | ||
+ | PS1='# ' | ||
+ | else | ||
+ | PS1='$ ' | ||
+ | fi | ||
+ | fi | ||
+ | fi | ||
+ | |||
+ | if [ -d /etc/profile.d ]; then | ||
+ | for i in /etc/profile.d/*.sh; do | ||
+ | if [ -r $i ]; then | ||
+ | . $i | ||
+ | fi | ||
+ | done | ||
+ | unset i | ||
+ | fi | ||
+ | |||
+ | |||
+ | export JAVA_HOME=/usr/local/java/jdk18 | ||
+ | export JRE_HOME=${JAVA_HOME}/jre | ||
+ | export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib | ||
+ | export PATH=${JAVA_HOME}/bin:$PATH | ||
+ | |||
+ | # Bring into effect | ||
+ | root@rock-4c-plus:/usr/local/java# source /etc/profile | ||
+ | |||
+ | # verification | ||
+ | root@rock-4c-plus:/usr/local/java# java -version | ||
+ | openjdk version "18.0.2.1" 2022-08-18 | ||
+ | OpenJDK Runtime Environment (build 18.0.2.1+1-1) | ||
+ | OpenJDK 64-Bit Server VM (build 18.0.2.1+1-1, mixed mode, sharing) | ||
+ | |||
+ | root@rock-4c-plus:/usr/local/java# javac -version | ||
+ | javac 18.0.2.1 | ||
+ | |||
+ | </pre> | ||
+ | |||
+ | For Debian Bullseye Distribution the below commands install the essential set: | ||
+ | <pre> | ||
+ | root@rock-4c-plus:/home/rock# apt-get install -y git build-essential swig python-dev python3-dev libnode-dev cmake libjson-c-dev | ||
+ | root@rock-4c-plus:/home/rock# apt-get install -y libc6 libgcc1 libstdc++6 python python2.7 libpython2.7 python3.8 libpython3.8 python3-dev python3 | ||
+ | root@rock-4c-plus:/home/rock# apt-get install -y libgtest-dev pkg-config cmake-data | ||
+ | </pre> | ||
+ | Get source code. | ||
+ | <pre> | ||
+ | root@rock-4c-plus:/home/rock# git clone -b master https://github.com/radxa/mraa.git | ||
+ | root@rock-4c-plus:/home/rock# cd mraa | ||
+ | </pre> | ||
+ | |||
+ | Patch the source code for building mraa with Python and java | ||
+ | <pre> | ||
+ | diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
+ | index 250d910..6446f11 100644 | ||
+ | --- a/CMakeLists.txt | ||
+ | +++ b/CMakeLists.txt | ||
+ | @@ -1,4 +1,4 @@ | ||
+ | -cmake_minimum_required (VERSION 2.8.11) | ||
+ | +cmake_minimum_required (VERSION 3.13.0) | ||
+ | project (mraa C CXX) | ||
+ | |||
+ | FIND_PACKAGE (Threads REQUIRED) | ||
+ | @@ -9,6 +9,8 @@ if (CMAKE_VERSION VERSION_LESS "3.1") | ||
+ | endif () | ||
+ | else () | ||
+ | set (CMAKE_C_STANDARD 99) | ||
+ | + cmake_policy(SET CMP0078 OLD) | ||
+ | + cmake_policy(SET CMP0086 NEW) | ||
+ | endif () | ||
+ | |||
+ | ############################################################################### | ||
+ | @@ -145,8 +147,8 @@ include_directories (${SYSTEM_USR_DIR}) | ||
+ | option (BUILDDOC "Build all doc." OFF) | ||
+ | option (BUILDSWIG "Build swig modules." ON) | ||
+ | option (BUILDSWIGPYTHON "Build swig python modules." ON) | ||
+ | -option (BUILDSWIGNODE "Build swig node modules." ON) | ||
+ | -option (BUILDSWIGJAVA "Build Java API." OFF) | ||
+ | +option (BUILDSWIGNODE "Build swig node modules." OFF) | ||
+ | +option (BUILDSWIGJAVA "Build Java API." ON) | ||
+ | option (USBPLAT "Detection USB platform." OFF) | ||
+ | option (FIRMATA "Add Firmata support to mraa." OFF) | ||
+ | option (ONEWIRE "Add Onewire support to mraa." ON) | ||
+ | |||
+ | |||
+ | diff --git a/include/version.h b/include/version.h | ||
+ | index 47366ef..3a567a1 100644 | ||
+ | --- a/include/version.h | ||
+ | +++ b/include/version.h | ||
+ | @@ -11,8 +11,8 @@ | ||
+ | extern "C" { | ||
+ | #endif | ||
+ | |||
+ | -const char* gVERSION; | ||
+ | -const char* gVERSION_SHORT; | ||
+ | +extern const char* gVERSION; | ||
+ | +extern const char* gVERSION_SHORT; | ||
+ | |||
+ | #ifdef __cplusplus | ||
+ | } | ||
+ | |||
+ | </pre> | ||
+ | |||
+ | Build and install mraa. | ||
+ | |||
+ | <pre> | ||
+ | root@rock-4c-plus:/home/rock# mkdir build | ||
+ | root@rock-4c-plus:/home/rock# cd build/ | ||
+ | root@rock-4c-plus:/home/rock# cmake .. | ||
+ | root@rock-4c-plus:/home/rock# make | ||
+ | rooroot@rock-4c-plus:/home/rock# make install | ||
+ | root@rock-4c-plus:/home/rock# ldconfig | ||
+ | root@rock-4c-plus:/home/rock# mraa-gpio version | ||
+ | Version v2.1.0 on ROCK Pi 4 | ||
</pre> | </pre> | ||
Line 209: | Line 358: | ||
<pre> | <pre> | ||
− | + | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
− | index 250d910.. | + | index 250d910..9050100 100644 |
--- a/CMakeLists.txt | --- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | +++ b/CMakeLists.txt | ||
Line 220: | Line 369: | ||
FIND_PACKAGE (Threads REQUIRED) | FIND_PACKAGE (Threads REQUIRED) | ||
+ | @@ -9,6 +9,8 @@ if (CMAKE_VERSION VERSION_LESS "3.1") | ||
+ | endif () | ||
+ | else () | ||
+ | set (CMAKE_C_STANDARD 99) | ||
+ | + cmake_policy(SET CMP0078 OLD) | ||
+ | + cmake_policy(SET CMP0086 NEW) | ||
+ | endif () | ||
+ | |||
+ | ############################################################################### | ||
diff --git a/include/version.h b/include/version.h | diff --git a/include/version.h b/include/version.h | ||
index 47366ef..3a567a1 100644 | index 47366ef..3a567a1 100644 |
Latest revision as of 02:20, 12 June 2023
Contents
- 1 Mraa on ROCK Pi boards
- 1.1 List of ROCK Pi Boards supported
- 1.2 List of Linux Distributions
- 1.3 Install example: Install Mraa on ROCK Pi N10 Debian system
- 1.4 Install example: Install Mraa on CM3 IO Debian11 system
- 1.5 Install example: Install Mraa on ROCK Pi 4C Ubuntu Focal system
- 1.6 Install example: Install Mraa on ROCK Pi 4C Debian Bullseye system
- 1.7 Install example: Install Mraa on ROCK Pi 4B Debian11 armhf system
- 1.8 Use mraa
- 1.9 Troubleshooting
Mraa on ROCK Pi boards
This document describes how to build and use mraa for ROCK Pi boards.
List of ROCK Pi Boards supported
- ROCK Pi 4 A/B/C
- ROCK Pi E
- ROCK Pi N10
- ROCK Pi S
- ROCK Pi X
List of Linux Distributions
- Ubuntu
- Debian
- Yocto (mraa-radxa_git.bb)
Install example: Install Mraa on ROCK Pi N10 Debian system
For Debian Distribution the below commands install the essential set:
root@rockpin10bc:/home/rock# apt-get install -y git build-essential swig3.0 python-dev cmake libjson-c-dev libnode-dev root@rockpin10bc:/home/rock# apt-get install -y libc6 libjson-c3 libgcc1 libstdc++6 python2.7 libpython2.7 python3.7 libpython3.7 python3-dev root@rockpin10bc:/home/rock# apt-get install -y libgtest-dev pkg-config cmake-data
Get source code.
root@rockpin10bc:/home/rock# git clone -b master https://github.com/radxa/mraa.git root@rockpin10bc:/home/rock# cd mraa
Patch the source code for building mraa with Python.
diff --git a/CMakeLists.txt b/CMakeLists.txt index 250d910..f1880e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -145,7 +145,7 @@ include_directories (${SYSTEM_USR_DIR}) option (BUILDDOC "Build all doc." OFF) option (BUILDSWIG "Build swig modules." ON) option (BUILDSWIGPYTHON "Build swig python modules." ON) -option (BUILDSWIGNODE "Build swig node modules." ON) +option (BUILDSWIGNODE "Build swig node modules." OFF) option (BUILDSWIGJAVA "Build Java API." OFF) option (USBPLAT "Detection USB platform." OFF) option (FIRMATA "Add Firmata support to mraa." OFF) @@ -156,7 +156,7 @@ option (FTDI4222 "Build with FTDI FT4222 subplatform support." OFF) option (ENABLEEXAMPLES "Disable building of examples" ON) option (INSTALLTOOLS "Install all tools" ON) option (BUILDTESTS "Override the addition of tests" ON) -option (USEPYTHON3TESTS "Force tests to run with python3" OFF) +option (USEPYTHON3TESTS "Force tests to run with python3" ON) set (BUILDARCH "" CACHE STRING "Override architecture to build for")
Build and install mraa.
root@rockpin10bc:/home/rock/mraa# mkdir build root@rockpin10bc:/home/rock/mraa# cd build/ root@rockpin10bc:/home/rock/mraa/build# cmake .. root@rockpin10bc:/home/rock/mraa/build# make root@rockpin10bc:/home/rock/mraa/build# make install root@rockpin10bc:/home/rock/mraa/build# ldconfig root@rockpin10bc:/home/rock/mraa/build# mraa-gpio version Version v2.1.0-11-g06b2be2 on Radxa ROCK Pi N10
Install example: Install Mraa on CM3 IO Debian11 system
For Debian11 Distribution the below commands install the essential set:
root@radxa-cm3-io:/home/rock# apt-get install -y git build-essential swig4.0 python-dev cmake libnode-dev python3-dev pkg-config
Get source code.
root@radxa-cm3-io:/home/rock# git clone -b master https://github.com/radxa/mraa.git root@radxa-cm3-io:/home/rock# cd mraa
Patch the source code for building mraa with Python.
diff --git a/CMakeLists.txt b/CMakeLists.txt index 250d910..f1880e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -145,7 +145,7 @@ include_directories (${SYSTEM_USR_DIR}) option (BUILDDOC "Build all doc." OFF) option (BUILDSWIG "Build swig modules." ON) option (BUILDSWIGPYTHON "Build swig python modules." ON) -option (BUILDSWIGNODE "Build swig node modules." ON) +option (BUILDSWIGNODE "Build swig node modules." OFF) option (BUILDSWIGJAVA "Build Java API." OFF) option (USBPLAT "Detection USB platform." OFF) option (FIRMATA "Add Firmata support to mraa." OFF) @@ -156,7 +156,7 @@ option (FTDI4222 "Build with FTDI FT4222 subplatform support." OFF) option (ENABLEEXAMPLES "Disable building of examples" ON) option (INSTALLTOOLS "Install all tools" ON) option (BUILDTESTS "Override the addition of tests" ON) -option (USEPYTHON3TESTS "Force tests to run with python3" OFF) +option (USEPYTHON3TESTS "Force tests to run with python3" ON) set (BUILDARCH "" CACHE STRING "Override architecture to build for")
Patch for later compilation with make
diff --git a/include/version.h b/include/version.h index 47366ef..3a567a1 100644 --- a/include/version.h +++ b/include/version.h @@ -11,8 +11,8 @@ extern "C" { #endif -const char* gVERSION; -const char* gVERSION_SHORT; +extern const char* gVERSION; +extern const char* gVERSION_SHORT; #ifdef __cplusplus }
Build and install mraa.
root@radxa-cm3-io:/home/rock/mraa# mkdir build root@radxa-cm3-io:/home/rock/mraa# cd build/ root@radxa-cm3-io:/home/rock/mraa/build# cmake .. root@radxa-cm3-io:/home/rock/mraa/build# make root@radxa-cm3-io:/home/rock/mraa/build# make install root@radxa-cm3-io:/home/rock/mraa/build# ldconfig root@radxa-cm3-io:/home/rock/mraa/build# mraa-gpio version Version v2.1.0-23-gfc8c906 on Radxa CM3 IO
Install example: Install Mraa on ROCK Pi 4C Ubuntu Focal system
For Ubuntu Distribution the below commands install the essential set:
root@rockpin10bc:/home/rock# apt-get install -y git build-essential swig3.0 python-dev python3-dev libnode-dev cmake libjson-c-dev root@rockpin10bc:/home/rock# apt-get install -y libc6 libgcc1 libstdc++6 python python2.7 libpython2.7 python3.8 libpython3.8 python3-dev python3 root@rockpin10bc:/home/rock# apt-get install -y libgtest-dev pkg-config cmake-data
Get source code.
root@rockpin10bc:/home/rock# git clone -b master https://github.com/radxa/mraa.git root@rockpin10bc:/home/rock# cd mraa
Patch the source code for building mraa with Python.
diff --git a/CMakeLists.txt b/CMakeLists.txt index 250d910..f1880e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -145,7 +145,7 @@ include_directories (${SYSTEM_USR_DIR}) option (BUILDDOC "Build all doc." OFF) option (BUILDSWIG "Build swig modules." ON) option (BUILDSWIGPYTHON "Build swig python modules." ON) -option (BUILDSWIGNODE "Build swig node modules." ON) +option (BUILDSWIGNODE "Build swig node modules." OFF) option (BUILDSWIGJAVA "Build Java API." OFF) option (USBPLAT "Detection USB platform." OFF) option (FIRMATA "Add Firmata support to mraa." OFF) @@ -156,7 +156,7 @@ option (FTDI4222 "Build with FTDI FT4222 subplatform support." OFF) option (ENABLEEXAMPLES "Disable building of examples" ON) option (INSTALLTOOLS "Install all tools" ON) option (BUILDTESTS "Override the addition of tests" ON) -option (USEPYTHON3TESTS "Force tests to run with python3" OFF) +option (USEPYTHON3TESTS "Force tests to run with python3" ON) set (BUILDARCH "" CACHE STRING "Override architecture to build for")
Build and install mraa.
root@rockpin10bc:/home/rock/mraa# mkdir build root@rockpin10bc:/home/rock/mraa# cd build/ root@rockpin10bc:/home/rock/mraa/build# cmake .. root@rockpin10bc:/home/rock/mraa/build# make root@rockpin10bc:/home/rock/mraa/build# make install root@rockpin10bc:/home/rock/mraa/build# ldconfig root@rockpin10bc:/home/rock/mraa/build# mraa-gpio version Version v2.1.0-11-g06b2be2 on ROCK Pi 4
Install example: Install Mraa on ROCK Pi 4C Debian Bullseye system
Configure the linux java environment
Download jdk for linux arm64 version, for example, openjdk-18.0.2.1_linux-aarch64 root@rock-4c-plus:/home/rock# cd /usr/local root@rock-4c-plus:/home/rock# mkdir java root@rock-4c-plus:/home/rock# cd java root@rock-4c-plus:/home/rock# tar xzvf openjdk-18.0.2.1_linux-aarch64_bin.tar.gz root@rock-4c-plus:/home/rock# ls jdk-18.0.2.1 openjdk-18.0.2.1_linux-aarch64_bin.tar.gz root@rock-4c-plus:/home/rock# mv jdk-18.0.2.1 jdk18 # modify /etc/profile root@rock-4c-plus:/usr/local/java# cat /etc/profile # /etc/profile: system-wide .profile file for the Bourne shell (sh(1)) # and Bourne compatible shells (bash(1), ksh(1), ash(1), ...). if [ "$(id -u)" -eq 0 ]; then PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" else PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games" fi export PATH if [ "${PS1-}" ]; then if [ "${BASH-}" ] && [ "$BASH" != "/bin/sh" ]; then # The file bash.bashrc already sets the default PS1. # PS1='\h:\w\$ ' if [ -f /etc/bash.bashrc ]; then . /etc/bash.bashrc fi else if [ "$(id -u)" -eq 0 ]; then PS1='# ' else PS1='$ ' fi fi fi if [ -d /etc/profile.d ]; then for i in /etc/profile.d/*.sh; do if [ -r $i ]; then . $i fi done unset i fi export JAVA_HOME=/usr/local/java/jdk18 export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH # Bring into effect root@rock-4c-plus:/usr/local/java# source /etc/profile # verification root@rock-4c-plus:/usr/local/java# java -version openjdk version "18.0.2.1" 2022-08-18 OpenJDK Runtime Environment (build 18.0.2.1+1-1) OpenJDK 64-Bit Server VM (build 18.0.2.1+1-1, mixed mode, sharing) root@rock-4c-plus:/usr/local/java# javac -version javac 18.0.2.1
For Debian Bullseye Distribution the below commands install the essential set:
root@rock-4c-plus:/home/rock# apt-get install -y git build-essential swig python-dev python3-dev libnode-dev cmake libjson-c-dev root@rock-4c-plus:/home/rock# apt-get install -y libc6 libgcc1 libstdc++6 python python2.7 libpython2.7 python3.8 libpython3.8 python3-dev python3 root@rock-4c-plus:/home/rock# apt-get install -y libgtest-dev pkg-config cmake-data
Get source code.
root@rock-4c-plus:/home/rock# git clone -b master https://github.com/radxa/mraa.git root@rock-4c-plus:/home/rock# cd mraa
Patch the source code for building mraa with Python and java
diff --git a/CMakeLists.txt b/CMakeLists.txt index 250d910..6446f11 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8.11) +cmake_minimum_required (VERSION 3.13.0) project (mraa C CXX) FIND_PACKAGE (Threads REQUIRED) @@ -9,6 +9,8 @@ if (CMAKE_VERSION VERSION_LESS "3.1") endif () else () set (CMAKE_C_STANDARD 99) + cmake_policy(SET CMP0078 OLD) + cmake_policy(SET CMP0086 NEW) endif () ############################################################################### @@ -145,8 +147,8 @@ include_directories (${SYSTEM_USR_DIR}) option (BUILDDOC "Build all doc." OFF) option (BUILDSWIG "Build swig modules." ON) option (BUILDSWIGPYTHON "Build swig python modules." ON) -option (BUILDSWIGNODE "Build swig node modules." ON) -option (BUILDSWIGJAVA "Build Java API." OFF) +option (BUILDSWIGNODE "Build swig node modules." OFF) +option (BUILDSWIGJAVA "Build Java API." ON) option (USBPLAT "Detection USB platform." OFF) option (FIRMATA "Add Firmata support to mraa." OFF) option (ONEWIRE "Add Onewire support to mraa." ON) diff --git a/include/version.h b/include/version.h index 47366ef..3a567a1 100644 --- a/include/version.h +++ b/include/version.h @@ -11,8 +11,8 @@ extern "C" { #endif -const char* gVERSION; -const char* gVERSION_SHORT; +extern const char* gVERSION; +extern const char* gVERSION_SHORT; #ifdef __cplusplus }
Build and install mraa.
root@rock-4c-plus:/home/rock# mkdir build root@rock-4c-plus:/home/rock# cd build/ root@rock-4c-plus:/home/rock# cmake .. root@rock-4c-plus:/home/rock# make rooroot@rock-4c-plus:/home/rock# make install root@rock-4c-plus:/home/rock# ldconfig root@rock-4c-plus:/home/rock# mraa-gpio version Version v2.1.0 on ROCK Pi 4
Install example: Install Mraa on ROCK Pi 4B Debian11 armhf system
For Debian11 Distribution the below commands install the essential set:
root@rockpi-4b:/home/rock# apt-get install -y git build-essential swig4.0 python-dev cmake libnode-dev python3-dev pkg-config tree root@rockpi-4b:/home/rock# apt-get install -y libc6 libjson-c5 libjson-c-dev libgtest-dev libgcc1 libstdc++6 python python2.7 libpython2.7 python3.9 libpython3.9 root@rockpi-4b:/home/rock# apt-get install -y libgtest-dev pkg-config cmake-data
Get source code.
root@rockpi-4b:/home/rock# git clone -b master https://github.com/radxa/mraa.git root@rockpi-4b:/home/rock# cd mraa
Patch the source code for building mraa.
diff --git a/CMakeLists.txt b/CMakeLists.txt index 250d910..9050100 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8.11) +cmake_minimum_required (VERSION 3.14.0) project (mraa C CXX) FIND_PACKAGE (Threads REQUIRED) @@ -9,6 +9,8 @@ if (CMAKE_VERSION VERSION_LESS "3.1") endif () else () set (CMAKE_C_STANDARD 99) + cmake_policy(SET CMP0078 OLD) + cmake_policy(SET CMP0086 NEW) endif () ############################################################################### diff --git a/include/version.h b/include/version.h index 47366ef..3a567a1 100644 --- a/include/version.h +++ b/include/version.h @@ -11,8 +11,8 @@ extern "C" { #endif -const char* gVERSION; -const char* gVERSION_SHORT; +extern const char* gVERSION; +extern const char* gVERSION_SHORT; #ifdef __cplusplus }
Build and install mraa
root@rockpi-4b:/home/rock/mraa# mkdir build root@rockpi-4b:/home/rock/mraa# cd build root@rockpi-4b:/home/rock/mraa/build# cmake .. root@rockpi-4b:/home/rock/mraa/build# make root@rockpi-4b:/home/rock/mraa/build# make install root@rockpi-4b:/home/rock/mraa/build# ldconfig root@rockpi-4b:/home/rock/mraa/build# mraa-gpio version Version v2.1.0-25-gf854463 on ROCK Pi 4
Backup prebuilt mraa on directory output.
root@rockpi-4b:/home/rock/mraa/build# mkdir output root@rockpi-4b:/home/rock/mraa/build# make install DESTDIR=output root@rockpi-4b:/home/rock/mraa/build# tree output
Use mraa
Since we have installed mraa successfully, now we start to use it. At this part, you can check out the following guides.
Troubleshooting
- If you have an issue, start a new post on the forum. https://forum.radxa.com/.