1

请帮忙!

我需要在 Windows 机器上运行一个在 Mobaxterm 上调用 cpp 函数的 sh 文件,我是 shell 脚本的新手,我无法理解以下错误消息:

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

这是整个 sh 代码

#!/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

很抱歉粘贴了这个太长的代码,但我真的遇到了问题并且无法理解。所以任何帮助将不胜感激!

4

1 回答 1

1

子目录中的 makefilertlib使用规则(显式或隐式)使用BusyBox不知道rtlib.aar命令选项进行制作。解决方法:使用另一个 shell 和成熟的工具链。(您可以使用 MobaXterm 包管理器工具安装流行的 Cygwin 工具链。)uar

于 2020-07-14T09:43:35.343 回答