Menu

MacOS GCbasic fails to compile. N00b here

Help
2021-02-26
2021-02-28
  • Jesus Guerrero

    Jesus Guerrero - 2021-02-26

    Hi all,

    I first became insterested when I saw Youtube videos of GCbasics ability to compile code for the LGT8f32p and i decided to check GCBASIC out. This was months ago as compliling GCC was put on the back burner. Now i have tried to comple GCbasic v0_96_06 along with FBC 1.06, but even after updating the bulld.sh file, i cannot get it to successfuly compile. can I please get help?

     
    • mkstevo

      mkstevo - 2021-02-28

      Just in case you are still reading this. The problem with the "Indirect Goto" errors is that freebasic is using the Apple version of Gcc to compile the gcbasic.bas code into the macOS assembly and final executable file. You need to ensure that the Apple Gcc is "replaced" by the Free Software Foundation version of Gcc.

      The problem with this is that if you actually use XCode to develop programs or Apps on the Mac that might use or need the Apple version, replacing it with another could cause XCode to fail.

      There may be a way of temporarily redirecting freebasic to the Free Software Foundation version by using something like:

      $export PATH ... {path to alternate Gcc here}

      from within the compile shell script, but that is way beyond my capabilities.

      I have always installed the XCode command line tools, then deleted the files and aliases that point to the Apple Gcc finally copied back in the Free Software Foundation files. Then copied and pasted the assembler "as" and linker(?) "ld" into the various folders until freebasic compiles gcbasic without any errors. This is a somewhat hit and miss affair as I'm not certain what I'm doing! I have managed it, and have written some notes (below) on how I did this, but can't be certain that they will work for you.

       
  • Jesus Guerrero

    Jesus Guerrero - 2021-02-26

    incase this helps, a screenshot of the build.sh file

     
  • Jesus Guerrero

    Jesus Guerrero - 2021-02-26

    If this has already been solved on a previous post, I apologize, but i have tried finding past posts but have not been able to solve my issue. Whether this is due to my lack of familiarity, idk.

     
  • Jesus Guerrero

    Jesus Guerrero - 2021-02-26

    Also, I currently have Catalina installed [10.15.6]

     
    • Anobium

      Anobium - 2021-02-26

      For LGT support you will need a 0.98.07 as a minimum.

      See the files tab for the release candidate software.

       
      • Jesus Guerrero

        Jesus Guerrero - 2021-02-26

        hmm, I will try that version now. Thank you,

         
      • Jesus Guerrero

        Jesus Guerrero - 2021-02-26

        Is this file only available as a .exe file?

         
  • mkstevo

    mkstevo - 2021-02-26

    I have a Mac binary for 0.98.07 RC09.

    If that is suitable, I could email you a copy if you PM me? If it isn't suitable, if someone can extract the sources from the .exe file, I could try and compile it for you? I have Mojave, so can't promise it will suit Catalina. Trev made a full installer for macOS which should be your first step if you haven't installed it already. It isn't the most recent version, and won't have support for the LGT device, but should get most things into roughly the right location for you.

    I have written some notes, but they may not be of much help!

    Have you managed to get FreeBasic installed?
    If you run FreeBasic from a Terminal window, do you get a response from it?
    Have you got the full XCode package installed? If so, this may cause problems.

    My notes:

    How I compiled GCB for the Mac.
    
    If you have the full XCode package installed, you may run into problems. I'd suggest you don't do any of this without significant knowledge of what you are doing.
    
    Download fbc-1.06-darwin-wip20160505.tar.bz2
    This is located at:  http://tmc.castleparadox.com/temp/fbc-1.06-darwin-wip20160505.tar.bz2
    
    Download the current version of gcc.
    
    Download the current "Linux" build version of GCB. This is a password protected .rar file. Keka may be required to open this file, the password is GCB.
    
    Download the XCode command Line tools for the version of macOS in use. 
    Install this.
    
    Unzip, UnRAR or UnTar all other downloaded files.
    
    Navigate to: /Library/Developer/CommandLineTools/usr/bin
    Delete the gcc file.
    
    Navigate to: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib
    
    Copy all files which start with "crt1".
    
    Copy them into: /Library/Developer/CommandLineTools/usr/bin
    
    Copy the files: as, cc1 from /Users/mkstevo/.Trash/gcc-9.2
    
    Navigate to the GCC-9.2 (or your version of the GCC files) folder which you extracted earlier.
    Locate the /gcc-9.2/bin folder and rename the x86_64-apple-darwin18.7.0-gcc-9.2 file to gcc
    
    Copy this renamed file into /Library/Developer/CommandLineTools/usr/bin
    
    *May not be required?
    *Copy the files: as, cc1 
    *from /gcc-9.2/libexec/gcc/x86_64-apple-darwin18.7.0/9.2.0
    *into /Library/Developer/CommandLineTools/usr/bin
    
    Open a terminal command window.
    Type: gcc --version
    
    You should see something like:
    gcc (GCC) 9.2.0
    Copyright (C) 2019 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    
    If this returns an Apple copyright notice, then something has gone wrong. I would suggest deleting any /Library/Developer/CommandLineTools folders and starting again. If you have the full XCode package installed, you may run into problems.
    
    Navigate to: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib
    
    Copy all files which start with "crt1".
    
    Copy them into: the FreeBasic folder you extracted earlier: 
    /fbc-1.06/lib/freebasic/darwin-x86_64/
    
    Edit the Shell script from with in the GreatCowBasic source folder:
    /sources/darwinbuild/build.sh
    
    This only needs the lines as listed below:
    
    #!/bin/sh
    
    #
    # v1.01 - Updated filepaths for new archive layout
    #
    
    echo
    echo "Compiling Great Cow BASIC for macOS with FreeBASIC"
    echo
    
    # FreeBASIC has a hardcoded OS target version; this needs to match below
    # or you will get a linker error similar to the following:
    # ld: warning: object file (gcbasic.o) was built for newer OSX version (10.13) than being linked (10.1)
    export MACOSX_DEPLOYMENT_TARGET=10.4
    
    # Now compile!
    #
    # Correct the path for your FreeBASIC version and location
    
    /Users/mkstevo/GCB_Mac/Sources/fbc-1.06/bin/fbc -exx -v -arch native  /Users/mkstevo/GCB_Mac/Sources/GreatCowBasicSource/sources/gcbasic.bas
    
    echo
    echo "Finished"
    echo
    
    Edit the path so that it points to your FreeBasic folder, and the GreatCowBasic sources folder. 
    Save any changes.
    
    Return to the terminal and make this script executeable:
    chmod -x /Users/mkstevo/GCB_Mac/Sources/GreatCowBasicSource/sources/darwinbuild/build.sh
    
    Finally, it is time to see if this works.
    Return to the terminal and drag the build.sh script into it, press enter and hope all goes well.
    
    If it does not, try and determine where you have gone wrong. Missing libraries can usually be cured by locating them in the gcc folders and copying them into: 
    /Library/Developer/CommandLineTools/usr/bin
    
    Some missing libraries can be found in the /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib folder. Again copy them into:
    /Library/Developer/CommandLineTools/usr/bin
    
    If you still get errors, try copying the missing files into the FreeBasic folder:
    /fbc-1.06/lib/freebasic/darwin-x86_64/
    
    Make sure that the GreatCowBasic sources folder contains:
    gcbasic.bas
    assembly.bi
    preprocessor.bi
    utils.bi
    variables.bi
    a folder: /darwinbuild/ containing build.sh
    
    Assuming the compilation completed successfully, you should be left with a file called gcbasic
    
    This can dropped into terminal to see if it was successful. It should show some text describing how to use the file. This starts:
    Great Cow BASIC - A BASIC compiler for microcontrollers
    Version: 0.98.06 2019-06-12 (Darwin 64 bit)
    
    Congratulations. Let's have a celebration!
    
     
  • Anobium

    Anobium - 2021-02-26

    Let me put a new Linus distro in Release Candidates. It will be RC41

     
    • Jesus Guerrero

      Jesus Guerrero - 2021-02-26

      I just saw this message, I will check it out

       
  • stan cartwright

    stan cartwright - 2021-02-26

    @jesus also get latest rc version. The lgt328 is supported well but there maybe the author
    needs to test it more, so still in release candidate.
    I'm using compiler version: 0.98.07 RC36....win 64bit.
    I seem to get gcb stuff from github.
    Anobium could explain.
    Glad someone else is interested in lgt328 :)

     
  • mkstevo

    mkstevo - 2021-02-27

    Well, that was an afternoon of frustration! I have previously managed to compile GCB for macOS and had everything set up. In order to help Jesus I tried downloading the current build (RC42) and compiling it. Failed. I knew why, since I last did this I have had some horrendous problems with my iMac failing repeatedly to boot. Long story short, I partitioned the drive in two and installed the OS on one partition with my user account and "stuff" on the other. This meant that I could reinstall (and reinstall, and reinstall...) the OS without wiping my data. This left me with a few problems, usually relating to the paths to my user account. However, macOS now assumes I don't have the developer tools command line utilities installed and I've had to go through my list of (inaccurate) instructions again. Three hours later and I'm good to go.

    Initially I got an error when compiling RC42:

    gcbasic.bas(15046) error 3: Expected End-of-Line, found '/' in '//not supported'
    

    Looking at line 15046 I found:

    #IFDEF __FB_UNIX__
      //not supported
    #ELSE
    

    I assumed that "//not supported" was a comment and so used an apostrophe to comment out the comment...

    Then things looked much brighter. The compile, build and link then completed.
    Running the new gcbasic executeable in Terminal produced this:

    Great Cow BASIC - A BASIC compiler for microcontrollers
    Version: 0.98.07 RC42 2021-02-27 (Darwin 64 bit)
    
    To compile a file, drag and drop it onto the icon for this program. See
    Getting Started with GCBASIC for more info.
    
    Command line parameters:
    GCBASIC [/O:output.asm] [/A:assembler] [/P:programmer] [/K:{C|A}] [/V] [/L]
            [/R:format] [/S:settings.ini] [/NP] [/WX] [/F] filename
    
            /O:output.asm   Set an output filename other than the default
            /A:assembler    Batch file used to call assembler. If /A:GCASM is
                              given, GCBASIC will use its internal assembler.
            /P:programmer   Batch file used to call programmer, or programmer
                          name if defined in settings file.
            /K:{C|A}        Keep original code in assembly output. /K:C will
                              save comments, /K:A will preserve all input code.
            /R:format       Write a compilation report. Format can be html, text
                              or none.
            /S:settings.ini Specify name of settings file to load
            /V              Verbose mode
            /L              Show license
            /NP             Do not pause on errors. Use with IDEs.
            /WX             Treat warnings as errors
            /F              Skip compilation if up to date hex file found, call
                              programmer immediately and then exit.
            /Version        Display the version of the software.
            filename        The file to compile.
    
    You may use - in place of /, such as -V instead of /V.
    

    I then copied the directory over the top of my "old" installation, loaded up Geany and compiled my Eiffel Tower Clock code:

    Great Cow BASIC (0.98.07 RC42 2021-02-27 (Darwin 64 bit))
    Compiling WS2812_18F14K22_11_02_2021_Eiffel_Tower.gcb ...
    
    ...
    
    No compilation errors found.
    Compilation and programming time: 3.433s
    

    So. If you would like a compiled binary for macOS (I'm using Mojave) of RC42, I could let you have one.

     
  • Anobium

    Anobium - 2021-02-27

    Well done!! Well done.

    I will sort the // in the source for the next release. What I need is a MAC user who is willing to test the MPLABX-PIC-AS software... then, we can sort for the MAC users.

     
    • mkstevo

      mkstevo - 2021-02-27

      I have a pathological hate of MPLab and all that it incorporates! That's what got me started with GCB.

      If PIC-AS is useable on macOS without me needing to install all, or part, of MPLabX (i.e. it is just a standalone executeable with few dependancies) I may be willing to have a look. I'm not sure what PIC-AS is, what it offers, what it does and why I do (or don't) need it.

       
      • Anobium

        Anobium - 2021-02-27

        LOL - I will just sort the issue with the source. When someone wants to use the capability under MAC OS, then, we can address at that point.

        You dont need MPLAB-X to make is work, but, to see your program in the MPLAB-X simulator ... you need the ful MPLAB-X. :-)

         
        • mkstevo

          mkstevo - 2021-02-27

          If I understand your reply, by compiling using PIC-AS would allow simulation of a program, within MPLabX? I guess that compiling using the GCB assembler doesn't allow this? A simulator would be an enormous help for me. Although I have built some test panels that have the common "bits 'n' bobs" I usually need, or connections for them on it. That means I can quickly knock up a prototype for testing code. Then I write, test, rewrite, retest, rewrite, retest, hone into shape, rewrite, retest, refine, done! Not the best use of my time, but it's how my brain works.

           
          • Anobium

            Anobium - 2021-02-28

            Yes. You can walk the code in MPLAB-X simulator. The reason for the PIC-AS capability is to resolve bugs in the core compiler/libraries using the MPLAB-X simulator.

            Hugh does have a Great Cow BASIC simulator but it is not as robust as MPLAB-X simulator.

            Re the method. Your method works. And, MPLAB-X simulator is only there for really hard issues where your method does not work. :-)

             
  • mkstevo

    mkstevo - 2021-02-28

    Is the simulator Hugh has available for end users? I could really use something like that. Robust or not.

    My method "works" well enough for me. It suits my scattered thought patterns well. Fortunately the OTP devices are almost as old as I am, and just as rare. EeProm based devices are more suited to my approach.

     
  • Chris Roper

    Chris Roper - 2021-02-28

    Take a look at PICSimLab that is what I use but I am not sure if it will work on Mac.
    https://sourceforge.net/projects/picsim/
    The Prof, who created it for his University courses, is very good and quick at fixing bugs if you find any.

     

    Last edit: Chris Roper 2021-02-28
    • mkstevo

      mkstevo - 2021-02-28

      I can't get it to run under WINE. I will give it a try once I get the super cheap laptop out. I thought I had looked at it before but dismissed it as {I thought} it didn't cover the devices I used most often, 16F1825/29 and 12F1840.

      Thanks for the suggestion.

       

      Last edit: mkstevo 2021-02-28
      • Chris Roper

        Chris Roper - 2021-02-28

        The latest release has increased the number of Supported Devices but not sure if it includes your preferences.

        There is a web based version you can try:
        https://lcgamboa.github.io/

        Not sure how good it is though as I only use the Latest Windows Copy.

         
        • mkstevo

          mkstevo - 2021-02-28

          Just had a look at the "online" version. It does not seem to cover the devices I tend to use, that's a pity. It also looks as though it is permanently wired to the development board configuration.

          OshonSoft PIC16 emulator does simulate (almost) all of the devices I use, and I've nearly been tempted to buy it on more than a few occasions. The one thing that stops me is the hard coded ports for the LCD. I've politely asked if the LCD module could have moveable "connections" and each time Vladimir has replied that this change is imminent, but it hasn't happened yet as far as I can tell.

           

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.