OpenSprinkler Forums OpenSprinkler Unified Firmware OSPi 2.1.9 build errors

  • This topic has 10 replies, 4 voices, and was last updated 4 years ago by Ray.
Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #62780

    Dutchie30
    Participant

    I’m seeing some build errors under CentOS 7:

    {code}[root@opensprinkler OpenSprinkler-Firmware]# ./build.sh -s ospi
    Building OpenSprinkler…
    weather.cpp: In function ‘void getweather_callback(char*)’:
    weather.cpp:55:31: error: ‘atoi’ was not declared in this scope
    wt_errCode = atoi(tmp_buffer);
    ^
    weather.cpp:61:22: error: ‘atoi’ was not declared in this scope
    v = atoi(tmp_buffer);
    ^
    weather.cpp:71:22: error: ‘atoi’ was not declared in this scope
    v = atoi(tmp_buffer);
    ^
    weather.cpp:80:22: error: ‘atoi’ was not declared in this scope
    v = atoi(tmp_buffer);
    ^
    weather.cpp:89:31: error: ‘atol’ was not declared in this scope
    uint32_t l = atol(tmp_buffer);
    ^
    weather.cpp:98:22: error: ‘atoi’ was not declared in this scope
    v = atoi(tmp_buffer);
    ^
    weather.cpp:110:22: error: ‘atoi’ was not declared in this scope
    v = atoi(tmp_buffer);
    ^
    Done!{code}

    I reported a similar issue for 2.1.7 about 3 years ago, it’s possible this issue is similar: https://opensprinkler.com/forums/topic/ospi-2-1-7-build-errors-on-centos-7-2-1511-for-rpi3/

    #62790

    Ray
    Keymaster

    Sounds like you are missing some basic libraries: atoi is a very common function. I’ve never compiled the program in CentOS. If you just google the error message you should be able to find solutions online.

    #62821

    Dutchie30
    Participant

    Strange. I’m not confident I’m missing the atoi library. A build of 2.1.8 works as expected on the same host:

    [root@opensprinkler OpenSprinkler-Firmware-218]# ./build.sh ospi
    Building OpenSprinkler...
    Done!

    2.1.8 also looks to contain references to atoi in server.cpp, so it looks like I do have the atoi library available. Is it possible the atoi library isn’t declared properly in the new weather.cpp?

    #62824

    Ray
    Keymaster

    In your first post, the command you typed is:
    ./build.sh -s ospi
    what’s that ‘-s’?

    #62829

    Dutchie30
    Participant

    It’s the option to do a “quiet” build:

    # head -n 11 build.sh 
    #!/bin/bash
    
    while getopts ":s" opt; do
      case $opt in
        s)
              SILENT=true
              command shift
          ;;
      esac
    done
    echo "Building OpenSprinkler..."

    It fails without -s too:

    # ./build.sh ospi
    Building OpenSprinkler...
    weather.cpp: In function ‘void getweather_callback(char*)’:
    weather.cpp:55:31: error: ‘atoi’ was not declared in this scope
       wt_errCode = atoi(tmp_buffer);
                                   ^
    weather.cpp:61:22: error: ‘atoi’ was not declared in this scope
       v = atoi(tmp_buffer);
                          ^
    weather.cpp:71:22: error: ‘atoi’ was not declared in this scope
       v = atoi(tmp_buffer);
                          ^
    weather.cpp:80:22: error: ‘atoi’ was not declared in this scope
       v = atoi(tmp_buffer);
                          ^
    weather.cpp:89:31: error: ‘atol’ was not declared in this scope
       uint32_t l = atol(tmp_buffer);
                                   ^
    weather.cpp:98:22: error: ‘atoi’ was not declared in this scope
       v = atoi(tmp_buffer);
                          ^
    weather.cpp:110:22: error: ‘atoi’ was not declared in this scope
       v = atoi(tmp_buffer);
                          ^
    Done!
    #62846

    Ray
    Keymaster

    I am confused: you said this is under CentOS 7, so does your Raspberry Pi run CentOS 7, or are you compiling the code under a desktop CentOS 7? I would assume your RPi runs CentOS 7, because you are using ‘./build.sh ospi’. If you are building it on a desktop Linux, you should be ‘./build.sh demo’. I have no experience with CentOS 7, so unfortunately I can’t tell what’s the issue. Sounds like you just need to add a include header in one of those .cpp files. The code has been compiled on Raspbian and also Linux Mint and I did not observe any such error. Make sure you are on master branch. Do a clean git clone to make sure you didn’t modify anything.

    #62972

    Marc
    Participant

    I just updated my Raspberry Pi installation (after running a “git pull” from my installation directory), and thought I should mention that I ran into the same problem:

    pi@sprinkler:~/OpenSprinklerGen2 $ sudo ./build.sh ospi
    Building OpenSprinkler...
    weather.cpp: In function 'void getweather_callback(char*)':
    weather.cpp:55:31: error: 'atoi' was not declared in this scope
       wt_errCode = atoi(tmp_buffer);
                                   ^
    weather.cpp:61:22: error: 'atoi' was not declared in this scope
       v = atoi(tmp_buffer);
                          ^
    weather.cpp:71:22: error: 'atoi' was not declared in this scope
       v = atoi(tmp_buffer);
                          ^
    weather.cpp:80:22: error: 'atoi' was not declared in this scope
       v = atoi(tmp_buffer);
                          ^
    weather.cpp:89:31: error: 'atol' was not declared in this scope
       uint32_t l = atol(tmp_buffer);
                                   ^
    weather.cpp:98:22: error: 'atoi' was not declared in this scope
       v = atoi(tmp_buffer);
                          ^
    weather.cpp:110:22: error: 'atoi' was not declared in this scope
       v = atoi(tmp_buffer);
                          ^
    Done!
    

    I added a line to the weather.cpp file to include the C standard library include file (i.e., “#include <stdlib.h>”), and that appears to have resolved the issue for me:

    pi@sprinkler:~/OpenSprinklerGen2 $ sudo ./build.sh ospi
    Building OpenSprinkler...
    Done!
    #62987

    Ray
    Keymaster

    Hmm, I just did a fresh checkout of the firmware and compiled it on my RPi and didn’t see this error at all. But sure, we can add the header file to weather.cpp anyways.

    #63058

    Talltrees
    Participant

    Ray, I too have the same error message as Marc when compiling a fresh copy of firmware onto a fully updated / dist-update Jessie formatted SD card. I tried compiling another SD card and again I got the same error message.
    The result of this is that OpenSprinkler doesn’t run, checked /etc/init.d/OpenSprinkler.sh to find that that file has no content. I copied the content of OpenSprinkler.sh from my other Ospi running firmware 2.1.8(4) into the new build with no success.

    #65060

    Dutchie30
    Participant

    A very late reply from me: Adding #include <stdlib.h> (Thx @Marc!) fixed the issue for me too. I’m all for including this in the next release.

    #65072

    Ray
    Keymaster

    It’s already added to the latest release of the firmware.

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.

OpenSprinkler Forums OpenSprinkler Unified Firmware OSPi 2.1.9 build errors