Hello,
I have an eclipse project based off of the i2c_test example in idf 4.3. I have added two components, init.c and h, and MCP23008.c and h.
I have init code in init.c and the prototype in init.h. I call these init functions in main.c where I have included the init.h file.
In MCP23008.c I have the routine i2c_master_init() defined and prototyped in MCP23008.h. I've included MCP23008.h in main.c where I
am calling i2c_master_init(). When I build I get 3 errors that say "undefined reference to `i2c_master_init'". It seems to be
working in the init components but for some reason I can't get it to recognize the MCP23008.h file included in main.
Any suggestions would be very much appreciated. main, init, and MCP23008 .c and .h files are attached.
I zipped up the 5 files as I was not able to post more than 3. The console output is shown below.
Thank you
Building in: C:\Workspace\Eclipse\datalogger100\build
cmake --build . -- -v
[1/5] cmd.exe /C "cd /D C:\Workspace\Eclipse\datalogger100\build\bootloader && C:\Users\barry\.espressif\tools\cmake\3.16.4\bin\cmake.exe --build ."
ninja: no work to do.
[2/3] cmd.exe /C "cd . && C:\Users\barry\.espressif\tools\xtensa-esp32-elf\esp-2020r3-8.4.0\xtensa-esp32-elf\bin\xtensa-esp32-elf-g++.exe -mlongcalls -Wno-frame-address @CMakeFiles\app-template.elf.rsp -o app-template.elf && cd ."
FAILED: app-template.elf
cmd.exe /C "cd . && C:\Users\barry\.espressif\tools\xtensa-esp32-elf\esp-2020r3-8.4.0\xtensa-esp32-elf\bin\xtensa-esp32-elf-g++.exe -mlongcalls -Wno-frame-address @CMakeFiles\app-template.elf.rsp -o app-template.elf && cd ."
c:/users/barry/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: esp-idf/main/libmain.a(main.c.obj):(.literal.app_main+0xc): undefined reference to `i2c_master_init'
c:/users/barry/.espressif/tools/xtensa-esp32-elf/esp-2020r3-8.4.0/xtensa-esp32-elf/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: esp-idf/main/libmain.a(main.c.obj): in function `app_main':
C:\Workspace\Eclipse\datalogger100\build/../main/main.c:22: undefined reference to `i2c_master_init'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
Build complete (3 errors, 0 warnings): C:\Workspace\Eclipse\datalogger100\build
Total time taken to build the project: 937 ms
i2c build issue in using multiple files
Re: i2c build issue in using multiple files
The zip file did not get attached to the original post. Thanks
- Attachments
-
- i2c.zip
- (3 KiB) Downloaded 260 times
Re: i2c build issue in using multiple files
Hello,
I removed the static declaration and it builds fine. Not sure why but didn't want anyone to waste time on an issue that I've solved. In MCP23008.c and h, just remove the declaration "static" and it should build fine.
Thanks
I removed the static declaration and it builds fine. Not sure why but didn't want anyone to waste time on an issue that I've solved. In MCP23008.c and h, just remove the declaration "static" and it should build fine.
Thanks
Who is online
Users browsing this forum: No registered users and 122 guests