Title: ESP-IDF Not Compiling Source File
Tags: c++;compilation;linker;esp32;esp-idf
Question: I am starting on a project for an ESP32-S3 and I'm having trouble getting my code to complete linking, and I think it is because my LinkedList.cpp source file is not being compiled for some reason.
Here is the output from building:
[truncated for post size limit]
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/megag/Documents/ESP32_Test/test/tusb_serial_device/build
[10/1078] Generating ../../partition_table/partition-table.bin
Partition table binary generated. Contents:
*******************************************************************************
# ESP-IDF Partition Table
# Name, Type, SubType, Offset, Size, Flags
nvs,data,nvs,0x9000,24K,
phy_init,data,phy,0xf000,4K,
factory,app,factory,0x10000,1M,
*******************************************************************************
[677/1078] Performing configure step for 'bootloader'
-- Found Git: C:/Program Files/Git/cmd/git.exe (found version &quot;2.35.0.windows.1&quot;)
-- The C compiler identification is GNU 8.4.0
-- The CXX compiler identification is GNU 8.4.0
-- The ASM compiler identification is GNU
-- Found assembler: C:/Users/megag/.espressif/tools/xtensa-esp32s3-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32s3-elf/bin/xtensa-esp32s3-elf-gcc.exe
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Users/megag/.espressif/tools/xtensa-esp32s3-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32s3-elf/bin/xtensa-esp32s3-elf-gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Users/megag/.espressif/tools/xtensa-esp32s3-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32s3-elf/bin/xtensa-esp32s3-elf-g++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Building ESP-IDF components for target esp32s3
-- Project sdkconfig file C:/Users/megag/Documents/ESP32_Test/test/tusb_serial_device/sdkconfig
-- Adding linker script C:/Users/megag/esp/esp-idf/components/soc/esp32s3/ld/esp32s3.peripherals.ld
-- Adding linker script C:/Users/megag/esp/esp-idf/components/esp_rom/esp32s3/ld/esp32s3.rom.ld
-- Adding linker script C:/Users/megag/esp/esp-idf/components/esp_rom/esp32s3/ld/esp32s3.rom.api.ld
-- Adding linker script C:/Users/megag/esp/esp-idf/components/esp_rom/esp32s3/ld/esp32s3.rom.libgcc.ld
-- Adding linker script C:/Users/megag/esp/esp-idf/components/esp_rom/esp32s3/ld/esp32s3.rom.newlib.ld
-- Adding linker script C:/Users/megag/esp/esp-idf/components/bootloader/subproject/main/ld/esp32s3/bootloader.ld
-- Adding linker script C:/Users/megag/esp/esp-idf/components/bootloader/subproject/main/ld/esp32s3/bootloader.rom.ld
-- Components: bootloader bootloader_support efuse esp32s3 esp_common esp_hw_support esp_rom esp_system esptool_py freertos hal log main micro-ecc newlib partition_table soc spi_flash xtensa
-- Component paths: C:/Users/megag/esp/esp-idf/components/bootloader C:/Users/megag/esp/esp-idf/components/bootloader_support C:/Users/megag/esp/esp-idf/components/efuse C:/Users/megag/esp/esp-idf/components/esp32s3 C:/Users/megag/esp/esp-idf/components/esp_common C:/Users/megag/esp/esp-idf/components/esp_hw_support C:/Users/megag/esp/esp-idf/components/esp_rom C:/Users/megag/esp/esp-idf/components/esp_system C:/Users/megag/esp/esp-idf/components/esptool_py C:/Users/megag/esp/esp-idf/components/freertos C:/Users/megag/esp/esp-idf/components/hal C:/Users/megag/esp/esp-idf/components/log C:/Users/megag/esp/esp-idf/components/bootloader/subproject/main C:/Users/megag/esp/esp-idf/components/bootloader/subproject/components/micro-ecc C:/Users/megag/esp/esp-idf/components/newlib C:/Users/megag/esp/esp-idf/components/partition_table C:/Users/megag/esp/esp-idf/components/soc C:/Users/megag/esp/esp-idf/components/spi_flash C:/Users/megag/esp/esp-idf/components/xtensa
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/megag/Documents/ESP32_Test/test/tusb_serial_device/build/bootloader
[826/1078] Performing build step for 'bootloader'
[1/101] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32s3/gdma_periph.c.obj
[2/101] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32s3/dedic_gpio_periph.c.obj
[3/101] Generating project_elf_src_esp32s3.c
[4/101] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/soc_include_legacy_warn.c.obj
[5/101] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/lldesc.c.obj
[6/101] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32s3/lcd_periph.c.obj
[7/101] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32s3/adc_periph.c.obj
[8/101] Building C object esp-idf/hal/CMakeFiles/__idf_hal.dir/mpu_hal.c.obj
[9/101] Building C object esp-idf/hal/CMakeFiles/__idf_hal.dir/cpu_hal.c.obj
[10/101] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32s3/interrupts.c.obj
[11/101] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32s3/rmt_periph.c.obj
[12/101] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32s3/ledc_periph.c.obj
[13/101] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32s3/i2s_periph.c.obj
[14/101] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32s3/gpio_periph.c.obj
[15/101] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32s3/i2c_periph.c.obj
[16/101] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32s3/rtc_io_periph.c.obj
[17/101] Building C object esp-idf/hal/CMakeFiles/__idf_hal.dir/wdt_hal_iram.c.obj
[18/101] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32s3/pcnt_periph.c.obj
[19/101] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32s3/mcpwm_periph.c.obj
[20/101] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32s3/sdmmc_periph.c.obj
[21/101] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32s3/sigmadelta_periph.c.obj
[22/101] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32s3/usb_phy_periph.c.obj
[23/101] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32s3/timer_periph.c.obj
[24/101] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32s3/sdio_slave_periph.c.obj
[25/101] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32s3/touch_sensor_periph.c.obj
[26/101] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32s3/uart_periph.c.obj
[27/101] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32s3/usb_periph.c.obj
[28/101] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32s3/spi_periph.c.obj
[29/101] Building C object esp-idf/spi_flash/CMakeFiles/__idf_spi_flash.dir/esp32s3/spi_flash_rom_patch.c.obj
[30/101] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_clock_init.c.obj
[31/101] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_random_esp32s3.c.obj
[32/101] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_mem.c.obj
[33/101] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_random.c.obj
[34/101] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_efuse_esp32s3.c.obj
[35/101] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/flash_encrypt.c.obj
[36/101] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_clock_loader.c.obj
[37/101] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/secure_boot.c.obj
[38/101] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_flash_config_esp32s3.c.obj
[39/101] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_flash.c.obj
[40/101] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_common.c.obj
[41/101] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_common_loader.c.obj
[42/101] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/flash_qio_mode.c.obj
[43/101] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/flash_partitions.c.obj
[44/101] Building C object esp-idf/efuse/CMakeFiles/__idf_efuse.dir/esp32s3/esp_efuse_fields.c.obj
[45/101] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_console_loader.c.obj
[46/101] Building C object esp-idf/efuse/CMakeFiles/__idf_efuse.dir/esp32s3/esp_efuse_utility.c.obj
[47/101] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_init.c.obj
[48/101] Building C object esp-idf/efuse/CMakeFiles/__idf_efuse.dir/esp32s3/esp_efuse_table.c.obj
[49/101] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/esp32s3/bootloader_soc.c.obj
[50/101] Building C object esp-idf/efuse/CMakeFiles/__idf_efuse.dir/esp32s3/esp_efuse_rtc_calib.c.obj
[51/101] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/esp_image_format.c.obj
[52/101] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/esp32s3/bootloader_sha.c.obj
[53/101] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_panic.c.obj
[54/101] Building C object esp-idf/esp_system/CMakeFiles/__idf_esp_system.dir/esp_err.c.obj
[55/101] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_console.c.obj
[56/101] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_utility.c.obj
[57/101] Building C object esp-idf/esp_hw_support/CMakeFiles/__idf_esp_hw_support.dir/port/esp32s3/rtc_clk_init.c.obj
[58/101] Building C object esp-idf/esp_hw_support/CMakeFiles/__idf_esp_hw_support.dir/compare_set.c.obj
[59/101] Building C object esp-idf/efuse/CMakeFiles/__idf_efuse.dir/src/esp_efuse_fields.c.obj
[60/101] Building C object esp-idf/efuse/CMakeFiles/__idf_efuse.dir/src/esp_efuse_api.c.obj
[61/101] Building C object esp-idf/micro-ecc/CMakeFiles/__idf_micro-ecc.dir/uECC_verify_antifault.c.obj
[62/101] Building C object esp-idf/esp_hw_support/CMakeFiles/__idf_esp_hw_support.dir/port/esp32s3/rtc_wdt.c.obj
[63/101] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/esp32s3/bootloader_esp32s3.c.obj
[64/101] Building C object esp-idf/esp_hw_support/CMakeFiles/__idf_esp_hw_support.dir/port/esp32s3/rtc_pm.c.obj
[65/101] Building C object esp-idf/esp_hw_support/CMakeFiles/__idf_esp_hw_support.dir/cpu_util.c.obj
[66/101] Building C object esp-idf/efuse/CMakeFiles/__idf_efuse.dir/src/esp_efuse_api_key_esp32xx.c.obj
[67/101] Building C object esp-idf/xtensa/CMakeFiles/__idf_xtensa.dir/eri.c.obj
[68/101] Building C object esp-idf/efuse/CMakeFiles/__idf_efuse.dir/src/esp_efuse_utility.c.obj
[69/101] Building C object esp-idf/esp_hw_support/CMakeFiles/__idf_esp_hw_support.dir/port/esp32s3/rtc_sleep.c.obj
[70/101] Building C object esp-idf/esp_hw_support/CMakeFiles/__idf_esp_hw_support.dir/port/esp32s3/chip_info.c.obj
[71/101] Building C object esp-idf/esp_hw_support/CMakeFiles/__idf_esp_hw_support.dir/port/esp32s3/rtc_time.c.obj
[72/101] Building C object esp-idf/esp_hw_support/CMakeFiles/__idf_esp_hw_support.dir/port/esp32s3/rtc_clk.c.obj
[73/101] Building C object esp-idf/xtensa/CMakeFiles/__idf_xtensa.dir/xt_trax.c.obj
[74/101] Building C object esp-idf/esp_common/CMakeFiles/__idf_esp_common.dir/src/esp_err_to_name.c.obj
[75/101] Building C object esp-idf/main/CMakeFiles/__idf_main.dir/bootloader_start.c.obj
[76/101] Building ASM object esp-idf/esp_rom/CMakeFiles/__idf_esp_rom.dir/patches/esp_rom_longjmp.S.obj
[77/101] Building C object esp-idf/esp_hw_support/CMakeFiles/__idf_esp_hw_support.dir/port/esp32s3/rtc_init.c.obj
[78/101] Building C object esp-idf/esp_rom/CMakeFiles/__idf_esp_rom.dir/patches/esp_rom_sys.c.obj
[79/101] Building C object esp-idf/esp_rom/CMakeFiles/__idf_esp_rom.dir/patches/esp_rom_tjpgd.c.obj
[80/101] Building C object esp-idf/esp_rom/CMakeFiles/__idf_esp_rom.dir/patches/esp_rom_uart.c.obj
[81/101] Building C object CMakeFiles/bootloader.elf.dir/project_elf_src_esp32s3.c.obj
[82/101] Building C object esp-idf/esp_rom/CMakeFiles/__idf_esp_rom.dir/patches/esp_rom_crc.c.obj
[83/101] Building C object esp-idf/log/CMakeFiles/__idf_log.dir/log.c.obj
[84/101] Building C object esp-idf/log/CMakeFiles/__idf_log.dir/log_buffers.c.obj
[85/101] Building C object esp-idf/log/CMakeFiles/__idf_log.dir/log_noos.c.obj
[86/101] Linking C static library esp-idf\log\liblog.a
[87/101] Linking C static library esp-idf\esp_rom\libesp_rom.a
[88/101] Linking C static library esp-idf\esp_common\libesp_common.a
[89/101] Linking C static library esp-idf\xtensa\libxtensa.a
[90/101] Linking C static library esp-idf\esp_hw_support\libesp_hw_support.a
[91/101] Linking C static library esp-idf\esp_system\libesp_system.a
[92/101] Linking C static library esp-idf\efuse\libefuse.a
[93/101] Linking C static library esp-idf\bootloader_support\libbootloader_support.a
[94/101] Linking C static library esp-idf\spi_flash\libspi_flash.a
[95/101] Linking C static library esp-idf\micro-ecc\libmicro-ecc.a
[96/101] Linking C static library esp-idf\soc\libsoc.a
[97/101] Linking C static library esp-idf\hal\libhal.a
[98/101] Linking C static library esp-idf\main\libmain.a
[99/101] Linking C executable bootloader.elf
[100/101] Generating binary image from built executable
esptool.py v3.3-dev
Creating esp32s3 image...
Merged 1 ELF section
Successfully created esp32s3 image.
Generated C:/Users/megag/Documents/ESP32_Test/test/tusb_serial_device/build/bootloader/bootloader.bin
[101/101] cmd.exe /C &quot;cd /D C:\Users\megag\Documents\ESP32_Test\test\tusb_serial_device\build\bootloader\esp-idf\esptool_py &amp;&amp; C:\Users\megag\.espressif\python_env\idf4.4_py3.8_env\Scripts\python.exe C:/Users/megag/esp/esp-idf/components/partition_table/check_sizes.py --offset 0x8000 bootloader 0x0 C:/Users/megag/Documents/ESP32_Test/test/tusb_serial_device/build/bootloader/bootloader.bin&quot;
Bootloader binary size 0x5190 bytes. 0x2e70 bytes (36%) free.
[1076/1078] Linking CXX executable tusb_serial_device.elf
FAILED: tusb_serial_device.elf
cmd.exe /C &quot;cd . &amp;&amp; C:\Users\megag\.espressif\tools\xtensa-esp32s3-elf\esp-2021r2-patch3-8.4.0\xtensa-esp32s3-elf\bin\xtensa-esp32s3-elf-g++.exe -mlongcalls  @CMakeFiles\tusb_serial_device.elf.rsp -o tusb_serial_device.elf  &amp;&amp; cd .&quot;
c:/users/megag/.espressif/tools/xtensa-esp32s3-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: esp-idf/main/libmain.a(tusb_serial_device_main.cpp.obj):(.literal.app_main+0x40): undefined reference to `LinkedList<int&gt;75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0LinkedList()'
c:/users/megag/.espressif/tools/xtensa-esp32s3-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: esp-idf/main/libmain.a(tusb_serial_device_main.cpp.obj):(.literal.app_main+0x44): undefined reference to `LinkedList<int&gt;75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0(int)'
c:/users/megag/.espressif/tools/xtensa-esp32s3-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: esp-idf/main/libmain.a(tusb_serial_device_main.cpp.obj):(.literal.app_main+0x48): undefined reference to `LinkedList<int&gt;75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0Remove(int)'
c:/users/megag/.espressif/tools/xtensa-esp32s3-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: esp-idf/main/libmain.a(tusb_serial_device_main.cpp.obj):(.literal.app_main+0x4c): undefined reference to `LinkedList<int&gt;75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0ToString(char*)'
c:/users/megag/.espressif/tools/xtensa-esp32s3-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: esp-idf/main/libmain.a(tusb_serial_device_main.cpp.obj): in function `app_main':
C:\Users\megag\Documents\ESP32_Test\test\tusb_serial_device\build/../main/tusb_serial_device_main.cpp:102: undefined reference to `LinkedList<int&gt;75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0LinkedList()'
c:/users/megag/.espressif/tools/xtensa-esp32s3-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\megag\Documents\ESP32_Test\test\tusb_serial_device\build/../main/tusb_serial_device_main.cpp:102: undefined reference to `LinkedList<int&gt;75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0(int)'
c:/users/megag/.espressif/tools/xtensa-esp32s3-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\megag\Documents\ESP32_Test\test\tusb_serial_device\build/../main/tusb_serial_device_main.cpp:103: undefined reference to `LinkedList<int&gt;75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0(int)'
c:/users/megag/.espressif/tools/xtensa-esp32s3-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\megag\Documents\ESP32_Test\test\tusb_serial_device\build/../main/tusb_serial_device_main.cpp:104: undefined reference to `LinkedList<int&gt;75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0(int)'
c:/users/megag/.espressif/tools/xtensa-esp32s3-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\megag\Documents\ESP32_Test\test\tusb_serial_device\build/../main/tusb_serial_device_main.cpp:105: undefined reference to `LinkedList<int&gt;75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0(int)'
c:/users/megag/.espressif/tools/xtensa-esp32s3-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\megag\Documents\ESP32_Test\test\tusb_serial_device\build/../main/tusb_serial_device_main.cpp:106: undefined reference to `LinkedList<int&gt;75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0(int)'
c:/users/megag/.espressif/tools/xtensa-esp32s3-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\megag\Documents\ESP32_Test\test\tusb_serial_device\build/../main/tusb_serial_device_main.cpp:107: undefined reference to `LinkedList<int&gt;75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0Remove(int)'
c:/users/megag/.espressif/tools/xtensa-esp32s3-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\megag\Documents\ESP32_Test\test\tusb_serial_device\build/../main/tusb_serial_device_main.cpp:108: undefined reference to `LinkedList<int&gt;75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0Remove(int)'
c:/users/megag/.espressif/tools/xtensa-esp32s3-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\megag\Documents\ESP32_Test\test\tusb_serial_device\build/../main/tusb_serial_device_main.cpp:109: undefined reference to `LinkedList<int&gt;75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0Remove(int)'
c:/users/megag/.espressif/tools/xtensa-esp32s3-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\megag\Documents\ESP32_Test\test\tusb_serial_device\build/../main/tusb_serial_device_main.cpp:115: undefined reference to `LinkedList<int&gt;75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0ToString(char*)'
c:/users/megag/.espressif/tools/xtensa-esp32s3-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: esp-idf/main/libmain.a(CommandLine.cpp.obj):(.literal._ZN7Command13AddSubcommandES_+0x0): undefined reference to `LinkedList<Command&gt;75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0(Command)'
c:/users/megag/.espressif/tools/xtensa-esp32s3-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: esp-idf/main/libmain.a(CommandLine.cpp.obj):(.literal._ZN11CommandLineC2Ev+0x0): undefined reference to `LinkedList<Command&gt;75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0LinkedList()'
c:/users/megag/.espressif/tools/xtensa-esp32s3-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: esp-idf/main/libmain.a(CommandLine.cpp.obj):(.literal._ZN11CommandLine9PrintTreeEPc+0x4): undefined reference to `LinkedList<Command&gt;75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0ount()'
c:/users/megag/.espressif/tools/xtensa-esp32s3-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: esp-idf/main/libmain.a(CommandLine.cpp.obj):(.literal._ZN11CommandLine9PrintTreeEPc+0x8): undefined reference to `LinkedList<Command&gt;75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0tIndex(int)'
c:/users/megag/.espressif/tools/xtensa-esp32s3-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: esp-idf/main/libmain.a(CommandLine.cpp.obj): in function `Comman75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0AddSubcommand(Command)':
C:\Users\megag\Documents\ESP32_Test\test\tusb_serial_device\build/../main/CommandLine.cpp:17: undefined reference to `LinkedList<Command&gt;75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0(Command)'
c:/users/megag/.espressif/tools/xtensa-esp32s3-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: esp-idf/main/libmain.a(CommandLine.cpp.obj): in function `CommandLin75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0CommandLine()':
C:\Users\megag\Documents\ESP32_Test\test\tusb_serial_device\build/../main/CommandLine.cpp:34: undefined reference to `LinkedList<Command&gt;75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0LinkedList()'
c:/users/megag/.espressif/tools/xtensa-esp32s3-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: esp-idf/main/libmain.a(CommandLine.cpp.obj): in function `CommandLin75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0AddCommand(Command)':
C:\Users\megag\Documents\ESP32_Test\test\tusb_serial_device\build/../main/CommandLine.cpp:39: undefined reference to `LinkedList<Command&gt;75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0(Command)'
c:/users/megag/.espressif/tools/xtensa-esp32s3-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: esp-idf/main/libmain.a(CommandLine.cpp.obj): in function `CommandLin75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0PrintTree(char*)':
C:\Users\megag\Documents\ESP32_Test\test\tusb_serial_device\build/../main/CommandLine.cpp:53: undefined reference to `LinkedList<Command&gt;75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0ount()'
c:/users/megag/.espressif/tools/xtensa-esp32s3-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32s3-elf/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\megag\Documents\ESP32_Test\test\tusb_serial_device\build/../main/CommandLine.cpp:54: undefined reference to `LinkedList<Command&gt;75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0tIndex(int)'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
*  The terminal process &quot;C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command ninja &quot; terminated with exit code: 1.
This is my project structure:
tusb_serial_device_main.cpp:
#include <stdint.h&gt;
#include <string.h&gt;
#include &quot;esp_log.h&quot;
#include &quot;freertos/FreeRTOS.h&quot;
#include &quot;freertos/task.h&quot;
#include &quot;tinyusb.h&quot;
#include &quot;tusb_cdc_acm.h&quot;
#include &quot;sdkconfig.h&quot;
#include &quot;LinkedList.hpp&quot;
#include &quot;CommandLine.hpp&quot;
#include &quot;Utils.hpp&quot;
static const char *TAG = &quot;example&quot;;
static uint8_t buf[CONFIG_TINYUSB_CDC_RX_BUFSIZE + 1];
void tinyusb_cdc_rx_callback(int itf, cdcacm_event_t *event)
/* initialization */
size_t rx_size = 0;
/* read */
esp_err_t ret = tinyusb_cdcacm_read((tinyusb_cdcacm_itf_t)itf, buf, CONFIG_TINYUSB_CDC_RX_BUFSIZE, &amp;rx_size);
if (ret == ESP_OK) {
buf[rx_size] = '\0';
ESP_LOGI(TAG, &quot;Got data (%d bytes): %s&quot;, rx_size, buf);
} else {
ESP_LOGE(TAG, &quot;Read error&quot;);
/* write back */
tinyusb_cdcacm_write_queue((tinyusb_cdcacm_itf_t)itf, buf, rx_size);
tinyusb_cdcacm_write_flush((tinyusb_cdcacm_itf_t)itf, 0);
void tinyusb_cdc_line_state_changed_callback(int itf, cdcacm_event_t *event)
int dtr = event-&gt;line_state_changed_data.dtr;
int rst = event-&gt;line_state_changed_data.rts;
ESP_LOGI(TAG, &quot;Line state changed! dtr:%d, rst:%d&quot;, dtr, rst);
int light_on(int numargs, ...){
Utils75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0serputs(&quot;\n\rlight turned on&quot;);
return true;
int light_off(int numargs, ...){
Utils75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0serputs(&quot;\n\rlight turned off&quot;);
return true;
extern &quot;C&quot; { void app_main(); }
void app_main()
ESP_LOGI(TAG, &quot;USB initialization&quot;);
tinyusb_config_t tusb_cfg = {}; // the configuration using default values
ESP_ERROR_CHECK(tinyusb_driver_install(&amp;tusb_cfg));
tinyusb_config_cdcacm_t amc_cfg = {
.usb_dev = TINYUSB_USBDEV_0,
.cdc_port = TINYUSB_CDC_ACM_0,
.rx_unread_buf_sz = 64,
.callback_rx = &amp;tinyusb_cdc_rx_callback, // the first way to register a callback
.callback_rx_wanted_char = NULL,
.callback_line_state_changed = NULL,
.callback_line_coding_changed = NULL,
};
ESP_ERROR_CHECK(tusb_cdc_acm_init(&amp;amc_cfg));
/* the second way to register a callback */
ESP_ERROR_CHECK(tinyusb_cdcacm_register_callback(
TINYUSB_CDC_ACM_0,
CDC_EVENT_LINE_STATE_CHANGED,
&amp;tinyusb_cdc_line_state_changed_callback));
ESP_LOGI(TAG, &quot;USB initialization DONE&quot;);
LinkedList<int&gt;* LL = new LinkedList<int&gt;();
LL-&gt;Add(1);
LL-&gt;Add(2);
LL-&gt;Add(3);
LL-&gt;Add(4);
LL-&gt;Add(5);
LL-&gt;Remove(1);
LL-&gt;Remove(3);
LL-&gt;Remove(5);
CommandLine cmdLine;
Command *lightCommand = new Command(&quot;light&quot;);
lightCommand-&gt;AddSubcommand(*(new Command(&quot;on&quot;, light_on)));
lightCommand-&gt;AddSubcommand(*(new Command(&quot;off&quot;, light_off)));
cmdLine.AddCommand(*lightCommand);
while(true){
char buf[240];
Utils75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0serputs(cmdLine.PrintTree(buf));
Utils75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0serputs(LL-&gt;ToString(buf));
Utils75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0serputs(&quot;\n\r&quot;);
LinkedList.cpp
#include &quot;LinkedList.hpp&quot;
#include <string.h&gt;
template <typename T&gt;
LinkedListNode<T&gt;75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0LinkedListNode()
this-&gt;Value = NULL;
this-&gt;Next = NULL;
template <typename T&gt;
LinkedListNode<T&gt;75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0LinkedListNode(T value)
this-&gt;Value = &amp;value;
this-&gt;Next = NULL;
template <typename T&gt;
LinkedList<T&gt;75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0LinkedList()
root = NULL;
count = 0;
template <typename T&gt;
void LinkedList<T&gt;75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0(T item)
LinkedListNode<T&gt;* newNode = new LinkedListNode<T&gt;(item);
if(root == NULL){
root = newNode;
return;
LinkedListNode<T&gt; *temp = root;
while(temp-&gt;Next != NULL){
temp = temp-&gt;Next;
temp-&gt;Next = newNode;
template <typename T&gt;
bool LinkedList<T&gt;75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0Remove(T item)
LinkedListNode<T&gt;* prevNode = NULL;
LinkedListNode<T&gt;* currNode = root;
while (currNode != NULL)
if (*(currNode-&gt;Value) == item)
{
if (prevNode == NULL)
{
root = currNode-&gt;Next;
}
else
{
prevNode-&gt;Next = currNode-&gt;Next;
}
return true;
}
prevNode = currNode;
currNode = currNode-&gt;Next;
return false;
template <typename T&gt;
T LinkedList<T&gt;75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0tIndex(int i){
LinkedListNode<T&gt; *currNode = root;
for(int idx = 0; idx < i; idx++){
currNode = currNode-&gt;Next;
return *(currNode-&gt;Value);
template <typename T&gt;
char* LinkedList<T&gt;75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0ToString(char* buf)
char tempbuf[16];
strcpy(buf, &quot;[&quot;);
LinkedListNode<T&gt; *currNode = root;
while (currNode != NULL)
strcat(buf, itoa(*(currNode-&gt;Value), tempbuf, 10));
strcat(buf, &quot;-&gt;&quot;);
currNode = currNode-&gt;Next;
strcat(buf,&quot;]&quot;);
return buf;
template <typename T&gt;
int LinkedList<T&gt;75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0ount(){
return count;
LinkedList.hpp:
/* TODO: Copyright
* Author: Alexander Charters
* Date: 8/6/2022
#ifndef LINKEDLIST_H
#define LINKEDLIST_H
template <typename T&gt;
class LinkedListNode
public:
LinkedListNode();
LinkedListNode(T Value);
T *Value;
LinkedListNode *Next;
template <typename T&gt;
class LinkedList
public:
LinkedList();
void Add(T item);
bool Remove(T item);
T AtIndex(int i);
int Count();
char *ToString(char *buf);
LinkedListNode<T&gt; *root;
LinkedListNode<T&gt; *tail;
private:
int count;
#endif
Here is the CMakeLists.txt for the main component:
idf_component_register(SRCS &quot;LinkedList.cpp&quot; &quot;CommandLine.cpp&quot; &quot;tusb_serial_device_main.cpp&quot;
INCLUDE_DIRS .)
I've read through The Build System Page, but still couldn't figure it out. I'm not having any issue with the the CommandLine files, even thoough there doesn't seem to be any significant difference in how I've implemented them and the LinkedList files, as far as I can tell.


Here is another answer: I might be a little out of date on this topic, but last time I checked you had to put all your template code in the header file. The declarations, definitions, everything. Couldn't have anything in the .cpp file.
https://isocpp.org/wiki/faq/templates#templates-defn-vs-decl

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2022:00:08/29/22', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<c++><compilation><linker><esp32><esp-idf>', 'Title': 'ESP-IDF Not Compiling Source File', 'ViewCount': 66, 'id': 73523376, 'user_AboutMe': '<p>Computer Engineering student at the University of Utah. I do everything from web design to hobby electronics to programming. Aside from the brainy activities, I enjoy freerunning, parkour, and skiing.</p>\n', 'user_AccountId': 12520858.0, 'user_DisplayName': 'Alex Charters', 'user_Reputation': 301.0, 'user_Views': 22.0, 'user_id': 9368476.0}}