Shop OBEX P1 Docs P2 Docs Learn Events
Stamp Basic Compiler for Linux - Page 2 — Parallax Forums

Stamp Basic Compiler for Linux

2»

Comments

  • signalsignal Posts: 6
    edited 2014-10-09 12:43
    Greetings,

    I'm new to BasicStamp and need to get the tools working on my Linux Mint 17 (i386 32bit) install.
    Below is the compiler output.

    The first warning is solved by adding the suggested parentheses to stampbc.cc.
    The only ref to 'atoi' I found is in the SBCompiler.cc.
    I have not even looked for the error dealing with 'exit'.

    Any help or suggestions are most welcome.


    make
    g++ -g -Wall -D_COLORFUL -c stampbc.cc
    stampbc.cc: In function ‘int processOptions(int, char**, SBProject&)’:
    stampbc.cc:80:27: warning: suggest parentheses around arithmetic in operand of ‘|’ [-Wparentheses]
    f = proj.getFlags() | SBProject::F_COMPILEONLY &
    ^
    stampbc.cc:133:31: error: ‘atoi’ was not declared in this scope
    proj.setSlot(atoi(optarg));
    ^
    stampbc.cc: In function ‘int main(int, char**)’:
    stampbc.cc:185:25: error: ‘exit’ was not declared in this scope
    exit(ret > 0 ? 0 : ret);
    ^
    make: *** [stampbc.o] Error 1



    I'm using the stampbc 124 code.
  • TorTor Posts: 2,010
    edited 2014-10-09 17:49
    There's possibly a specific C++ way, but the generic C way will work too:
    Add the following line to the top of the stampbc.cc file:
    #include <stdlib.h>
    
    That should solve both errors.
  • signalsignal Posts: 6
    edited 2014-10-10 11:32
    Tor wrote: »
    There's possibly a specific C++ way, but the generic C way will work too:
    Add the following line to the top of the stampbc.cc file:
    #include <stdlib.h>
    
    That should solve both errors.

    Thanks Tor.

    That did the trick, at least for that section of code.

    After adding your suggested '#include <stdlib.h>' I went back to post #5 of this thread and did the changes suggested there, and now have another problem.

    Here is the section of SBTokenizer.cc code that got changed.
    if (m_libt) {
    // (void *)m_TestRecAlignment = dlsym(m_libt, "TestRecAlignment");
    // (void *)m_Compile == dlsym(m_libt, "Compile");
    // (void *)m_Version = dlsym(m_libt, "Version");
    void* p(0);

    p = dlsym(m_libt, "TestRecAlignment");
    m_TestRecAlignment = (bool (*)(TModuleRec*))p;

    p = dlsym(m_libt, "Compile");
    m_Compile = (bool (*)(TModuleRec*, char*, unsigned char, unsigned char, TSrcTokReference*)p;

    p = dlsym(m_libt, "Version");
    m_Version = (byte (*)())p;

    return true;
    }

    And this is the compiler output.

    ******************************************************************
    make
    g++ -g -Wall -D_COLORFUL -c SBTokenizer.cc
    SBTokenizer.cc: In member function ‘bool SBTokenizer::init()’:
    SBTokenizer.cc:77:14: error: expected primary-expression before ‘bool’
    m_Compile = (bool (*)(TModuleRec*, char*, unsigned char, unsigned char, TSrcTokReference*)p;
    ^
    SBTokenizer.cc:77:14: error: expected ‘)’ before ‘bool’
    make: *** [SBTokenizer.o] Error 1
    *****************************************************************

    Since the original code compiled and worked for other people I can only think that different versions of the same compiler are handling the source differently, for whatever reasons. Perhaps the compiler guys are in cahoots with the headache pill companies.

    I need a beer.
  • signalsignal Posts: 6
    edited 2014-10-10 16:18
    Update to my post #34.

    Post #31 by bbooth contained the answer to the problem. So now the section of source of SBTokenizer.cc looks like;
    if (m_libt) {
    // (void *)m_TestRecAlignment = dlsym(m_libt, "TestRecAlignment");
    // (void *)m_Compile == dlsym(m_libt, "Compile");
    // (void *)m_Version = dlsym(m_libt, "Version");

    void* p(0);

    p = dlsym(m_libt, "TestRecAlignment");
    m_TestRecAlignment = (bool (*)(TModuleRec*))p;

    p = dlsym(m_libt, "Compile");
    //m_Compile = (bool (*)(TModuleRec*, char*, unsigned char, unsigned char, TSrcTokReference*)p;
    m_Compile = (bool (*)(SBTokenizer::TModuleRec*, char*, bool, bool))p;

    p = dlsym(m_libt, "Version");
    m_Version = (byte (*)())p;

    return true;
    }

    Now the compiler output looks like;
    *********************************************************************
    make
    g++ -g -Wall -D_COLORFUL -c stampbc.cc
    g++ -g -Wall -D_COLORFUL -c SBTokenizer.cc
    g++ -g -Wall -D_COLORFUL -c SBCompiler.cc
    SBCompiler.cc: In member function ‘bool SBCompiler::compile(const string&, const string&, std::string&, std::string&, bool, bool, bool)’:
    SBCompiler.cc:179:13: warning: variable ‘objSize’ set but not used [-Wunused-but-set-variable]
    int objSize;
    ^
    g++ -g -Wall -D_COLORFUL -c SBProject.cc
    g++ -g -Wall -D_COLORFUL -c SBLoader.cc
    SBLoader.cc:48:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
    };
    ^
    SBLoader.cc:48:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
    SBLoader.cc:48:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
    SBLoader.cc:48:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
    SBLoader.cc:48:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
    SBLoader.cc:48:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
    SBLoader.cc:48:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
    SBLoader.cc:48:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
    SBLoader.cc:48:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
    SBLoader.cc:48:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
    SBLoader.cc:48:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
    SBLoader.cc:48:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
    SBLoader.cc:48:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
    SBLoader.cc:48:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
    SBLoader.cc:48:1: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
    g++ -g -Wall -D_COLORFUL -o stampbc stampbc.o SBTokenizer.o SBCompiler.o SBProject.o SBLoader.o -ldl
    *********************************************************************************

    I also had to add #include <stdlib.h> to SBCompiler.cc

    Again, any help is welcome.
  • TorTor Posts: 2,010
    edited 2014-10-10 21:30
    I can't help much with c++-specific issues unfortunately. One reason I decided to stay away from C++ years ago was that I noticed how much of a moving target the C++ language definition was. Code suffered from not working with the next version compiler. It seems that this is still happening.
    However, I'll come back to you if nobody else jumps in - but right now I'm packing my computers because I'll be relocating to my alternative location.
  • signalsignal Posts: 6
    edited 2014-10-11 04:57
    @Tor

    I have never used C++ and only dig into it when absolutly necessary. I'm not a programmer and only use C when I need to do some small things, or fix some problems, which usually means spending time re-learning stuff.

    There is no hurry on this. The kit I ordered has not gotten here yet, but since I do not have any windows computers I will need to get this working. It's all fun and frustration. :-)
  • signalsignal Posts: 6
    edited 2014-10-16 13:00
    UPDATE.

    After too much frustration I decided on a new attack to this problem.

    First I installed Wine and the win98 version of the Parallax software just to see if the OEM board I assembled would work........It's ALIVE!

    I set aside the Stamp_124 source code for now, I'll get back to that later.

    I grabbed the pbasic code from sourceforge as it looked simpler to work with.
    Followed the instructions on the sourceforge pbasic website for installing and using the pbasic tokenizer product.

    Grrrrrrrrrr, NUTS! All kinds of errors and warnings.

    Next I cranked up my old Debian 6.0.7 install and tried compiling there. It worked.
    Still had some warnings. I then copied the whole pbasic folder to a USB stick and rebooted into Mint 17, pasted the folder into my Home/user directory, opened a root terminal and did a 'make install' ( I did a 'make uninstall' from the Stamp_124 folder first ).

    It works. The pbasic code tokenizes and loads to the stamp.

    So the problem is either outdated source code or the wrong version of compiler ( shake head ).

    Well, time for a break and see if I can scratch off some HoneyDo's ( that woman really knows how to make lists ). :-)
Sign In or Register to comment.