Problems in using cmake with standalone SDK



  • On Ubuntu 16.04, using Sipeed M1w Dan Dock (By the way, someone really needs to standardize the names used for each board, it is currently too confusing. A table of comparison would be nice too).

    Using the excellent all-in-one script from manageryzy I was able to install the toolchain and standalone SDK and the test seems to compile fine.

    But I can't seem to build my own .bin files using cmake. In $HOME/kendryte/kendryte-standalone-sdk/src/hello_world there is already a main.c file which contains the following code:

    #include <stdio.h>
    #include "bsp.h"
    
    int core1_function(void *ctx)
    {
        uint64_t core = current_coreid();
        printf("Core %ld Hello world\n", core);
        while(1);
    }
    
    
    int main()
    {
        uint64_t core = current_coreid();
        printf("Core %ld Hello world\n", core);
        register_core1(core1_function, NULL);
        while(1);
    }
    

    To generate a new .bin file, I type this in a new terminal window:

    cd kendryte/kendryte-standalone-sdk/
    mkdir build && cd build
    cmake .. -DPROJ=hello_world -DSDK_ROOT=\$STANDALONE_SDK_DIR -DTOOLCHAIN=\$K210_TOOLCHAIN && make
    

    This produces the following error in the terminal:

    ld -DSDK_ROOT=\$STANDALONE_SDK_DIR -DTOOLCHAIN=\$K210_TOOLCHAIN && make
    PROJ = hello_world
    -- Check for RISCV toolchain ...
    -- Using $K210_TOOLCHAIN RISCV toolchain
    -- The C compiler identification is unknown
    -- The CXX compiler identification is unknown
    CMake Error at CMakeLists.txt:17 (project):
      The CMAKE_C_COMPILER:
    
        $K210_TOOLCHAIN/riscv64-unknown-elf-gcc
    
      is not a full path and was not found in the PATH.
    
      Tell CMake where to find the compiler by setting either the environment
      variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
      the compiler, or to the compiler name if it is in the PATH.
    
    
    CMake Error at CMakeLists.txt:17 (project):
      The CMAKE_CXX_COMPILER:
    
        $K210_TOOLCHAIN/riscv64-unknown-elf-g++
    
      is not a full path and was not found in the PATH.
    
      Tell CMake where to find the compiler by setting either the environment
      variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
      to the compiler, or to the compiler name if it is in the PATH.
    
    
    -- Configuring incomplete, errors occurred!
    See also "/home/mcx/kendryte/kendryte-standalone-sdk/CMakeFiles/CMakeOutput.log".
    See also "/home/mcx/kendryte/kendryte-standalone-sdk/CMakeFiles/CMakeError.log".
    

    CMakeOutput.log

    The target system is: Generic -  - 
    The host system is: Linux - 4.15.0-39-generic - x86_64
    

    CMakeError.log

    Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
    Compiler: $K210_TOOLCHAIN/riscv64-unknown-elf-gcc 
    Build flags: ;-mcmodel=medany;-fno-common;-ffunction-sections;-fdata-sections;-fstrict-volatile-bitfields;-fno-zero-initialized-in-bss;-Os;-ggdb;-std=gnu11;-Wno-pointer-to-int-cast;-Wall;-Werror=all;-Wno-error=unused-function;-Wno-error=unused-but-set-variable;-Wno-error=unused-variable;-Wno-error=deprecated-declarations;-Wextra;-Werror=frame-larger-than=65536;-Wno-unused-parameter;-Wno-sign-compare;-Wno-error=missing-braces;-Wno-error=return-type;-Wno-error=pointer-sign;-Wno-missing-braces;-Wno-strict-aliasing;-Wno-implicit-fallthrough;-Wno-missing-field-initializers;-Wno-old-style-declaration
    Id flags: 
    
    The output was:
    No such file or directory
    
    
    Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
    Compiler: $K210_TOOLCHAIN/riscv64-unknown-elf-gcc 
    Build flags: ;-mcmodel=medany;-fno-common;-ffunction-sections;-fdata-sections;-fstrict-volatile-bitfields;-fno-zero-initialized-in-bss;-Os;-ggdb;-std=gnu11;-Wno-pointer-to-int-cast;-Wall;-Werror=all;-Wno-error=unused-function;-Wno-error=unused-but-set-variable;-Wno-error=unused-variable;-Wno-error=deprecated-declarations;-Wextra;-Werror=frame-larger-than=65536;-Wno-unused-parameter;-Wno-sign-compare;-Wno-error=missing-braces;-Wno-error=return-type;-Wno-error=pointer-sign;-Wno-missing-braces;-Wno-strict-aliasing;-Wno-implicit-fallthrough;-Wno-missing-field-initializers;-Wno-old-style-declaration
    Id flags: -c
    
    The output was:
    No such file or directory
    
    
    Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
    Compiler: $K210_TOOLCHAIN/riscv64-unknown-elf-gcc 
    Build flags: ;-mcmodel=medany;-fno-common;-ffunction-sections;-fdata-sections;-fstrict-volatile-bitfields;-fno-zero-initialized-in-bss;-Os;-ggdb;-std=gnu11;-Wno-pointer-to-int-cast;-Wall;-Werror=all;-Wno-error=unused-function;-Wno-error=unused-but-set-variable;-Wno-error=unused-variable;-Wno-error=deprecated-declarations;-Wextra;-Werror=frame-larger-than=65536;-Wno-unused-parameter;-Wno-sign-compare;-Wno-error=missing-braces;-Wno-error=return-type;-Wno-error=pointer-sign;-Wno-missing-braces;-Wno-strict-aliasing;-Wno-implicit-fallthrough;-Wno-missing-field-initializers;-Wno-old-style-declaration
    Id flags: -Aa
    
    The output was:
    No such file or directory
    
    
    Checking whether the C compiler is IAR using "" did not match "IAR .+ Compiler":
    Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
    Compiler: $K210_TOOLCHAIN/riscv64-unknown-elf-g++ 
    Build flags: ;-mcmodel=medany;-fno-common;-ffunction-sections;-fdata-sections;-fstrict-volatile-bitfields;-fno-zero-initialized-in-bss;-Os;-ggdb;-std=gnu++17;-Wall;-Werror=all;-Wno-error=unused-function;-Wno-error=unused-but-set-variable;-Wno-error=unused-variable;-Wno-error=deprecated-declarations;-Wextra;-Werror=frame-larger-than=65536;-Wno-unused-parameter;-Wno-sign-compare;-Wno-error=missing-braces;-Wno-error=return-type;-Wno-error=pointer-sign;-Wno-missing-braces;-Wno-strict-aliasing;-Wno-implicit-fallthrough;-Wno-missing-field-initializers
    Id flags: 
    
    The output was:
    No such file or directory
    
    
    Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" failed.
    Compiler: $K210_TOOLCHAIN/riscv64-unknown-elf-g++ 
    Build flags: ;-mcmodel=medany;-fno-common;-ffunction-sections;-fdata-sections;-fstrict-volatile-bitfields;-fno-zero-initialized-in-bss;-Os;-ggdb;-std=gnu++17;-Wall;-Werror=all;-Wno-error=unused-function;-Wno-error=unused-but-set-variable;-Wno-error=unused-variable;-Wno-error=deprecated-declarations;-Wextra;-Werror=frame-larger-than=65536;-Wno-unused-parameter;-Wno-sign-compare;-Wno-error=missing-braces;-Wno-error=return-type;-Wno-error=pointer-sign;-Wno-missing-braces;-Wno-strict-aliasing;-Wno-implicit-fallthrough;-Wno-missing-field-initializers
    Id flags: -c
    
    The output was:
    No such file or directory
    
    
    Checking whether the CXX compiler is IAR using "" did not match "IAR .+ Compiler":
    

    How do I fix these errors?



  • @JanzeeLiu 回复里面显示的又问题,我写在这里。
    alt text
    复制完之后,再编译:
    alt text



  • @JanzeeLiu 我已解决这个问题。原问题如图
    alt text
    可以看到,问题的原因是没有找到/usr/local/riscv/bin/riscv64-unknown-elf-gcc/usr/local/riscv/bin/riscv64-unknown-elf-g++文件,官网link text下载offlinepackages.beta.darwin.7z,解压,得到kendryteIDE,找到上面两个文件,复制到```
    /usr/local/riscv/bin

    下面,如图:
    ![alt text](https://i.loli.net/2019/02/22/5c6f854925be8.png)
    然后再编译:
    ![alt text](https://i.loli.net/2019/02/22/5c6f859043b2c.png)


  • @mcx I meet the seam problem in mac.I don't know how to solve it.



  • @mcx said in Problems in using cmake with standalone SDK:

    cmake .. -DPROJ=hello_world -DSDK_ROOT=$STANDALONE_SDK_DIR -DTOOLCHAIN=$K210_TOOLCHAIN && make

    this step has failed,the error is :it cant find gcc File in toolchain .i think you should figure out whether toolchain File has something wrong.or download toolchain again.

    yesterday i has the same error .i find that my ubuntu version is 18.04 which is Incompatible.today i install version 16.04.run success.