I want to use GPIO with C/C++. I am trying to build wiringX but I recive error.
radxa@rock-pi-4b-plus:~$ git clone https://github.com/radxa/wiringX.git
Cloning into ‘wiringX’…
remote: Enumerating objects: 571, done.
remote: Total 571 (delta 0), reused 0 (delta 0), pack-reused 571
Receiving objects: 100% (571/571), 547.77 KiB | 1.63 MiB/s, done.
Resolving deltas: 100% (343/343), done.
radxa@rock-pi-4b-plus:~$ cd wiringX
radxa@rock-pi-4b-plus:~/wiringX$ mkdir build
radxa@rock-pi-4b-plus:~/wiringX$ cd build
radxa@rock-pi-4b-plus:~/wiringX/build$ cmake … -DCMAKE_C_FLAGS=-fPIC
– The C compiler identification is GNU 10.2.1
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Check for working C compiler: /usr/bin/cc - skipped
– Detecting C compile features
– Detecting C compile features - done
– Configuring done
– Generating done
– Build files have been written to: /home/radxa/wiringX/build
radxa@rock-pi-4b-plus:~/wiringX/build$ make
Scanning dependencies of target sources
[ 6%] Building C object CMakeFiles/sources.dir/src/bananapi.c.o
/home/radxa/wiringX/src/bananapi.c: In function ‘setup’:
/home/radxa/wiringX/src/bananapi.c:412:6: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
412 | if((int32_t)gpio == -1) {
| ^
[ 12%] Building C object CMakeFiles/sources.dir/src/ci20.c.o
/home/radxa/wiringX/src/ci20.c: In function ‘setup’:
/home/radxa/wiringX/src/ci20.c:172:5: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
172 | if((int32_t)gpio == -1) {
| ^
[ 18%] Building C object CMakeFiles/sources.dir/src/hummingboard.c.o
/home/radxa/wiringX/src/hummingboard.c: In function ‘setup’:
/home/radxa/wiringX/src/hummingboard.c:107:5: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
107 | if((int32_t)(gpio = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, MX6Q_IOMUXC_BASE_ADDR)) == -1) {
| ^
[ 25%] Building C object CMakeFiles/sources.dir/src/radxa.c.o
/home/radxa/wiringX/src/radxa.c:104:1: warning: useless storage class specifier in empty declaration
104 | };
| ^
/home/radxa/wiringX/src/radxa.c:135:1: warning: useless storage class specifier in empty declaration
135 | };
| ^
/home/radxa/wiringX/src/radxa.c:148:1: warning: useless storage class specifier in empty declaration
148 | };
| ^
/home/radxa/wiringX/src/radxa.c: In function ‘map_reg’:
/home/radxa/wiringX/src/radxa.c:295:15: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
295 | addr_start = (unsigned int)reg & pagemask;
| ^
/home/radxa/wiringX/src/radxa.c:296:16: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
296 | addr_offset = (unsigned int)reg & ~pagemask;
| ^
/home/radxa/wiringX/src/radxa.c: In function ‘radxaSetup’:
/home/radxa/wiringX/src/radxa.c:60:25: warning: passing argument 1 of ‘map_reg’ makes pointer from integer without a cast [-Wint-conversion]
60 | #define RK30_AIN_BASE 0x2006c000
| ^~~~~~~~~~
| |
| int
/home/radxa/wiringX/src/radxa.c:724:16: note: in expansion of macro ‘RK30_AIN_BASE’
724 | ret = map_reg(RK30_AIN_BASE, &ain);
| ^~~~~~~~~~~~~
/home/radxa/wiringX/src/radxa.c:278:26: note: expected ‘void *’ but argument is of type ‘int’
278 | static int map_reg(void *reg, void **reg_mapped) {
| ~~^
/home/radxa/wiringX/src/radxa.c:724:31: warning: passing argument 2 of ‘map_reg’ from incompatible pointer type [-Wincompatible-pointer-types]
724 | ret = map_reg(RK30_AIN_BASE, &ain);
| ^
| |
| volatile void **
/home/radxa/wiringX/src/radxa.c:278:38: note: expected ‘void **’ but argument is of type ‘volatile void **’
278 | static int map_reg(void *reg, void **reg_mapped) {
| ~^
/home/radxa/wiringX/src/radxa.c:72:33: warning: passing argument 1 of ‘map_reg’ makes pointer from integer without a cast [-Wint-conversion]
72 | #define RK30_PWM23_BASE 0x20050000
| ^~~~~~~~~~
| |
| int
/home/radxa/wiringX/src/radxa.c:728:16: note: in expansion of macro ‘RK30_PWM23_BASE’
728 | ret = map_reg(RK30_PWM23_BASE, &(pwm[4]));
| ^~~~~~~~~~~~~~~
/home/radxa/wiringX/src/radxa.c:278:26: note: expected ‘void *’ but argument is of type ‘int’
278 | static int map_reg(void *reg, void **reg_mapped) {
| ~~~~^
/home/radxa/wiringX/src/radxa.c:728:33: warning: passing argument 2 of ‘map_reg’ from incompatible pointer type [-Wincompatible-pointer-types]
728 | ret = map_reg(RK30_PWM23_BASE, &(pwm[4]));
| ^
| |
| volatile void **
/home/radxa/wiringX/src/radxa.c:278:38: note: expected ‘void **’ but argument is of type ‘volatile void **’
278 | static int map_reg(void *reg, void **reg_mapped) {
| ~~~~^
/home/radxa/wiringX/src/radxa.c:71:33: warning: passing argument 1 of ‘map_reg’ makes pointer from integer without a cast [-Wint-conversion]
71 | #define RK30_PWM01_BASE 0x20030000
| ^~~~~~~~~~
| |
| int
/home/radxa/wiringX/src/radxa.c:732:16: note: in expansion of macro ‘RK30_PWM01_BASE’
732 | ret = map_reg(RK30_PWM01_BASE, &(pwm[5]));
| ^~~~~~~~~~~~~~~
/home/radxa/wiringX/src/radxa.c:278:26: note: expected ‘void *’ but argument is of type ‘int’
278 | static int map_reg(void *reg, void **reg_mapped) {
| ~~~~^
/home/radxa/wiringX/src/radxa.c:732:33: warning: passing argument 2 of ‘map_reg’ from incompatible pointer type [-Wincompatible-pointer-types]
732 | ret = map_reg(RK30_PWM01_BASE, &(pwm[5]));
| ^
| |
| volatile void **
/home/radxa/wiringX/src/radxa.c:278:38: note: expected ‘void **’ but argument is of type ‘volatile void **’
278 | static int map_reg(void *reg, void **reg_mapped) {
| ~~~~^
[ 31%] Building C object CMakeFiles/sources.dir/src/raspberrypi.c.o
/home/radxa/wiringX/src/raspberrypi.c: In function ‘setup’:
/home/radxa/wiringX/src/raspberrypi.c:363:5: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
363 | if((int32_t)gpio == -1) {
| ^
[ 37%] Building C object CMakeFiles/sources.dir/src/wiringX.c.o
[ 37%] Built target sources
Scanning dependencies of target wiringx_shared
[ 43%] Linking C shared library libwiringX.so
/usr/bin/ld: CMakeFiles/sources.dir/src/ci20.c.o:(.bss+0x78): multiple definition of wiringXLog'; CMakeFiles/sources.dir/src/bananapi.c.o:(.bss+0x480): first defined here /usr/bin/ld: CMakeFiles/sources.dir/src/ci20.c.o:(.bss+0x70): multiple definition of
platforms’; CMakeFiles/sources.dir/src/bananapi.c.o:(.bss+0x478): first defined here
/usr/bin/ld: CMakeFiles/sources.dir/src/hummingboard.c.o:(.bss+0x78): multiple definition of wiringXLog'; CMakeFiles/sources.dir/src/bananapi.c.o:(.bss+0x480): first defined here /usr/bin/ld: CMakeFiles/sources.dir/src/hummingboard.c.o:(.bss+0x70): multiple definition of
platforms’; CMakeFiles/sources.dir/src/bananapi.c.o:(.bss+0x478): first defined here
/usr/bin/ld: CMakeFiles/sources.dir/src/radxa.c.o:(.bss+0x270): multiple definition of wiringXLog'; CMakeFiles/sources.dir/src/bananapi.c.o:(.bss+0x480): first defined here /usr/bin/ld: CMakeFiles/sources.dir/src/radxa.c.o:(.bss+0x268): multiple definition of
platforms’; CMakeFiles/sources.dir/src/bananapi.c.o:(.bss+0x478): first defined here
/usr/bin/ld: CMakeFiles/sources.dir/src/raspberrypi.c.o:(.bss+0xc0): multiple definition of wiringXLog'; CMakeFiles/sources.dir/src/bananapi.c.o:(.bss+0x480): first defined here /usr/bin/ld: CMakeFiles/sources.dir/src/raspberrypi.c.o:(.bss+0xb8): multiple definition of
platforms’; CMakeFiles/sources.dir/src/bananapi.c.o:(.bss+0x478): first defined here
/usr/bin/ld: CMakeFiles/sources.dir/src/wiringX.c.o:(.bss+0x30): multiple definition of platforms'; CMakeFiles/sources.dir/src/bananapi.c.o:(.bss+0x478): first defined here /usr/bin/ld: CMakeFiles/sources.dir/src/wiringX.c.o:(.bss+0x38): multiple definition of
wiringXLog’; CMakeFiles/sources.dir/src/bananapi.c.o:(.bss+0x480): first defined here
/usr/bin/ld: CMakeFiles/sources.dir/src/wiringX.c.o:(.bss+0x8): multiple definition of ci20'; CMakeFiles/sources.dir/src/ci20.c.o:(.bss+0x68): first defined here /usr/bin/ld: CMakeFiles/sources.dir/src/wiringX.c.o:(.bss+0x10): multiple definition of
radxa’; CMakeFiles/sources.dir/src/radxa.c.o:(.bss+0x260): first defined here
/usr/bin/ld: CMakeFiles/sources.dir/src/wiringX.c.o:(.bss+0x18): multiple definition of bananapi'; CMakeFiles/sources.dir/src/bananapi.c.o:(.bss+0x470): first defined here /usr/bin/ld: CMakeFiles/sources.dir/src/wiringX.c.o:(.bss+0x20): multiple definition of
raspberrypi’; CMakeFiles/sources.dir/src/raspberrypi.c.o:(.bss+0xb0): first defined here
/usr/bin/ld: CMakeFiles/sources.dir/src/wiringX.c.o:(.bss+0x28): multiple definition of `hummingboard’; CMakeFiles/sources.dir/src/hummingboard.c.o:(.bss+0x68): first defined here
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/wiringx_shared.dir/build.make:99: libwiringX.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:216: CMakeFiles/wiringx_shared.dir/all] Error 2
make: *** [Makefile:171: all] Error 2