【buildroot-2011.11】You may have to install 'g++' on your build machine

來源:互聯網
上載者:User

標籤:buildroot

buildroot - 2011.11 交叉編譯器製作時,提示如下錯誤:

“You may have to install ‘g++‘ on your build machine”

還提示:toolchain/dependencies/dependencies.sh 121 Error


開啟toolchain/dependencies/dependencies.sh,有如下一段指令碼

# check for host CXXCXXCOMPILER=$(which $HOSTCXX 2> /dev/null)if [ -z "$CXXCOMPILER" ] ; then    CXXCOMPILER=$(which c++ 2> /dev/null)fiif [ -z "$CXXCOMPILER" ] ; then    /bin/echo -e "\nYou may have to install 'g++' on your build machine\n"    #exit 1fiif [ ! -z "$CXXCOMPILER" ] ; then    CXXCOMPILER_VERSION=$($CXXCOMPILER -v 2>&1 | sed -n '/^gcc version/p' |        sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q')        if [ -z "$CXXCOMPILER_VERSION" ] ; then        /bin/echo -e "\nYou may have to install 'g++' on your build machine\n"    fi    CXXCOMPILER_MAJOR=$(echo $CXXCOMPILER_VERSION | sed -e "s/\..*//g")    CXXCOMPILER_MINOR=$(echo $CXXCOMPILER_VERSION | sed -e "s/^$CXXCOMPILER_MAJOR\.//g" -e "s/\..*//g")    if [ $CXXCOMPILER_MAJOR -lt 3 -o $CXXCOMPILER_MAJOR -eq 2 -a $CXXCOMPILER_MINOR -lt 95 ] ; then        /bin/echo -e "\nYou have g++ '$CXXCOMPILER_VERSION' installed.  g++ >= 2.95 is required\n"        exit 1    fifi
有兩個地方會列印“You may have to install ‘g++‘ on your build machine”,在這兩個地方分別加入調試標記,發現是這裡出問題了。

# check for host CXX
CXXCOMPILER=$(which $HOSTCXX 2> /dev/null)
if [ -z "$CXXCOMPILER" ] ; then
    CXXCOMPILER=$(which c++ 2> /dev/null)
fi
if [ -z "$CXXCOMPILER" ] ; then
    /bin/echo -e "\nYou may have to install ‘g++‘ on your build machine\n"
    #exit 1
fi
if [ ! -z "$CXXCOMPILER" ] ; then
    CXXCOMPILER_VERSION=$($CXXCOMPILER -v 2>&1 | sed -n ‘/^gcc version/p‘ |
        sed -e ‘s/^gcc version \([0-9\.]\)/\1/g‘ -e ‘s/[-\ ].*//g‘ -e ‘1q‘)
    
    if [ -z "$CXXCOMPILER_VERSION" ] ; then
        /bin/echo -e "\nYou may have to install ‘g++‘ on your build machine\n"
    fi



    CXXCOMPILER_MAJOR=$(echo $CXXCOMPILER_VERSION | sed -e "s/\..*//g")
    CXXCOMPILER_MINOR=$(echo $CXXCOMPILER_VERSION | sed -e "s/^$CXXCOMPILER_MAJOR\.//g" -e "s/\..*//g")
    if [ $CXXCOMPILER_MAJOR -lt 3 -o $CXXCOMPILER_MAJOR -eq 2 -a $CXXCOMPILER_MINOR -lt 95 ] ; then
        /bin/echo -e "\nYou have g++ ‘$CXXCOMPILER_VERSION‘ installed.  g++ >= 2.95 is required\n"
        exit 1
    fi
fi

原來他沒有檢查出來,CXXCOMPILER_VERSION為空白。方便起見,我直接輸入命令:

c++ -v 2>&1 | sed -n ‘/^gcc version/p‘ | sed -e ‘s/^gcc version \([0-9\.]\)/\1/g‘ -e ‘s/[-\ ].*//g‘ -e ‘1q‘

得到C++的版本為:4.4.6

我就直接在CXXCOMPILER_VERSION的判斷上面加一句:CXXCOMPILER_VERSION=4.4.6
然後make,直接通過。


OK,問題解決到此結束!

【buildroot-2011.11】You may have to install 'g++' on your build machine

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.