skip to Main Content

Using windows 10, I am trying to build example code for a W5100S-EVB-Pico.

I started in https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf section 9.2 which sets you up to build on windows. I was able to build the examples files there using visual studio code.

Now I want to use the Wiznet. Starting in https://github.com/Wiznet/RP2040-HAT-C I follow directions in the file getting_started.md I then go to vs code, and follow the pattern from 9.2. I open the folder …RP2040-HAT-Cexampleshttpserver select the appropriate compiler, and click build. I get an error which leads me to add the line
cmake_minimum_required(VERSION 3.25)
to CMakeLists.txt Build now results in the following:

[variant] Loaded new set of variants
[kit] Successfully loaded 5 kits from C:UsersrwAppDataLocalCMakeToolscmake-tools-kits.json
[proc] Executing command: "D:Program Files (x86)Arm GNU Toolchain arm-none-eabi12.2 rel1binarm-none-eabi-gcc.exe" -v
[proc] Executing command: "C:Program FilesCMakebincmake.EXE" -Sd:/cygwin/home/rw/holden/RP2040-HAT-C/examples/http/server -Bd:/cygwin/home/rw/holden/RP2040-HAT-C/examples/http/server/build -G "NMake Makefiles"
[proc] The command: "C:Program FilesCMakebincmake.EXE" -Sd:/cygwin/home/rw/holden/RP2040-HAT-C/examples/http/server -Bd:/cygwin/home/rw/holden/RP2040-HAT-C/examples/http/server/build -G "NMake Makefiles" exited with code: 1 and signal: null
[main] Configuring folder: server 
[proc] Executing command: "C:Program FilesCMakebincmake.EXE" --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug "-DCMAKE_C_COMPILER:FILEPATH=D:Program Files (x86)Arm GNU Toolchain arm-none-eabi12.2 rel1binarm-none-eabi-gcc.exe" "-DCMAKE_CXX_COMPILER:FILEPATH=D:Program Files (x86)Arm GNU Toolchain arm-none-eabi12.2 rel1binarm-none-eabi-g++.exe" -Sd:/cygwin/home/rw/holden/RP2040-HAT-C/examples/http/server -Bd:/cygwin/home/rw/holden/RP2040-HAT-C/examples/http/server/build -G "NMake Makefiles"
[cmake] Not searching for unused variables given on the command line.
[cmake] CMake Warning (dev) in CMakeLists.txt:
[cmake]   No project() command is present.  The top-level CMakeLists.txt file must
[cmake]   contain a literal, direct call to the project() command.  Add a line of
[cmake]   code such as
[cmake] 
[cmake]     project(ProjectName)
[cmake] 
[cmake]   near the top of the file, but after cmake_minimum_required().
[cmake] 
[cmake]   CMake is pretending there is a "project(Project)" command on the first
[cmake]   line.
[cmake] This warning is for project developers.  Use -Wno-dev to suppress it.
[cmake] 
[cmake] -- The C compiler identification is GNU 12.2.1
[cmake] -- The CXX compiler identification is GNU 12.2.1
[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - failed
[cmake] -- Check for working C compiler: D:/Program Files (x86)/Arm GNU Toolchain arm-none-eabi/12.2 rel1/bin/arm-none-eabi-gcc.exe
[cmake] -- Check for working C compiler: D:/Program Files (x86)/Arm GNU Toolchain arm-none-eabi/12.2 rel1/bin/arm-none-eabi-gcc.exe - broken
[cmake] CMake Error at C:/Program Files/CMake/share/cmake-3.25/Modules/CMakeTestCCompiler.cmake:70 (message):
[cmake]   The C compiler
[cmake] 
[cmake]     "D:/Program Files (x86)/Arm GNU Toolchain arm-none-eabi/12.2 rel1/bin/arm-none-eabi-gcc.exe"
[cmake] 
[cmake]   is not able to compile a simple test program.
[cmake] 
[cmake]   It fails with the following output:
[cmake] 
[cmake]     Change Dir: D:/cygwin/home/rw/holden/RP2040-HAT-C/examples/http/server/build/CMakeFiles/CMakeScratch/TryCompile-2zbfaa
[cmake]     
[cmake]     Run Build Command(s):nmake -f Makefile /nologo cmTC_d4dcefast &&   "C:Program Files (x86)Microsoft Visual Studio2022BuildToolsVCToolsMSVC14.34.31933binHostX86x86nmake.exe"  -f CMakeFilescmTC_d4dce.dirbuild.make /nologo -L                  CMakeFilescmTC_d4dce.dirbuild
[cmake]     Building C object CMakeFiles/cmTC_d4dce.dir/testCCompiler.c.obj
[cmake]         "D:Program Files (x86)ARMGNU~112DBAB~1.2REbinAR19DD~1.EXE"    -o CMakeFilescmTC_d4dce.dirtestCCompiler.c.obj -c D:cygwinhomerwholdenRP2040-HAT-CexampleshttpserverbuildCMakeFilesCMakeScratchTryCompile-2zbfaatestCCompiler.c
[cmake]     Linking C executable cmTC_d4dce.exe
[cmake]         "C:Program FilesCMakebincmake.exe" -E rm -f CMakeFilescmTC_d4dce.dir/objects.a
[cmake]         "D:Program Files (x86)ARMGNU~112DBAB~1.2REbinARM-NO~2.EXE" qc CMakeFilescmTC_d4dce.dir/objects.a @CMakeFilescmTC_d4dce.dirobjects1
[cmake]         "D:Program Files (x86)ARMGNU~112DBAB~1.2REbinAR19DD~1.EXE" -Wl,--whole-archive CMakeFilescmTC_d4dce.dir/objects.a -Wl,--no-whole-archive -o cmTC_d4dce.exe -Wl,--out-implib,libcmTC_d4dce.dll.a -Wl,--major-image-version,0,--minor-image-version,0 @CMakeFilescmTC_d4dce.dirlinkLibs.rsp
[cmake]     d:/program files (x86)/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: unrecognized option '--major-image-version'
[cmake]     d:/program files (x86)/armgnu~1/12dbab~1.2re/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: use the --help option for usage information
[cmake]     collect2.exe: error: ld returned 1 exit status
[cmake]     NMAKE : fatal error U1077: '"D:Program Files (x86)ARMGNU~112DBAB~1.2REbinAR19DD~1.EXE"' : return code '0x1'
[cmake]     Stop.
[cmake]     NMAKE : fatal error U1077: '"C:Program Files (x86)Microsoft Visual Studio2022BuildToolsVCToolsMSVC14.34.31933binHostX86x86nmake.exe"' : return code '0x2'
[cmake]     Stop.
[cmake]     
[cmake]     
[cmake] 
[cmake]   
[cmake] 
[cmake]   CMake will not be able to correctly generate this project.
[cmake] Call Stack (most recent call first):
[cmake]   CMakeLists.txt
[cmake] 
[cmake] 
[cmake] -- Configuring incomplete, errors occurred!
[cmake] See also "D:/cygwin/home/rw/holden/RP2040-HAT-C/examples/http/server/build/CMakeFiles/CMakeOutput.log".
[cmake] See also "D:/cygwin/home/rw/holden/RP2040-HAT-C/examples/http/server/build/CMakeFiles/CMakeError.log".
[proc] The command: "C:Program FilesCMakebincmake.EXE" --no-warn-unused-cli -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_BUILD_TYPE:STRING=Debug "-DCMAKE_C_COMPILER:FILEPATH=D:Program Files (x86)Arm GNU Toolchain arm-none-eabi12.2 rel1binarm-none-eabi-gcc.exe" "-DCMAKE_CXX_COMPILER:FILEPATH=D:Program Files (x86)Arm GNU Toolchain arm-none-eabi12.2 rel1binarm-none-eabi-g++.exe" -Sd:/cygwin/home/rw/holden/RP2040-HAT-C/examples/http/server -Bd:/cygwin/home/rw/holden/RP2040-HAT-C/examples/http/server/build -G "NMake Makefiles" exited with code: 1 and signal: null

Some googling also led me to add the line
set(CMAKE_SYSTEM_NAME Generic)
to CMakeLists.txt, which now looks like

set(TARGET_NAME w5x00_http_server)

cmake_minimum_required(VERSION 3.25)
set(CMAKE_SYSTEM_NAME Generic)

add_executable(${TARGET_NAME}
        ${TARGET_NAME}.c
        )

target_link_libraries(${TARGET_NAME} PRIVATE
        pico_stdlib
        hardware_spi
        hardware_dma
        ETHERNET_FILES
        IOLIBRARY_FILES
        HTTPSERVER_FILES
        )

pico_enable_stdio_usb(${TARGET_NAME} 1)
pico_enable_stdio_uart(${TARGET_NAME} 0)

pico_add_extra_outputs(${TARGET_NAME})

I tried to fix the broken compiler error, which made things worse, and returning CMakeLists.txt to its former state did not get back to what is shown above. Is there some kind of ‘clean’ function I can do?

2

Answers


  1. Chosen as BEST ANSWER

    My mistake was opening the 'server' folder and assuming that everything was there. I never could figure out where the 'toolchain file' was. The solution is to open the folder RP2040-HAT-C in VS code first and select the appropriate compiler. VS code then does the initial cmake with the .txt file in that directory. Now, on the status line in VS code, I can click 'all' next to build, select my desired target (server) and build. Success!

    Thanks to everyone who helped me with this.


  2. EDIT2: Tsyvarev made a very good point in the discussion under this answer. Because your CMakeLists.txt is missing a project(...) line it most likely gets implicitly called by CMake on the first line. Specific variables such as CMAKE_CXX_COMPILER or for example CMAKE_SYSTEM_NAME require to be set before the project() line. It is worth trying to update the CMakeLists.txt accordingly. However the first EDIT still holds place (which was also Tsyvarevs finding). You are most likely trying to build from an insufficient CMakeLists.txt

    EDIT: I didn’t notice what Tsyvarev mentioned in the comments, after looking at the appropriate CMakeLists.txt I have to agree with him. You are definitely also missing some targets and you’ve probably didn’t give us the whole (new) error message. The missing targets here are (for example):

    ETHERNET_FILES
    IOLIBRARY_FILES
    HTTPSERVER_FILES
    

    You will most likely encounter errors regarding this as well. However the original error is truly tied to the set(CMAKE_SYSTEM_NAME Generic).


    Original post:

    A missing cmake_minimum_required() should just throw a warning not an error IIRC.

    The only clean function that exists in CMake is rm [path-to-build-directory]. When you issue the cmake -S. -Bbuild command (or similar) you create a build folder where CMake generates the file needed to compile the project.

    As to your issue. The set(CMAKE_SYSTEM_NAME Generic) should be added to the toolchain file or at the very least be the first variable set in your CMakeLists.txt. I believe (and this is a wild guess) that it should be before the cmake_minimum_required() this is the same for variables like CMAKE_CXX_COMPILER etc.

    What I would recommend is:

    1. Move the set(CMAKE_SYSTEM_NAME Generic) to the top of the CMakeLists.txt file
    2. Remove the build folder.
    3. Run cmake and build it again.

    If the above won’t help then I need you to clarify for me this:

    • By "I went back to VSCode" you mean you opened it up via the Developer prompt like the book you linked suggested.
    • What commands do you pass to run cmake/build it, i.e. what happens if you run from the Developer powershell/command prompt: cmake -S. -BbuildForStackOverflow -DCMAKE_SYSTEM_NAME=Generic and then build it from these generated files?
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search