Home > OS >  " /bin/sh: 1: Syntax error: "(" unexpected " error while building code for raspb
" /bin/sh: 1: Syntax error: "(" unexpected " error while building code for raspb

Time:10-06

I am on Ubuntu. I am trying to build a simple project that I know worked! (I already made it work) I don't think I changed something to it but it has been three days and I cannot find a way to make it build again.

I use a library named pico-DMX, whenever I don't add it to my project with "include" in cmake, than the make starts building.

Otherwise, if I include the library in the cmake code, cmake .. command process and generate normally but the build ctrying to build a simple project that I know workedrashes instantaneously. I cannot seem to understand where it comes from.

This is the error message:

PICO_SDK_PATH is /home/andrew/pico/pico-sdk
PICO platform is rp2040.
Build type is Release
PICO target board is pico.
Using board configuration from /home/andrew/pico/pico-sdk/src/boards/include/boards/pico.h
TinyUSB available at /home/andrew/pico/pico-sdk/lib/tinyusb/src/portable/raspberrypi/rp2040; enabling build support for USB.
cyw43-driver available at /home/andrew/pico/pico-sdk/lib/cyw43-driver
lwIP available at /home/andrew/pico/pico-sdk/lib/lwip
-- Configuring done
-- Generating done
-- Build files have been written to: /home/andrew/pico/serial_pico (copy)/build
Scanning dependencies of target bs2_default
[  1%] Building ASM object pico-sdk/src/rp2_common/boot_stage2/CMakeFiles/bs2_default.dir/compile_time_choice.S.obj
[  2%] Linking ASM executable bs2_default.elf
/bin/sh: 1: Syntax error: "(" unexpected
make[2]: *** [pico-sdk/src/rp2_common/boot_stage2/CMakeFiles/bs2_default.dir/build.make:98: pico-sdk/src/rp2_common/boot_stage2/bs2_default.elf] Error 2
make[2]: *** Deleting file 'pico-sdk/src/rp2_common/boot_stage2/bs2_default.elf'
make[1]: *** [CMakeFiles/Makefile2:1493: pico-sdk/src/rp2_common/boot_stage2/CMakeFiles/bs2_default.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

This is my main cmake files:

cmake_minimum_required(VERSION 3.13)

include($ENV{PICO_SDK_PATH}/pico_sdk_init.cmake)

project(usb_control C CXX ASM)

set(CMAKE_CXX_STANDARD 17)

pico_sdk_init()

include($ENV{HOME}/pico/libraries/lib/Pico-DMX/interfaceLibForPicoSDK.cmake)
add_executable(usb_control
    main.cpp
)

target_link_libraries(usb_control picodmx pico_stdlib hardware_pio hardware_dma)

pico_enable_stdio_usb(usb_control 1)
pico_enable_stdio_uart(usb_control 0)

pico_add_extra_outputs(usb_control)

The previous cmake file include $ENV{HOME}/pico/libraries/lib/Pico-DMX/interfaceLibForPicoSDK.cmake which contains :

## Include this file if you want to use the Pico-DMX library
## in YOUR (Pico-C-SDK-based) project.

cmake_minimum_required(VERSION 3.12)

# Define the Pico-DMX library
add_library(picodmx INTERFACE)

target_sources(picodmx INTERFACE
    ${CMAKE_CURRENT_LIST_DIR}/src/DmxInput.cpp
    ${CMAKE_CURRENT_LIST_DIR}/src/DmxOutput.cpp
)

pico_generate_pio_header(picodmx
    ${CMAKE_CURRENT_LIST_DIR}/extras/DmxInput.pio
)
pico_generate_pio_header(picodmx
    ${CMAKE_CURRENT_LIST_DIR}/extras/DmxOutput.pio
)

target_include_directories(picodmx INTERFACE
    ${CMAKE_CURRENT_LIST_DIR}/src
)

Again, I know there are no mistakes in the C code, it worked! It started to bug and wouldn't work again when I played with the Cmake to include directly the library dependencies of pico-dmx in its cmake file.

If you have any questions feel free to ask, I'll answer quickly. In advance thank you for your help

CodePudding user response:

As mentioned in the comments, the cause is the name of your directory. In order to accurately explain why it happens, I reproduced your situation myself. I created a dummy project under "/tmp/test checkout (copy)" and built using CMake:

cd "/tmp/test checkout (copy)/build/pico-sdk/src/rp2_common/boot_stage2" && \
arm-none-eabi-objdump -h /tmp/test\ checkout\ (copy)/build/pico-sdk/src/rp2_common/boot_stage2/bs2_default.elf >bs2_default.dis

Note that the spaces in the full filename are correctly escaped with a backslash, but the parentheses are not. This confuses the shell.

I raised this issue on the Pico SDK. Until it is fixed, people should steer clear of using special characters in their directory structures. This is a good recommendation in general as it avoids situations like these.

  • Related