0

I have been trying to build a C++ program using the i2c-dev.h library on Ubuntu Core 22.04.02 LTS, so I can read and write I2C packets. But I can't get my program to build correctly. I tried including the path in my makefile but the compiler returns errors from what appears to be compiling some of the Linux headers themselves.

Here is my makefile now:

CC = g++
CFLAGS = -Wall
ALL_LIBS = -lrt -lstdc++ -std=c++11 -pthread -L/opt/picoscope/lib -lps4000a -libi2c
INCLUDES = -I/opt/picoscope/include/libps4000a -I/usr/src/linux-headers-5.15.0-67-generic/include -I/usr/src/linux-headers-5.15.0-67-generic/arch/x86/include/generated
ALL_TARGET = verde

all: $(ALL_TARGET)

$(ALL_TARGET): verde.cpp verde.h $(CC) -o $(ALL_TARGET) verde.cpp $(CFLAGS) $(ALL_LIBS) $(INCLUDES)

clean: rm -f .o rm -f $(ALL_TARGET) rm -f .bin rm -f .csv rm -f .txt sudo rm -rf CPU* sudo rm -rf RF*

Here is the latest error message when running make:

In file included from /usr/include/linux/posix_types.h:5,
                 from /usr/src/linux-headers-5.15.0-1032-realtime/include/uapi/linux/types.h:14,
                 from /usr/src/linux-headers-5.15.0-1032-realtime/include/linux/types.h:6,
                 from /usr/src/linux-headers-5.15.0-1032-realtime/include/uapi/linux/i2c-dev.h:12,
                 from /usr/src/linux-headers-5.15.0-1032-realtime/include/linux/i2c-dev.h:12,
                 from verde.h:54,
                 from verde.cpp:28:
verde.cpp: In function ‘void loggingSwitchDetect()’:
verde.cpp:929:36: error: invalid conversion from ‘void*’ to ‘char**’ [-fpermissive]
  929 |         dioValInt = strtol(dioVal, NULL, 16);
      |                                    ^~~~
      |                                    |
      |                                    void*
In file included from /usr/include/c++/11/cstdlib:75,
                 from verde.h:33,
                 from verde.cpp:28:
/usr/include/stdlib.h:178:43: note:   initializing argument 2 of ‘long int strtol(const char*, char**, int)’
  178 |                         char **__restrict __endptr, int __base)
      |                         ~~~~~~~~~~~~~~~~~~^~~~~~~~

enter image description here

steeldriver
  • 142,475

0 Answers0