0

when I make the following project: https://github.com/ovrheat/raspberry_rtl_wh1080#readme on my raspberry pi, I end up with errors:

     sudo make
[  6%] Building C object src/CMakeFiles/data.dir/data.c.o
/home/pi/raspberry_rtl_wh1080/src/data.c:88:35: warning: cast between incompatible function types from ‘void (*)(data_t *)’ {aka ‘void (*)(struct data *)’} to ‘void * (*)(void *)’ [-Wcast-function-type]
   88 |       .array_element_release    = (array_element_release_fn) data_free,
      |                                   ^
/home/pi/raspberry_rtl_wh1080/src/data.c:89:35: warning: cast between incompatible function types from ‘void (*)(data_t *)’ {aka ‘void (*)(struct data *)’} to ‘void * (*)(void *)’ [-Wcast-function-type]
   89 |       .value_release            = (value_release_fn) data_free },
      |                                   ^
/home/pi/raspberry_rtl_wh1080/src/data.c:96:35: warning: cast between incompatible function types from ‘void (*)(void *)’ to ‘void * (*)(void *)’ [-Wcast-function-type]
   96 |       .value_release            = (value_release_fn) free },
      |                                   ^
/home/pi/raspberry_rtl_wh1080/src/data.c:103:35: warning: cast between incompatible function types from ‘void (*)(void *)’ to ‘void * (*)(void *)’ [-Wcast-function-type]
  103 |       .value_release            = (value_release_fn) free },
      |                                   ^
/home/pi/raspberry_rtl_wh1080/src/data.c:109:35: warning: cast between incompatible function types from ‘void (*)(void *)’ to ‘void * (*)(void *)’ [-Wcast-function-type]
  109 |       .array_element_release    = (array_element_release_fn) free,
      |                                   ^
/home/pi/raspberry_rtl_wh1080/src/data.c:110:35: warning: cast between incompatible function types from ‘void (*)(void *)’ to ‘void * (*)(void *)’ [-Wcast-function-type]
  110 |       .value_release            = (value_release_fn) free },
      |                                   ^
/home/pi/raspberry_rtl_wh1080/src/data.c:116:35: warning: cast between incompatible function types from ‘void (*)(data_array_t *)’ {aka ‘void (*)(struct data_array *)’} to ‘void * (*)(void *)’ [-Wcast-function-type]
  116 |       .array_element_release    = (array_element_release_fn) data_array_free ,
      |                                   ^
/home/pi/raspberry_rtl_wh1080/src/data.c:117:35: warning: cast between incompatible function types from ‘void (*)(data_array_t *)’ {aka ‘void (*)(struct data_array *)’} to ‘void * (*)(void *)’ [-Wcast-function-type]
  117 |       .value_release            = (value_release_fn) data_array_free },
      |                                   ^
[ 13%] Linking C static library libdata.a
[ 13%] Built target data
[ 20%] Building C object src/CMakeFiles/rtl_433.dir/baseband.c.o
[ 26%] Building C object src/CMakeFiles/rtl_433.dir/bitbuffer.c.o
[ 33%] Building C object src/CMakeFiles/rtl_433.dir/data.c.o
/home/pi/raspberry_rtl_wh1080/src/data.c:88:35: warning: cast between incompatible function types from ‘void (*)(data_t *)’ {aka ‘void (*)(struct data *)’} to ‘void * (*)(void *)’ [-Wcast-function-type]
   88 |       .array_element_release    = (array_element_release_fn) data_free,
      |                                   ^
/home/pi/raspberry_rtl_wh1080/src/data.c:89:35: warning: cast between incompatible function types from ‘void (*)(data_t *)’ {aka ‘void (*)(struct data *)’} to ‘void * (*)(void *)’ [-Wcast-function-type]
   89 |       .value_release            = (value_release_fn) data_free },
      |                                   ^
/home/pi/raspberry_rtl_wh1080/src/data.c:96:35: warning: cast between incompatible function types from ‘void (*)(void *)’ to ‘void * (*)(void *)’ [-Wcast-function-type]
   96 |       .value_release            = (value_release_fn) free },
      |                                   ^
/home/pi/raspberry_rtl_wh1080/src/data.c:103:35: warning: cast between incompatible function types from ‘void (*)(void *)’ to ‘void * (*)(void *)’ [-Wcast-function-type]
  103 |       .value_release            = (value_release_fn) free },
      |                                   ^
/home/pi/raspberry_rtl_wh1080/src/data.c:109:35: warning: cast between incompatible function types from ‘void (*)(void *)’ to ‘void * (*)(void *)’ [-Wcast-function-type]
  109 |       .array_element_release    = (array_element_release_fn) free,
      |                                   ^
/home/pi/raspberry_rtl_wh1080/src/data.c:110:35: warning: cast between incompatible function types from ‘void (*)(void *)’ to ‘void * (*)(void *)’ [-Wcast-function-type]
  110 |       .value_release            = (value_release_fn) free },
      |                                   ^
/home/pi/raspberry_rtl_wh1080/src/data.c:116:35: warning: cast between incompatible function types from ‘void (*)(data_array_t *)’ {aka ‘void (*)(struct data_array *)’} to ‘void * (*)(void *)’ [-Wcast-function-type]
  116 |       .array_element_release    = (array_element_release_fn) data_array_free ,
      |                                   ^
/home/pi/raspberry_rtl_wh1080/src/data.c:117:35: warning: cast between incompatible function types from ‘void (*)(data_array_t *)’ {aka ‘void (*)(struct data_array *)’} to ‘void * (*)(void *)’ [-Wcast-function-type]
  117 |       .value_release            = (value_release_fn) data_array_free },
      |                                   ^
[ 40%] Building C object src/CMakeFiles/rtl_433.dir/pulse_demod.c.o
[ 46%] Building C object src/CMakeFiles/rtl_433.dir/pulse_detect.c.o
[ 53%] Building C object src/CMakeFiles/rtl_433.dir/rtl_433.c.o
[ 60%] Building C object src/CMakeFiles/rtl_433.dir/optparse.c.o
[ 66%] Building C object src/CMakeFiles/rtl_433.dir/util.c.o
[ 73%] Building C object src/CMakeFiles/rtl_433.dir/devices/flex.c.o
[ 80%] Building C object src/CMakeFiles/rtl_433.dir/devices/fineoffset_wh1080.c.o
In file included from /usr/include/aarch64-linux-gnu/bits/libc-header-start.h:33,
                 from /usr/include/stdio.h:27,
                 from /home/pi/raspberry_rtl_wh1080/include/data.h:24,
                 from /home/pi/raspberry_rtl_wh1080/src/devices/fineoffset_wh1080.c:102:
/usr/include/features.h:187:3: warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
  187 | # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
      |   ^~~~~~~
[ 86%] Linking C executable rtl_433
/usr/bin/ld: CMakeFiles/rtl_433.dir/devices/fineoffset_wh1080.c.o: in function `bmp085_i2c_Read_Int':
fineoffset_wh1080.c:(.text+0x80): undefined reference to `i2c_smbus_read_word_data'
/usr/bin/ld: CMakeFiles/rtl_433.dir/devices/fineoffset_wh1080.c.o: in function `bmp085_i2c_Write_Byte':
fineoffset_wh1080.c:(.text+0xc0): undefined reference to `i2c_smbus_write_byte_data'
/usr/bin/ld: CMakeFiles/rtl_433.dir/devices/fineoffset_wh1080.c.o: in function `bmp085_i2c_Read_Block':
fineoffset_wh1080.c:(.text+0xf0): undefined reference to `i2c_smbus_read_i2c_block_data'
/usr/bin/ld: CMakeFiles/rtl_433.dir/devices/fineoffset_wh1080.c.o: in function `bmp085_Calibration':
fineoffset_wh1080.c:(.text+0x150): undefined reference to `i2c_smbus_read_word_data'
/usr/bin/ld: fineoffset_wh1080.c:(.text+0x178): undefined reference to `i2c_smbus_read_word_data'
/usr/bin/ld: fineoffset_wh1080.c:(.text+0x198): undefined reference to `i2c_smbus_read_word_data'
/usr/bin/ld: fineoffset_wh1080.c:(.text+0x1b8): undefined reference to `i2c_smbus_read_word_data'
/usr/bin/ld: fineoffset_wh1080.c:(.text+0x1d8): undefined reference to `i2c_smbus_read_word_data'
/usr/bin/ld: CMakeFiles/rtl_433.dir/devices/fineoffset_wh1080.c.o:fineoffset_wh1080.c:(.text+0x1f8): more undefined references to `i2c_smbus_read_word_data' follow
/usr/bin/ld: CMakeFiles/rtl_433.dir/devices/fineoffset_wh1080.c.o: in function `bmp085_ReadUT':
fineoffset_wh1080.c:(.text+0x320): undefined reference to `i2c_smbus_write_byte_data'
/usr/bin/ld: fineoffset_wh1080.c:(.text+0x338): undefined reference to `i2c_smbus_read_word_data'
/usr/bin/ld: CMakeFiles/rtl_433.dir/devices/fineoffset_wh1080.c.o: in function `bmp085_ReadUP':
fineoffset_wh1080.c:(.text+0x3c0): undefined reference to `i2c_smbus_write_byte_data'
/usr/bin/ld: fineoffset_wh1080.c:(.text+0x3e0): undefined reference to `i2c_smbus_read_i2c_block_data'
/usr/bin/ld: CMakeFiles/rtl_433.dir/devices/fineoffset_wh1080.c.o: in function `read_int_temp':
fineoffset_wh1080.c:(.text+0x588): undefined reference to `i2c_smbus_write_byte_data'
/usr/bin/ld: fineoffset_wh1080.c:(.text+0x5a0): undefined reference to `i2c_smbus_read_word_data'
/usr/bin/ld: CMakeFiles/rtl_433.dir/devices/fineoffset_wh1080.c.o: in function `read_press':
fineoffset_wh1080.c:(.text+0x694): undefined reference to `i2c_smbus_write_byte_data'
/usr/bin/ld: fineoffset_wh1080.c:(.text+0x6ac): undefined reference to `i2c_smbus_read_word_data'
collect2: error: ld returned 1 exit status
make[2]: *** [src/CMakeFiles/rtl_433.dir/build.make:239: src/rtl_433] Fehler 1
make[1]: *** [CMakeFiles/Makefile2:212: src/CMakeFiles/rtl_433.dir/all] Fehler 2
make: *** [Makefile:149: all] Fehler 2

How to solve this? I've followed the instructions, but unfortunately no success. The project owner has not replied to a similar question, therefore I try to find an answer here Is there any lib missing? Any possibility for better debugging?

  • Does this answer your question? [Can't compile i2c\_smbus\_write\_byte on Raspberry Pi 4](https://stackoverflow.com/questions/61657749/cant-compile-i2c-smbus-write-byte-on-raspberry-pi-4) – fabian Jul 19 '22 at 17:19
  • Btw: why do you build with superuser rights? This way the results of the build including the intermediate files are owned by root preventing you from working with this build directory without superuser rights... – fabian Jul 19 '22 at 17:22
  • Thanks @ Fabian, I‘ll check immediately. The Su I had to use after playing around with ownership. I have to fix this. – Michael Mueller Jul 19 '22 at 17:34
  • Hi fabian, I followed the steps in the post and I can compile the example. Then I've added the missing include to my project. How can I add the -li2c to the makefile? I think this is the issue on top of it – Michael Mueller Jul 19 '22 at 17:58
  • By modifying the appropriate [`target_link_libraries`](https://cmake.org/cmake/help/latest/command/target_link_libraries.html) command in the **C**Make files (or adding a new one)... – fabian Jul 19 '22 at 18:00
  • @fabian, how does it look like? All references seems to require sources for the lib, but I'm looking for the equivalent to a simple gcc test.c -li2c. How can I do this in the CMakelists file? – Michael Mueller Jul 19 '22 at 18:15
  • `target_link_libraries(rtl_433 PRIVATE i2c)` (that is if the lib and headers can be found by the compiler, otherwise `target_link_directories` and `target_include_directories` could be necessary) – fabian Jul 19 '22 at 18:23
  • Unfortunately it says something like i2c is not part of the project. So this does not work – Michael Mueller Jul 19 '22 at 18:54

1 Answers1

0

Solved now. And a big thanks to @fabian. There are two steps:

  1. The includes have been changed (Please follow: Can't compile i2c_smbus_write_byte on Raspberry Pi 4)
  2. The CMakelists.txt in the /src folder needs to be extended on line 38 to the following:
    target_link_libraries(rtl_433
        ${SDR_LIBRARIES}
        ${CMAKE_THREAD_LIBS_INIT} i2c
    )
    
Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77