0

I'm having an issue when trying to compile simple C code for my raspberry pi pico. I am using VSCode (this is reproducible in PS as well). I have set up everything correctly as far as I'm aware.

I have tried doing this only in PS and it gives me the exact same results.

CMakeLists.txt

cmake_minimum_required(VERSION 3.19)

include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake)

project(blink C CXX ASM)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

pico_sdk_init()

add_executable(${PROJECT_NAME}
    main.c
)

pico_add_extra_outputs(${PROJECT_NAME})

target_link_libraries(${PROJECT_NAME}
    pico_stdlib
)

Main.c

#include <pico/stdlib.h>

int main()
{
    const uint led_pin = 25;

    //init ledpin
    gpio_init(led_pin);
    gpio_set_dir(led_pin, GPIO_OUT);

    while(true)
    {
        //blink led
        gpio_put(led_pin, true);
        sleep_ms(1000);
        gpio_put(led_pin, false);
        sleep_ms(1000);
    }
}

This when compiled using nmake. Spits out,

[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --build c:/pico/Projects/Blink/build --config Release --target blink -j 6 --
[build] Warning: NMake does not support parallel builds. Ignoring parallel build command line option.
[build] makefile(7): Error(E21): Extension(s) (.PHONY) not defined
[build] makefile(10): Error(E21): Extension(s) (.NOTPARALLEL) not defined
[build] makefile(12): Error(E09): Ignoring out of place Extension
[build] makefile(14): Error(E21): Extension(s) (.PHONY) not defined
[build] makefile(28): Warning(W18): Unrecognized or out of place character '='
[build] makefile(31): Error(E09): Ignoring out of place Single-colon
[build] makefile(36): Error(E21): Extension(s) (.PHONY) not defined
...
[build] Error(E02): Make execution terminated
[build] Build finished with exit code 0

I am not able to find much in the sense of how to fix this exact thing, which is surprising to me. The only thing that I have found is that nmake doesn't use ".PHONY" and thats where most of my issues are coming from.

Do I just remove all of the ".PHONY" references in the Makefile? I hope someone can help with this very confusing problem.

Thank you.

  • Disclaimer: no `nmake` exposure on my part, but there flavors of `make` and I suppose `nmake` differs in this regard from `gmake` or whatever your `cmake` generated `Makefile` assumed. You may want to have a look at `-G` flag of `cmake` and make sure generator suitable for use case is used... i.e. `NMake Makefiles`? – Ondrej K. Oct 24 '21 at 16:57
  • You present a `CMakeLists.txt`. Are you in fact using CMake in your build process? Because in a CMake build, the makefile would be generated cia the `cmake` command, and if that isn't right for your environment then probably `cmake` is not being invoked correctly. – John Bollinger Oct 24 '21 at 17:15
  • The Cmake command i'm using to generate the makefiles is "CMake -G "NMake Makefiles" .." Then afterwards I try compiling with the command "nmake" – deathwillcome800 Oct 24 '21 at 17:47

1 Answers1

1

I have finally solved the issue.

I had a 3rd party nmake installed on my computer "Open Watcom C/C++".

This was creating a "WMake Makefiles" which is obviously not an "NMake Makefiles".

If you run into this issue please read your NMake output more closely.