I am able to compile the code but when it is linking-time something does not work as expected.
I investigated a bit, and the problem is that the objects files used by the linker are 'empty'.
Likely, the build process is considering only the headers file and nothing else, but I have not idea how to fix it.
To replicate the problem just do as follow:
You can verify that into the build folder some of the object files produced actually are "empty". Thus, the linker does not find the required symbols and fails.
For example, it it look at the cdc_device.c.obj used:
It is just 704 bytes instead of 7184
The file has no symbols:
It should be:
Of course, I can get the final binary by replacing the content of the build folder with the correctly compiled version from another project. In this case, I have to start the linker manually. Fortunately, it is possible to get the command line to be used from the output of `make -j4 --trace`
How can I fix the CMakeFiles.txt file to avoid the empty files?
I investigated a bit, and the problem is that the objects files used by the linker are 'empty'.
Likely, the build process is considering only the headers file and nothing else, but I have not idea how to fix it.
To replicate the problem just do as follow:
Code:
pi@raspberrypi:~/pico $ git clone git@github.com:ozw1z5rd/PicoMite.git -b hcg20-WIFI PicoMiteHCG20-WIFI Cloning into 'PicoMiteHCG20-WIFI'...remote: Enumerating objects: 3480, done.remote: Counting objects: 100% (217/217), done.remote: Compressing objects: 100% (153/153), done.remote: Total 3480 (delta 121), reused 130 (delta 64), pack-reused 3263 (from 1)Receiving objects: 100% (3480/3480), 8.19 MiB | 976.00 KiB/s, done.Resolving deltas: 100% (2235/2235), done.pi@raspberrypi:~/pico $ cd PicoMiteHCG20-WIFI/pi@raspberrypi:~/pico/PicoMiteHCG20-WIFI $ git branch * hcg20-WIFIpi@raspberrypi:~/pico/PicoMiteHCG20-WIFI $ mkdir build pi@raspberrypi:~/pico/PicoMiteHCG20-WIFI $ cd build/ pi@raspberrypi:~/pico/PicoMiteHCG20-WIFI/build $ cmake .. pi@raspberrypi:~/pico/PicoMiteHCG20-WIFI/build $ make -j4 Scanning dependencies of target bs2_default:100%] Linking CXX executable PicoMiteWeb.elf/usr/lib/gcc/arm-none-eabi/8.3.1/../../../arm-none-eabi/bin/ld: CMakeFiles/PicoMiteWeb.dir/PicoMite.c.obj: in function `routinechecks':PicoMite.c:(.time_critical.routinechecks+0x4c): undefined reference to `tud_cdc_n_connected'/usr/lib/gcc/arm-none-eabi/8.3.1/../../../arm-none-eabi/bin/ld: PicoMite.c:(.time_critical.routinechecks+0x8e): undefined reference to `tud_cdc_n_read'/usr/lib/gcc/arm-none-eabi/8.3.1/../../../arm-none-eabi/bin/ld: CMakeFiles/PicoMiteWeb.dir/PicoMite.c.obj: in function `SerialConsolePutC':PicoMite.c:(.text.SerialConsolePutC+0xd6): undefined reference to `tud_cdc_n_connected'/usr/lib/gcc/arm-none-eabi/8.3.1/../../../arm-none-eabi/bin/ld: CMakeFiles/PicoMiteWeb.dir/PicoMite.c.obj: in function `main':PicoMite.c:(.text.startup.main+0x350): undefined reference to `tud_cdc_n_connected'/usr/lib/gcc/arm-none-eabi/8.3.1/../../../arm-none-eabi/bin/ld: PicoMite.c:(.text.startup.main+0x3bc): undefined reference to `stdio_usb'collect2: error: ld returned 1 exit statusmake[2]: *** [CMakeFiles/PicoMiteWeb.dir/build.make:3331: PicoMiteWeb.elf] Error 1make[1]: *** [CMakeFiles/Makefile2:1913: CMakeFiles/PicoMiteWeb.dir/all] Error 2make: *** [Makefile:103: all] Error 2
For example, it it look at the cdc_device.c.obj used:
Code:
pi@raspberrypi:~/pico/PicoMiteHCG20-WIFI/build $ ls -l CMakeFiles/PicoMiteWeb.dir/home/pi/pico/pico-sdk/lib/tinyusb/src/class/cdc total 4-rw-r--r-- 1 pi pi 740 Aug 18 18:34 cdc_device.c.obj
The file has no symbols:
Code:
pi@raspberrypi:~/pico/PicoMiteHCG20-WIFI/build $ objdump -t CMakeFiles/PicoMiteWeb.dir/home/pi/pico/pico-sdk/lib/tinyusb/src/class/cdc/cdc_device.c.obj CMakeFiles/PicoMiteWeb.dir/home/pi/pico/pico-sdk/lib/tinyusb/src/class/cdc/cdc_device.c.obj: file format elf32-littlearmSYMBOL TABLE:00000000 l df *ABS*00000000 cdc_device.c00000000 l d .text00000000 .text00000000 l d .data00000000 .data00000000 l d .bss00000000 .bss00000000 l d .comment00000000 .comment00000000 l d .ARM.attributes00000000 .ARM.attributes
Code:
cdc_device.c.obj: file format elf32-littlearmSYMBOL TABLE:00000000 l df *ABS*00000000 cdc_device.c00000000 l d .text00000000 .text00000000 l d .data00000000 .data00000000 l d .bss00000000 .bss00000000 l d .text._prep_out_transaction00000000 .text._prep_out_transaction00000000 l F .text._prep_out_transaction00000048 _prep_out_transaction00000000 l d .text.tud_cdc_n_connected00000000 .text.tud_cdc_n_connected00000000 l O .bss._cdcd_itf000002c8 _cdcd_itf00000000 l d .text.tud_cdc_n_get_line_state00000000 .text.tud_cdc_n_get_line_state00000000 l d .text.tud_cdc_n_get_line_coding00000000 .text.tud_cdc_n_get_line_coding00000000 l d .text.tud_cdc_n_set_wanted_char00000000 .text.tud_cdc_n_set_wanted_char00000000 l d .text.tud_cdc_n_available00000000 .text.tud_cdc_n_available00000000 l d .text.tud_cdc_n_read00000000 .text.tud_cdc_n_read00000000 l d .text.tud_cdc_n_peek00000000 .text.tud_cdc_n_peek00000000 l d .text.tud_cdc_n_read_flush00000000 .text.tud_cdc_n_read_flush00000000 l d .text.tud_cdc_n_write_flush00000000 .text.tud_cdc_n_write_flush00000000 l d .text.tud_cdc_n_write00000000 .text.tud_cdc_n_write00000000 l d .text.tud_cdc_n_write_available00000000 .text.tud_cdc_n_write_available00000000 l d .text.tud_cdc_n_write_clear00000000 .text.tud_cdc_n_write_clear00000000 l d .text.cdcd_init00000000 .text.cdcd_init00000000 l d .text.cdcd_reset00000000 .text.cdcd_reset00000000 l d .text.cdcd_open00000000 .text.cdcd_open00000000 l d .text.cdcd_control_xfer_cb00000000 .text.cdcd_control_xfer_cb00000000 l d .text.cdcd_xfer_cb00000000 .text.cdcd_xfer_cb00000000 l d .bss._cdcd_itf00000000 .bss._cdcd_itf00000000 l d .comment00000000 .comment00000000 l d .ARM.attributes00000000 .ARM.attributes00000000 *UND*00000000 tu_fifo_remaining00000000 *UND*00000000 usbd_edpt_claim00000000 *UND*00000000 usbd_edpt_xfer00000000 *UND*00000000 usbd_edpt_release00000000 g F .text.tud_cdc_n_connected00000030 tud_cdc_n_connected00000000 *UND*00000000 tud_mounted00000000 *UND*00000000 tud_suspended00000000 g F .text.tud_cdc_n_get_line_state00000014 tud_cdc_n_get_line_state00000000 g F .text.tud_cdc_n_get_line_coding00000020 tud_cdc_n_get_line_coding00000000 *UND*00000000 memcpy00000000 g F .text.tud_cdc_n_set_wanted_char00000014 tud_cdc_n_set_wanted_char00000000 g F .text.tud_cdc_n_available00000018 tud_cdc_n_available00000000 *UND*00000000 tu_fifo_count00000000 g F .text.tud_cdc_n_read00000028 tud_cdc_n_read00000000 *UND*00000000 tu_fifo_read_n00000000 g F .text.tud_cdc_n_peek00000018 tud_cdc_n_peek00000000 *UND*00000000 tu_fifo_peek00000000 g F .text.tud_cdc_n_read_flush00000020 tud_cdc_n_read_flush00000000 *UND*00000000 tu_fifo_clear00000000 g F .text.tud_cdc_n_write_flush00000078 tud_cdc_n_write_flush00000000 g F .text.tud_cdc_n_write00000034 tud_cdc_n_write00000000 *UND*00000000 tu_fifo_write_n00000000 g F .text.tud_cdc_n_write_available00000018 tud_cdc_n_write_available00000000 g F .text.tud_cdc_n_write_clear00000018 tud_cdc_n_write_clear00000000 g F .text.cdcd_init0000007c cdcd_init00000000 *UND*00000000 memset00000000 *UND*00000000 tu_fifo_config00000000 *UND*00000000 mutex_init00000000 g F .text.cdcd_reset0000002c cdcd_reset00000000 *UND*00000000 tu_fifo_set_overwritable00000000 g F .text.cdcd_open000000b4 cdcd_open00000000 *UND*00000000 usbd_edpt_open00000000 *UND*00000000 usbd_open_edpt_pair00000000 g F .text.cdcd_control_xfer_cb000000dc cdcd_control_xfer_cb00000000 w *UND*00000000 tud_cdc_line_coding_cb00000000 w *UND*00000000 tud_cdc_line_state_cb00000000 *UND*00000000 tud_control_xfer00000000 w *UND*00000000 tud_cdc_send_break_cb00000000 *UND*00000000 tud_control_status00000000 g F .text.cdcd_xfer_cb00000104 cdcd_xfer_cb00000000 *UND*00000000 tu_fifo_empty00000000 w *UND*00000000 tud_cdc_rx_wanted_cb00000000 w *UND*00000000 tud_cdc_tx_complete_cb00000000 w *UND*00000000 tud_cdc_rx_cb
How can I fix the CMakeFiles.txt file to avoid the empty files?
Statistics: Posted by ozw1z5rd — Sun Aug 18, 2024 5:43 pm — Replies 0 — Views 32