Description / Steps to reproduce the issue
1. Follow the instructions in the document: Guides -> C++ Example using CMake:
./tools/configure.sh -l esp32s3-devkit:nsh
make menuconfig ...
Executing to "make export"
2. Creating my cpp project with vscode
main.cpp:
#include "versionConfig.h"
#include
extern "C" int main(int, char*[])
{
printf("App Version: %s\n", HELLOCPP_VERSION_STRING);
return 0;
}
CMakePresets.json:
"configurePresets": [
{
"name": "nuttx-debug",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_TOOLCHAIN_FILE": "/home/globalz/nuttx-export-13.0.0/scripts/toolchain.cmake"
}
}
]
CMakeLists.txt:
cmake_minimum_required(VERSION 3.16)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
project(Tiger4
VERSION 0.0.0
)
configure_file(
${CMAKE_SOURCE_DIR}/versionConfig.h.in
${CMAKE_BINARY_DIR}/versionConfig.h
@only
)
file(GLOB_RECURSE TIGER
${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp
)
set(EXE_NAME "tiger4")
add_executable(${EXE_NAME} ${TIGER})
target_include_directories(${EXE_NAME} PRIVATE ${CMAKE_BINARY_DIR})
add_custom_command(
TARGET ${EXE_NAME}
POST_BUILD
COMMAND ${CMAKE_OBJCOPY} ARGS -S -O binary ${CMAKE_BINARY_DIR}/${EXE_NAME} ${CMAKE_BINARY_DIR}/${EXE_NAME}.bin
)
3. When build stopped, pay attention to the bolded words
[main] Building folder: /home/globalz/tiger4/build
[main] The folder containing the CMake cache is missing. The cache will be regenerated.
[main] Configuring project: tiger4
[proc] Executing command: /usr/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=/home/globalz/nuttx-export-13.0.0/scripts/toolchain.cmake -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -S /home/globalz/tiger4 -B /home/globalz/tiger4/build -G Ninja
[cmake] -- Configuring done (12.6s)
[cmake] -- Generating done (0.0s)
[cmake] -- Build files have been written to: /home/globalz/tiger4/build
[build] Starting build
[proc] Executing command: /usr/bin/cmake --build /home/globalz/tiger4/build --
[build] [1/2] Building CXX object CMakeFiles/tiger4.dir/src/main.cpp.obj
[build] [2/2] Linking CXX executable tiger4
[build] FAILED: tiger4
[build] : && /home/globalz/esp/xtensa-esp-elf/bin/xtensa-esp32s3-elf-ld -nostdlib --gc-sections --cref -Map=/home/globalz/nuttxspace/nuttx/nuttx.map --print-memory-usage --entry=_start -T/home/globalz/nuttx-export-13.0.0/scripts/../scripts/esp32s3_peripherals.ld esp32s3_rom_aliases.ld flat_memory.ld esp32s3_sections.ld CMakeFiles/tiger4.dir/src/main.cpp.obj -o tiger4 -L/home/globalz/nuttx-export-13.0.0/scripts/../libs --start-group -lsched -ldrivers -lboards -lc -lmm -larch -lxx -lapps -lfs -lbinfmt -lboard -lboard /home/globalz/esp/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/esp32s3/libgcc.a /home/globalz/esp/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/lib/esp32s3/libm.a /home/globalz/esp/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/lib/esp32s3/libsupc++.a /home/globalz/esp/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/lib/esp32s3/libstdc++.a --end-group && cd /home/globalz/tiger4/build && xtensa-esp32s3-elf-objcopy -S -O binary /home/globalz/tiger4/build/tiger4 /home/globalz/tiger4/build/tiger4.bin
[build] /home/globalz/esp/xtensa-esp-elf/bin/xtensa-esp-elf-ld: cannot find esp32s3_rom_aliases.ld: No such file or directory
[build] /home/globalz/esp/xtensa-esp-elf/bin/xtensa-esp-elf-ld: cannot find flat_memory.ld: No such file or directory
[build] /home/globalz/esp/xtensa-esp-elf/bin/xtensa-esp-elf-ld: cannot find esp32s3_sections.ld: No such file or directory
[build] ninja: build stopped: subcommand failed.
[proc] The command: /usr/bin/cmake --build /home/globalz/tiger4/build -- exited with code: 1
[driver] Build completed: 00:00:00.071
[build] Build finished with exit code 1
4. I think the problem is in target.cmake or toolchain.cmake when make export
In target.cmake, there are 4 .lds:
set(LDNAME "esp32s3_peripherals.ld esp32s3_rom_aliases.ld flat_memory.ld esp32s3_sections.ld")
In toolchain.cmake, only the first .ld has a path:
set(LINKER_SCRIPT ${NUTTX_PATH}/scripts/${LDNAME})
set(CMAKE_CXX_LINK_EXECUTABLE
"<CMAKE_LINKER> ${LDFLAGS} --entry=${ENTRY_NAME} -T${LINKER_SCRIPT} -o <LINK_LIBRARIES> -L${NUTTX_PATH}/libs --start-group ${LDLIBS} ${EXTRA_LIBS} --end-group"
)
On which OS does this issue occur?
[OS: Linux]
What is the version of your OS?
Windows11 using wsl for Ubuntu 24.04.4 LTS
NuttX Version
13.0.0 , The same issue as 12.13.0
Issue Architecture
[Arch: xtensa]
Issue Area
[Area: Build System]
Host information
No response
Verification
Description / Steps to reproduce the issue
1. Follow the instructions in the document: Guides -> C++ Example using CMake:
./tools/configure.sh -l esp32s3-devkit:nsh
make menuconfig ...
Executing to "make export"
2. Creating my cpp project with vscode
main.cpp:
#include "versionConfig.h"
#include
extern "C" int main(int, char*[])
{
printf("App Version: %s\n", HELLOCPP_VERSION_STRING);
return 0;
}
CMakePresets.json:
"configurePresets": [
{
"name": "nuttx-debug",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_TOOLCHAIN_FILE": "/home/globalz/nuttx-export-13.0.0/scripts/toolchain.cmake"
}
}
]
CMakeLists.txt:
cmake_minimum_required(VERSION 3.16)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
project(Tiger4
VERSION 0.0.0
)
configure_file(
${CMAKE_SOURCE_DIR}/versionConfig.h.in
${CMAKE_BINARY_DIR}/versionConfig.h
@only
)
file(GLOB_RECURSE TIGER
${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp
)
set(EXE_NAME "tiger4")
add_executable(${EXE_NAME} ${TIGER})
target_include_directories(${EXE_NAME} PRIVATE ${CMAKE_BINARY_DIR})
add_custom_command(
TARGET ${EXE_NAME}
POST_BUILD
COMMAND ${CMAKE_OBJCOPY} ARGS -S -O binary ${CMAKE_BINARY_DIR}/${EXE_NAME} ${CMAKE_BINARY_DIR}/${EXE_NAME}.bin
)
3. When build stopped, pay attention to the bolded words
[main] Building folder: /home/globalz/tiger4/build
[main] The folder containing the CMake cache is missing. The cache will be regenerated.
[main] Configuring project: tiger4
[proc] Executing command: /usr/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=/home/globalz/nuttx-export-13.0.0/scripts/toolchain.cmake -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -S /home/globalz/tiger4 -B /home/globalz/tiger4/build -G Ninja
[cmake] -- Configuring done (12.6s)
[cmake] -- Generating done (0.0s)
[cmake] -- Build files have been written to: /home/globalz/tiger4/build
[build] Starting build
[proc] Executing command: /usr/bin/cmake --build /home/globalz/tiger4/build --
[build] [1/2] Building CXX object CMakeFiles/tiger4.dir/src/main.cpp.obj
[build] [2/2] Linking CXX executable tiger4
[build] FAILED: tiger4
[build] : && /home/globalz/esp/xtensa-esp-elf/bin/xtensa-esp32s3-elf-ld -nostdlib --gc-sections --cref -Map=/home/globalz/nuttxspace/nuttx/nuttx.map --print-memory-usage --entry=_start -T/home/globalz/nuttx-export-13.0.0/scripts/../scripts/esp32s3_peripherals.ld esp32s3_rom_aliases.ld flat_memory.ld esp32s3_sections.ld CMakeFiles/tiger4.dir/src/main.cpp.obj -o tiger4 -L/home/globalz/nuttx-export-13.0.0/scripts/../libs --start-group -lsched -ldrivers -lboards -lc -lmm -larch -lxx -lapps -lfs -lbinfmt -lboard -lboard /home/globalz/esp/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/esp32s3/libgcc.a /home/globalz/esp/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/lib/esp32s3/libm.a /home/globalz/esp/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/lib/esp32s3/libsupc++.a /home/globalz/esp/xtensa-esp-elf/bin/../lib/gcc/xtensa-esp-elf/14.2.0/../../../../xtensa-esp-elf/lib/esp32s3/libstdc++.a --end-group && cd /home/globalz/tiger4/build && xtensa-esp32s3-elf-objcopy -S -O binary /home/globalz/tiger4/build/tiger4 /home/globalz/tiger4/build/tiger4.bin
[build] /home/globalz/esp/xtensa-esp-elf/bin/xtensa-esp-elf-ld: cannot find esp32s3_rom_aliases.ld: No such file or directory
[build] /home/globalz/esp/xtensa-esp-elf/bin/xtensa-esp-elf-ld: cannot find flat_memory.ld: No such file or directory
[build] /home/globalz/esp/xtensa-esp-elf/bin/xtensa-esp-elf-ld: cannot find esp32s3_sections.ld: No such file or directory
[build] ninja: build stopped: subcommand failed.
[proc] The command: /usr/bin/cmake --build /home/globalz/tiger4/build -- exited with code: 1
[driver] Build completed: 00:00:00.071
[build] Build finished with exit code 1
4. I think the problem is in target.cmake or toolchain.cmake when make export
In target.cmake, there are 4 .lds:
set(LDNAME "esp32s3_peripherals.ld esp32s3_rom_aliases.ld flat_memory.ld esp32s3_sections.ld")
In toolchain.cmake, only the first .ld has a path:
set(LINKER_SCRIPT ${NUTTX_PATH}/scripts/${LDNAME})
set(CMAKE_CXX_LINK_EXECUTABLE
"<CMAKE_LINKER> ${LDFLAGS} --entry=${ENTRY_NAME} -T${LINKER_SCRIPT} -o <LINK_LIBRARIES> -L${NUTTX_PATH}/libs --start-group ${LDLIBS} ${EXTRA_LIBS} --end-group"
)
On which OS does this issue occur?
[OS: Linux]
What is the version of your OS?
Windows11 using wsl for Ubuntu 24.04.4 LTS
NuttX Version
13.0.0 , The same issue as 12.13.0
Issue Architecture
[Arch: xtensa]
Issue Area
[Area: Build System]
Host information
No response
Verification