Need help to configure makefile flags from Rasp3 to Rasp 4

Hi,
can please someone help me to get the following code running on a Raspberry 4 and DietPi or tell me where to find information how to do it or where I can find help? As far as I know the flags have to be changed.

This makefile.arm-Code is for the raspberry 3 and I need it for my raspberry 4.

https://github.com/baycom/tfrec

PACKAGES= librtlsdr

CXX=g++

PROFILING=
DEFINES=
PKG_INCLUDES= $(shell pkg-config --cflags $(PACKAGES))
PKG_LIBS= $(shell pkg-config --libs $(PACKAGES))

CXXFLAGS=-O3 $(PROFILING) -mfpu=crypto-neon-fp-armv8 -mfloat-abi=hard -ftree-vectorize -ffast-math \
	      -std=c++0x -Wall \
	      -Wno-unused-function  -Wno-unused-variable -Wno-unused-but-set-variable \
	      -Wno-write-strings

INCLUDES= $(PKG_INCLUDES) 

LIBS=-lm $(PKG_LIBS) -lpthread
LDFLAGS=$(PROFILING) -rdynamic

CFILES=main.cpp engine.cpp  dsp_stuff.cpp fm_demod.cpp decoder.cpp crc8.cpp \
	tfa1.cpp tfa2.cpp utils.cpp sdr.cpp whb.cpp crc32.cpp

OBJS = $(CFILES:.cpp=.o)

all: tfrec

tfrec: $(OBJS)
	 $(CXX) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)

.cpp.o:
	$(CXX) $(CXXFLAGS) $(DEFINES) $(INCLUDES) -c $<

ifneq ($(MAKECMDGOALS),clean)
include .depend
endif

.depend: Makefile
	touch .depend
	makedepend $(DEF) $(INCL)  $(CFLAGS) $(CFILES) -f .depend >/dev/null 2>&1 || /bin/true

clean :
	$(RM) $(OBJS) *~
	$(RM) tfrec
	$(RM) .depend

Do you want to run it on a 32-bit image or 64-bit image? For 64-bit it looks all right already, but at least the following build tools are required:

apt install make g++ pkg-config

For 32-bit the following part needs to be changed: -mfpu=crypto-neon-fp-armv8
But I’d need to look for the correct one.

Hi,
I want to run it on a 64-bit version. I tried it already. But it didnt work.

I will give it a try again with the packages you have named first installed.

Back in a sec…

Thank you very much so far.

As well post the error message once stuck

Yes, an error :cry: :

g++: error: unrecognized command line option ‘-mfpu=crypto-neon-fp-armv8’
g++: error: unrecognized command line option ‘-mfloat-abi=hard’

To be true, I also lack knowledge of all that compiling options, but actually, as long as you’re not cross-compiling e.g. on a PC for that SBC, it should be possible to simply remove those two options from the Makefile.

Na, this didnt work either: I got this kind of errors. Like the days before as I have tried to get it working:

g++ -O3   -ftree-vectorize -ffast-math -std=c++0x -Wall -Wno-unused-function  -Wno-unused-variable -Wno-unused-but-set-variable -Wno-write-strings  -I/  -c main.cpp
main.cpp: In function ‘void read_raw_msgs(std::vector<demodulator*>*, char*)’:
main.cpp:41:36: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
   while((x=strsep(&dp, " ")) && len<sizeof(dbuf)) {
                                 ~~~^~~~~~~~~~~~~
main.cpp:45:16: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<demodulator*>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   for(int n=0;n<demods->size();n++) {
               ~^~~~~~~~~~~~~~~
main.cpp: In function ‘int main(int, char**)’:
main.cpp:232:16: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<demodulator*>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   for(int n=0;n<demods.size();n++)
               ~^~~~~~~~~~~~~~
g++ -O3   -ftree-vectorize -ffast-math -std=c++0x -Wall -Wno-unused-function  -Wno-unused-variable -Wno-unused-but-set-variable -Wno-write-strings  -I/  -c engine.cpp
g++ -O3   -ftree-vectorize -ffast-math -std=c++0x -Wall -Wno-unused-function  -Wno-unused-variable -Wno-unused-but-set-variable -Wno-write-strings  -I/  -c dsp_stuff.cpp
g++ -O3   -ftree-vectorize -ffast-math -std=c++0x -Wall -Wno-unused-function  -Wno-unused-variable -Wno-unused-but-set-variable -Wno-write-strings  -I/  -c fm_demod.cpp
fm_demod.cpp: In member function ‘void fsk_demod::process(int16_t*, int)’:
fm_demod.cpp:38:15: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<demodulator*>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
  for(int n=0;n<demods->size();n++) {
              ~^~~~~~~~~~~~~~~
fm_demod.cpp:48:16: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vector<demodulator*>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   for(int n=0;n<demods->size();n++)
               ~^~~~~~~~~~~~~~~
g++ -O3   -ftree-vectorize -ffast-math -std=c++0x -Wall -Wno-unused-function  -Wno-unused-variable -Wno-unused-but-set-variable -Wno-write-strings  -I/  -c decoder.cpp
decoder.cpp: In member function ‘virtual void decoder::execute_handler(sensordata_t&)’:
decoder.cpp:73:29: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 5 has type ‘uint64_t’ {aka ‘long unsigned int’}  -Wformat=]
    snprintf(cmd,sizeof(cmd),"%s %04llx %+.1f %g %i %i %i %i %li",
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
decoder.cpp:75:6:
      nid, d.temp, d.humidity,
      ~~~
decoder.cpp:83:29: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 5 has type ‘uint64_t’ {aka ‘long unsigned int’}  -Wformat=]
    snprintf(cmd,sizeof(cmd),"%s %013llx %+.1f %g %i %i %i %i %li",
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
decoder.cpp:85:6:
      nid, d.temp, d.humidity,
      ~~~
g++ -O3   -ftree-vectorize -ffast-math -std=c++0x -Wall -Wno-unused-function  -Wno-unused-variable -Wno-unused-but-set-variable -Wno-write-strings  -I/  -c crc8.cpp
g++ -O3   -ftree-vectorize -ffast-math -std=c++0x -Wall -Wno-unused-function  -Wno-unused-variable -Wno-unused-but-set-variable -Wno-write-strings  -I/  -c tfa1.cpp
g++ -O3   -ftree-vectorize -ffast-math -std=c++0x -Wall -Wno-unused-function  -Wno-unused-variable -Wno-unused-but-set-variable -Wno-write-strings  -I/  -c tfa2.cpp
tfa2.cpp: In member function ‘void tfa2_decoder::flush_tx22(int, int)’:
tfa2.cpp:207:10: warning: ‘crc_calc’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    printf("TX22(%02x) BAD %i RSSI %i  Offset %.0lfkHz (CRC %02x %02x) len %i\n",1<<type,bad,rssi,
    ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           -1536.0*offset/131072,
           ~~~~~~~~~~~~~~~~~~~~~~
           crc_val,crc_calc,byte_cnt);
           ~~~~~~~~~~~~~~~~~~~~~~~~~~
tfa2.cpp:207:10: warning: ‘crc_val’ may be used uninitialized in this function [-Wmaybe-uninitialized]
g++ -O3   -ftree-vectorize -ffast-math -std=c++0x -Wall -Wno-unused-function  -Wno-unused-variable -Wno-unused-but-set-variable -Wno-write-strings  -I/  -c utils.cpp
g++ -O3   -ftree-vectorize -ffast-math -std=c++0x -Wall -Wno-unused-function  -Wno-unused-variable -Wno-unused-but-set-variable -Wno-write-strings  -I/  -c sdr.cpp
sdr.cpp: In static member function ‘static int sdr::search_device(char*)’:
sdr.cpp:93:29: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size between 254 and 764 [-Wformat-truncation=]
    snprintf(sum,sizeof(sum),"%s %s SN%s",vendor, product, serial);
                             ^~~~~~~~~~~~                  ~~~~~~
sdr.cpp:93:12: note: ‘snprintf’ output between 5 and 770 bytes into a destination of size 768
    snprintf(sum,sizeof(sum),"%s %s SN%s",vendor, product, serial);
    ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
g++ -O3   -ftree-vectorize -ffast-math -std=c++0x -Wall -Wno-unused-function  -Wno-unused-variable -Wno-unused-but-set-variable -Wno-write-strings  -I/  -c whb.cpp
whb.cpp: In member function ‘void whb_decoder::decode_02(uint8_t*, uint64_t, int, int)’:
whb.cpp:121:10: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘uint64_t’ {aka ‘long unsigned int’} [-Wformat=]
   printf("WHB02 ID %llx TEMP %g, PTEMP %g\n",
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          id, cvt_temp(temp), cvt_temp(temp_prev));
          ~~
whb.cpp: In member function ‘void whb_decoder::decode_03(uint8_t*, uint64_t, int, int)’:
whb.cpp:150:10: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘uint64_t’ {aka ‘long unsigned int’} [-Wformat=]
   printf("WHB03 ID %llx TEMP %g HUM %i, PTEMP %g PHUM %i\n",
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          id, cvt_temp(temp), hum, cvt_temp(temp_prev), hum_prev);
          ~~
whb.cpp: In member function ‘void whb_decoder::decode_04(uint8_t*, uint64_t, int, int)’:
whb.cpp:180:10: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘uint64_t’ {aka ‘long unsigned int’} [-Wformat=]
   printf("WHB04 ID %llx TEMP %g HUM %i WET %i, PTEMP %g PHUM %i PWET %i\n",
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          id, cvt_temp(temp),hum,(wet&1)^1, cvt_temp(temp_prev), hum_prev, (wet_prev&1)^1);
          ~~
whb.cpp: In member function ‘void whb_decoder::decode_06(uint8_t*, uint64_t, int, int)’:
whb.cpp:214:10: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘uint64_t’ {aka ‘long unsigned int’} [-Wformat=]
   printf("WHB06 ID %llx TEMP %g HUM %i TEMP2 %g, PTEMP %g PHUM %i PTEMP2 %g\n",
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          id, cvt_temp(temp),hum,cvt_temp(temp2), cvt_temp(temp_prev), hum_prev, cvt_temp(temp2_prev));
          ~~
whb.cpp: In member function ‘void whb_decoder::decode_07(uint8_t*, uint64_t, int, int)’:
whb.cpp:247:10: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘uint64_t’ {aka ‘long unsigned int’} [-Wformat=]
   printf("WHB07 ID %llx TEMP_IN %g HUM_IN %i TEMP_OUT %g HUM_OUT %i",id, cvt_temp(temp[0]), hum[0], cvt_temp(temp[1]), hum[1]);
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~
whb.cpp: In member function ‘void whb_decoder::decode_08(uint8_t*, uint64_t, int, int)’:
whb.cpp:282:10: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘uint64_t’ {aka ‘long unsigned int’} [-Wformat=]
   printf("WHB08 ID %llx cnt %i\n",id, cnt);
          ^~~~~~~~~~~~~~~~~~~~~~~~ ~~
whb.cpp:289:11: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘uint64_t’ {aka ‘long unsigned int’} [-Wformat=]
    printf("WHB08 ID %llx #%i time %i\n",id,i,times[i]);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~
whb.cpp: In member function ‘void whb_decoder::decode_0b(uint8_t*, uint64_t, int, int)’:
whb.cpp:319:27: warning: suggest parentheses around ‘+’ in operand of ‘&’ [-Wparentheses]
   speed[i]= ((v>>16)&0xff + 256*((v>>25)&1))/10.0;
                      ~~~~~^~~~~~~~~~~~~~~~~
whb.cpp:320:26: warning: suggest parentheses around ‘+’ in operand of ‘&’ [-Wparentheses]
   gust[i]=  ((v>>8)&0xff + 256*((v>>24)&1))/10.0;
                     ~~~~~^~~~~~~~~~~~~~~~~
whb.cpp:323:11: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘uint64_t’ {aka ‘long unsigned int’} [-Wformat=]
    printf("WHB0b ID %llx #%i DIR %f SPEED %f GUST %f time %i\n",
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           id, i,dir[i],speed[i],gust[i],times[i]);
           ~~
whb.cpp: In member function ‘void whb_decoder::decode_10(uint8_t*, uint64_t, int, int)’:
whb.cpp:357:11: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘uint64_t’ {aka ‘long unsigned int’} [-Wformat=]
    printf("WHB10 ID %llx #%i %i %i\n",id,i,state[i],times[i]);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~
whb.cpp: In member function ‘void whb_decoder::decode_11(uint8_t*, uint64_t, int, int)’:
whb.cpp:386:10: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘uint64_t’ {aka ‘long unsigned int’} [-Wformat=]
   printf("WHB11 %llx TEMP1 %g HUM1 %i TEMP2 %g HUM2 %i TEMP3 %g HUM3 %i TEMP_IN %g HUM_IN %i",
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          id, cvt_temp(temp[0]),hum[0], cvt_temp(temp[1]),hum[1], cvt_temp(temp[2]),hum[2], cvt_temp(temp[3]),hum[3]);
          ~~
whb.cpp: In member function ‘void whb_decoder::decode_12(uint8_t*, uint64_t, int, int)’:
whb.cpp:427:10: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘uint64_t’ {aka ‘long unsigned int’} [-Wformat=]
   printf("WHB12 %llx TEMP %g HUM %i HUM3h %i HUM24h %i HUM7d %i HUM30d %i\n",
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          id, cvt_temp(temp), hum[0], hum[1], hum[2], hum[3], hum[4]);
          ~~
g++ -O3   -ftree-vectorize -ffast-math -std=c++0x -Wall -Wno-unused-function  -Wno-unused-variable -Wno-unused-but-set-variable -Wno-write-strings  -I/  -c crc32.cpp
g++  -rdynamic -o tfrec main.o engine.o dsp_stuff.o fm_demod.o decoder.o crc8.o tfa1.o tfa2.o utils.o sdr.o whb.o crc32.o -lm -L -lrtlsdr -lpthread
/usr/bin/ld: sdr.o: in function `sdr::read_thread()':
sdr.cpp:(.text+0xf0): undefined reference to `rtlsdr_read_async'
/usr/bin/ld: sdr.o: in function `sdr::sdr(int, int, int, char*)':
sdr.cpp:(.text+0x314): undefined reference to `rtlsdr_get_device_usb_strings'
/usr/bin/ld: sdr.cpp:(.text+0x3ac): undefined reference to `rtlsdr_open'
/usr/bin/ld: sdr.cpp:(.text+0x3c4): undefined reference to `rtlsdr_set_freq_correction'
/usr/bin/ld: sdr.o: in function `sdr::~sdr()':
sdr.cpp:(.text+0x4b8): undefined reference to `rtlsdr_cancel_async'
/usr/bin/ld: sdr.o: in function `sdr::search_device(char*)':
sdr.cpp:(.text+0x550): undefined reference to `rtlsdr_get_device_count'
/usr/bin/ld: sdr.cpp:(.text+0x5e0): undefined reference to `rtlsdr_get_device_usb_strings'
/usr/bin/ld: sdr.o: in function `sdr::start()':
sdr.cpp:(.text+0x6c4): undefined reference to `rtlsdr_reset_buffer'
/usr/bin/ld: sdr.o: in function `sdr::stop()':
sdr.cpp:(.text+0x7ac): undefined reference to `rtlsdr_cancel_async'
/usr/bin/ld: sdr.o: in function `sdr::set_frequency(unsigned int)':
sdr.cpp:(.text+0x864): undefined reference to `rtlsdr_set_center_freq'
/usr/bin/ld: sdr.o: in function `sdr::nearest_gain(int)':
sdr.cpp:(.text+0x8f0): undefined reference to `rtlsdr_set_tuner_gain_mode'
/usr/bin/ld: sdr.cpp:(.text+0x904): undefined reference to `rtlsdr_get_tuner_gains'
/usr/bin/ld: sdr.cpp:(.text+0x924): undefined reference to `rtlsdr_get_tuner_gains'
/usr/bin/ld: sdr.o: in function `sdr::set_gain(int, float)':
sdr.cpp:(.text+0x9ec): undefined reference to `rtlsdr_set_tuner_gain_mode'
/usr/bin/ld: sdr.cpp:(.text+0xa44): undefined reference to `rtlsdr_set_tuner_gain_mode'
/usr/bin/ld: sdr.cpp:(.text+0xa50): undefined reference to `rtlsdr_set_tuner_gain'
/usr/bin/ld: sdr.o: in function `sdr::set_ppm(int)':
sdr.cpp:(.text+0xab0): undefined reference to `rtlsdr_set_freq_correction'
/usr/bin/ld: sdr.o: in function `sdr::set_samplerate(int)':
sdr.cpp:(.text+0xaf4): undefined reference to `rtlsdr_set_sample_rate'
collect2: error: ld returned 1 exit status
make: *** [Makefile.arm:28: tfrec] Error 1

It’s mostly just warnings, indicating bad or outdated programming. The last however is an error because of a missing library. This one seems right:

apt install librtlsdr-dev

The other linked pthread library should be part out the c++ standard library that should be installed already.

Hi,
sorry the package

librtlsdr-dev

was already installed. Tried again, same problems as before. Do you think the hardware must be pluged in one of the USB ports? I think I tested it some weeks before, but it didnt work either…

g++  -rdynamic -o tfrec main.o engine.o dsp_stuff.o fm_demod.o decoder.o crc8.o tfa1.o tfa2.o utils.o sdr.o whb.o crc32.o -lm -L -lrtlsdr -lpthread
/usr/bin/ld: sdr.o: in function `sdr::read_thread()':
sdr.cpp:(.text+0xf0): undefined reference to `rtlsdr_read_async'
/usr/bin/ld: sdr.o: in function `sdr::sdr(int, int, int, char*)':
sdr.cpp:(.text+0x314): undefined reference to `rtlsdr_get_device_usb_strings'
/usr/bin/ld: sdr.cpp:(.text+0x3ac): undefined reference to `rtlsdr_open'
/usr/bin/ld: sdr.cpp:(.text+0x3c4): undefined reference to `rtlsdr_set_freq_correction'
/usr/bin/ld: sdr.o: in function `sdr::~sdr()':
sdr.cpp:(.text+0x4b8): undefined reference to `rtlsdr_cancel_async'
/usr/bin/ld: sdr.o: in function `sdr::search_device(char*)':
sdr.cpp:(.text+0x550): undefined reference to `rtlsdr_get_device_count'
/usr/bin/ld: sdr.cpp:(.text+0x5e0): undefined reference to `rtlsdr_get_device_usb_strings'
/usr/bin/ld: sdr.o: in function `sdr::start()':
sdr.cpp:(.text+0x6c4): undefined reference to `rtlsdr_reset_buffer'
/usr/bin/ld: sdr.o: in function `sdr::stop()':
sdr.cpp:(.text+0x7ac): undefined reference to `rtlsdr_cancel_async'
/usr/bin/ld: sdr.o: in function `sdr::set_frequency(unsigned int)':
sdr.cpp:(.text+0x864): undefined reference to `rtlsdr_set_center_freq'
/usr/bin/ld: sdr.o: in function `sdr::nearest_gain(int)':
sdr.cpp:(.text+0x8f0): undefined reference to `rtlsdr_set_tuner_gain_mode'
/usr/bin/ld: sdr.cpp:(.text+0x904): undefined reference to `rtlsdr_get_tuner_gains'
/usr/bin/ld: sdr.cpp:(.text+0x924): undefined reference to `rtlsdr_get_tuner_gains'
/usr/bin/ld: sdr.o: in function `sdr::set_gain(int, float)':
sdr.cpp:(.text+0x9ec): undefined reference to `rtlsdr_set_tuner_gain_mode'
/usr/bin/ld: sdr.cpp:(.text+0xa44): undefined reference to `rtlsdr_set_tuner_gain_mode'
/usr/bin/ld: sdr.cpp:(.text+0xa50): undefined reference to `rtlsdr_set_tuner_gain'
/usr/bin/ld: sdr.o: in function `sdr::set_ppm(int)':
sdr.cpp:(.text+0xab0): undefined reference to `rtlsdr_set_freq_correction'
/usr/bin/ld: sdr.o: in function `sdr::set_samplerate(int)':
sdr.cpp:(.text+0xaf4): undefined reference to `rtlsdr_set_sample_rate'
collect2: error: ld returned 1 exit status
make: *** [Makefile.arm:28: tfrec] Error 1