1

YOUR HELP PLEASE!

I need to run an sh file that calls cpp functions on Mobaxterm with windows machine, I am a newbie in shell scripting, and I cant understand the following error messages :

Creating rtlib.a...
ar: unknown option -- u
BusyBox v1.22.1 (2015-11-10 11:07:12    ) multi-call binary.

Usage: ar [-o] [-v] [-p] [-t] [-x] ARCHIVE FILES

Extract or list FILES from an ar archive

        -o      Preserve original dates
        -p      Extract to stdout
        -t      List
        -x      Extract
        -v      Verbose

Makefile:55: recipe for target 'rtlib.a' failed
make: *** [rtlib.a] Error 1

Here is the entire sh code

#!/bin/bash

# Directories
DIRRTRo=RTRo
DIRrtlib=rtlib
DIRPPPTOOLS=$(pwd)

# Options
CC=g++
CFLAGS="-O3 -lm -lpthread -lrt -static"

# rtlib generation
generatertlib()
{
  echo "*****************"
  echo "rtlib generation"
  echo "*****************"
  cd $DIRrtlib || exit ; make ; cd - || exit
  #cd $DIRrtlib ; make ; cd -
}

# RTRo generation
generateRTRo()
{
  echo "******************"  
  echo "RTRo generation"
  echo "******************"
  cd $DIRRTRo ; make ; cd -
}

# getStream generation
generateGetStream()
{
  echo "********************"
  echo "getStream generation"
  echo "********************"
  $CC getStream.cpp -I$DIRrtlib $DIRrtlib/rtlib.a $CFLAGS -o getStream
}

# processStream generation
generateProcessStream()
{
  echo "************************"
  echo "processStream generation"
  echo "************************"
# Pour la livraison
 $CC processStream.cpp -I$DIRrtlib -I$DIRRTRo $DIRRTRo/libRTRo.a $DIRrtlib/rtlib.a $CFLAGS -DENAGLO -DENAGAL -DENACMP -DNFREQ=4 -DNEXOBS=1 -o processStream

}

# generateLowLevel generation
generateLowLevel()
{
  echo "***************************"
  echo "generateLowLevel generation"
  echo "***************************"
 $CC generateLowLevel.cpp -I$DIRrtlib $DIRrtlib/rtlib.a $CFLAGS -DENAGLO -DENAGAL -DENACMP -DNFREQ=4 -DNEXOBS=1 -o generateLowLevel
}

# processLowLevel generation
generateProcessLowLevel()
{
  echo "**************************"
  echo "processLowLevel generation"
  echo "**************************" 
 $CC processLowLevel.cpp -I$DIRRTRo $DIRRTRo/libRTRo.a $CFLAGS -o processLowLevel
}

# generation of all libraries, getStream and processStream
generateAll()
{
  generatertlib
  generateRTRo
  generateGetStream
  generateProcessStream
  generateLowLevel
  generateProcessLowLevel
}

# Main program

# Too many options
if [ $# -gt 1 ] ; then   
  echo "Error ! Usage : compile.sh [ clean | getStream | processStream | generateLowLevel | processLowLevel | computeErrors | sendStream | all ]"
  echo "Examples :"
  echo "  ./compile.sh"
  echo "  ./compile.sh clean"
  exit
fi

# Read option
if [ $# -eq 1 ] ; then
  if [ $1 == "clean" ] ; then
    cd $DIRrtlib ; make clean ; cd $DIRPPPTOOLS ;
    cd $DIRRTRo ; make clean ; cd $DIRPPPTOOLS ;
    rm -f processStream getStream processLowLevel computeErrors sendStream generateLowLevel
  elif [ $1 == "processStream" ] ; then
    generatertlib
    generateRTRo
    generateProcessStream
  elif [ $1 == "getStream" ] ; then
    generatertlib
    generateGetStream
  elif [ $1 == "generateLowLevel" ] ; then
    generatertlib
    generateLowLevel
  elif [ $1 == "processLowLevel" ] ; then
    generateRTRo
    generateProcessLowLevel
  elif [ $1 == "computeErrors" ] ; then
    generatertlib
    generateComputeErrors
    elif [ $1 == "sendStream" ] ; then
    generatertlib
    generateSendStream
  elif [ $1 == "all" ] ; then
    generateAll
  else
    # Bad option
    echo "Error ! Usage : compile.sh [ clean | getStream | processStream | processLowLevel | generateLowLevel | computeErrors | sendStream | all ]"
    echo "Examples :"
    echo "  ./compile.sh"
    echo "  ./compile.sh clean"
    exit
  fi
fi

# No option => all
if [ $# -eq 0 ] ; then
    generateAll
fi

I'm sorry for pasting this too long code but I'm really facing problems and can't understand. So any help will be appreciated!

Marven
  • 11
  • 1
  • What do you mean by _calling a cpp function_ from a Terminal? You can invoke a C++ function only from within the C++ program which contains the function. – user1934428 Jul 14 '20 at 10:44
  • Thank you for having time to reply, what I meant is that the sh file will call a cpp functions in the same directory like generateGetStream() , generateRTRo(), generatertlib() – Marven Jul 14 '20 at 11:10
  • But you can't call a C++ funcrion from a shell script! – user1934428 Jul 14 '20 at 11:14
  • I don't know that really, but the software package provided by to me as student, contains sh and cpp files. And actually the sh file call the cpp files and I think it works for others ! – Marven Jul 14 '20 at 11:25

1 Answers1

1

The makefile in the subdirectory rtlib uses a rule (explicit or implicit) to make rtlib.a with the ar command option u which the BusyBox ar doesn't know. Cure: Use another shell and a full-fledged toolchain. (You may be able to install the popular Cygwin toolchain with the MobaXterm packages manager tool.)

Armali
  • 18,255
  • 14
  • 57
  • 171
  • Thank you for the reply, as I mentionned I'm newbie in this kind of coding , would you explain step by step, word for word to have a clear vision ? – Marven Jul 14 '20 at 09:53
  • I did installed the Cygwin toolchain (64), but when running I got the same error message ! Please is there any other suggestions ? – Marven Jul 14 '20 at 10:22
  • The question is now: Why is BusyBox used rather than an other shell? - I'd uninstall the "busybox" package (and open a new terminal tab). – Armali Jul 14 '20 at 11:25
  • Would you please explain more, step by step ? – Marven Jul 14 '20 at 21:00
  • In the MobaXterm window (at least in mine) there's a sidebar with tabs Macros, Tools, Sessions. Click on Tools. Now there's a menu with sections Terminal Games, System, Office, Network. Under System, there's MobApt packages manager; click there. After a while, a window with the list of packages appears. Select busybox and busybox-standalone; click Uninstall. – Armali Jul 15 '20 at 06:30
  • I have uninstalled the busybox and the busybox stand-alone, and I restart my desktop, but the same problem persist, always said : ar: unknown option -- u – Marven Jul 15 '20 at 14:14
  • Is there still the line `BusyBox v1.22.1 (2015-11-10 11:07:12 ) multi-call binary.` in the error message? If so, the question is: Where is this Busybox, since you uninstalled already. You might try `which busybox` or `which ar` to find it. – Armali Jul 21 '20 at 05:05