i2c_ error with JetPack 4.2


I followed this article to motor esc control.
After I open setThrottle.pro with ‘Qt Creator’ and then I did configure Project.
After click ‘build all’ I got an error.

Ubuntu 18.04 uses SMBus differently than earlier versions. So I added header file
extern “C” {
#include <i2c/smbus.h>
But still got an error.

/home/jetson/jetsonRACECAR/research/build-setThrottle-Desktop-Debug/JHPWMPCA9685.o:-1: In function `PCA9685::readByte(int)':
/home/jetson/jetsonRACECAR/research/setThrottle/JHPWMPCA9685.cpp:91: error: undefined reference to `i2c_smbus_read_byte_data'
/home/jetson/jetsonRACECAR/research/build-setThrottle-Desktop-Debug/JHPWMPCA9685.o:-1: In function `PCA9685::writeByte(int, int)':
/home/jetson/jetsonRACECAR/research/setThrottle/JHPWMPCA9685.cpp:106: error: undefined reference to `i2c_smbus_write_byte_data'
:-1: error: collect2: error: ld returned 1 exit status

I don’t know what should I do Please help.
I’m using tx2 with Jetpack 4.2

You may not include the include/linux/i2c.h


Thank you for your reply ShaneCCC.
I include

extern "C"{
#include <i2c/smbus.h>
#include <linux/i2c.h>

both but still have same error.
I think this article is different case but similar so I’m trying to include the i2c library.
but there is no such a file which i can include because using Qt creater.
I need some help.

Does below post didn’t help?


I really appreciated for your help but It didn’t work.
Or Can I add that -li2c library on Qt creator?