【问题】
折腾:
【记录】在Cygwin下编译gcc-3.4.5-glibc-2.3.6的arm-xscale-linux-gnu交叉编译器
期间,安装完毕crosstool-ng后,去运行ct-ng help,结果出错:
CLi@PC-CLI-1 ~/develop/crosstool-ng/crosstool-ng-1.9.3 $ echo "PATH=$PATH:/opt/crosstool-ng/bin">>~/.bashrc CLi@PC-CLI-1 ~/develop/crosstool-ng/crosstool-ng-1.9.3 $ source ~/.bashrc bash: /.bashrc: line 1: syntax error near unexpected token `(' bash: /.bashrc: line 1: `PATH=/usr/local/bin:/usr/bin:/cygdrive/d/tmp/dev_install_root/Python27_x64:/cygdrive/d/tmp/dev_install_root/Python27_x64/Lib/site-packages/PyQt4:/cygdrive/d/tmp/dev_install_root/Perl64/site/bin:/cygdrive/d/tmp/dev_install_root/Perl64/bin:/cygdrive/c/Program Files/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/Program Files (x86)/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files (x86)/Microsoft SQL Server/100/Tools/Binn:/cygdrive/c/Program Files/Microsoft SQL Server/100/Tools/Binn:/cygdrive/c/Program Files/Microsoft SQL Server/100/DTS/Binn:/cygdrive/d/tmp/WordPress/mysql/mysql-5.5.18/MySQL/MySQL Server 5.5/bin:/cygdrive/d/tmp/WordPress/DevRoot/MySQL/MySQL Server 5.5/bin:/cygdrive/d/tmp/WordPress/DevRoot/php-5.3.6-Win32-VC9-x64:/cygdrive/d/tmp/WordPress/DevRoot/php-5.3.6-Win32-VC9-x64/ext:/cygdrive/d/tmp/WordPress/DevRoot/Python27:/cygdrive/c/Program Files (x86)/Common Files/Acronis/SnapAPI:/cygdrive/c/Program Files (x86)/Windows Live/Shared:/cygdrive/c/Program Files/Java/jdk1.7.0_11/bin:/home/CLi/develop/docbook/tools/fop/lib:/home/CLi/develop/docbook/tools/fop:/cygdrive/d/DevInstallRoot/FF/DD_IDE_1.1.2/TOK/BIN:/cygdrive/d/DevInstallRoot/FF/DD_IDE_1.2.0/TOK/BIN:/cygdrive/d/DevRoot/EmbeddedDevelop/trunk/Research/CLI/FF/FBK/develop/tools/develop-tools:/cygdrive/d/tmp/WordPress/DevRoot/Python27/Scripts:/cygdrive/d/tmp/dev_install_root/PostgreSQL/8.3/bin:/cygdrive/d/tmp/dev_install_root/ant/apache-ant-1.8.4/bin:/cygdrive/c/Program Files/nodejs:/cygdrive/c/Program Files/Microsoft/Web Platform Installer:/cygdrive/c/Program Files/TortoiseSVN/bin:/cygdrive/d/DevRoot/IndustrialMobileAutomation/HandheldDataSetter/ANTLR/batchFile:/cygdrive/c/Program Files (x86)/QuickTime/QTSystem:/cygdrive/d/tmp/tmp_dev_root/android/adt-bundle-windows/sdk/platform-tools:/cygdrive/d/tmp/dev_install_root/Tesseract-OCR:/cygdrive/d/tmp/dev_install_root/jython2.5.3/bin:/cygdrive/d/devinstallroot/gnuarm/bin:/cygdrive/c/Users/CLi/AppData/Roaming/npm:/usr/lib/lapack:/opt/crosstool-ng/bin' CLi@PC-CLI-1 ~/develop/crosstool-ng/crosstool-ng-1.9.3 $ ct-ng help bash: ct-ng: command not found
【解决过程】
1.后来增加上空格,结果还是不行:
CLi@PC-CLI-1 ~/develop/crosstool-ng/crosstool-ng-1.9.3 $ echo "PATH=$PATH:/opt/crosstool-ng/bin" >> ~/.bashrc CLi@PC-CLI-1 ~/develop/crosstool-ng/crosstool-ng-1.9.3 $ source ~/.bashrc bash: /home/CLi/.bashrc: line 199: syntax error near unexpected token `(' bash: /home/CLi/.bashrc: line 199: `PATH=/usr/local/bin:/usr/bin:/cygdrive/d/tmp/dev_install_root/Python27_x64:/cygdrive/d/tmp/dev_install_root/Python27_x64/Lib/site-packages/PyQt4:/cygdrive/d/tmp/dev_install_root/Perl64/site/bin:/cygdrive/d/tmp/dev_install_root/Perl64/bin:/cygdrive/c/Program Files/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/Program Files (x86)/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files (x86)/Microsoft SQL Server/100/Tools/Binn:/cygdrive/c/Program Files/Microsoft SQL Server/100/Tools/Binn:/cygdrive/c/Program Files/Microsoft SQL Server/100/DTS/Binn:/cygdrive/d/tmp/WordPress/mysql/mysql-5.5.18/MySQL/MySQL Server 5.5/bin:/cygdrive/d/tmp/WordPress/DevRoot/MySQL/MySQL Server 5.5/bin:/cygdrive/d/tmp/WordPress/DevRoot/php-5.3.6-Win32-VC9-x64:/cygdrive/d/tmp/WordPress/DevRoot/php-5.3.6-Win32-VC9-x64/ext:/cygdrive/d/tmp/WordPress/DevRoot/Python27:/cygdrive/c/Program Files (x86)/Common Files/Acronis/SnapAPI:/cygdrive/c/Program Files (x86)/Windows Live/Shared:/cygdrive/c/Program Files/Java/jdk1.7.0_11/bin:/home/CLi/develop/docbook/tools/fop/lib:/home/CLi/develop/docbook/tools/fop:/cygdrive/d/DevInstallRoot/FF/DD_IDE_1.1.2/TOK/BIN:/cygdrive/d/DevInstallRoot/FF/DD_IDE_1.2.0/TOK/BIN:/cygdrive/d/DevRoot/EmbeddedDevelop/trunk/Research/CLI/FF/FBK/develop/tools/develop-tools:/cygdrive/d/tmp/WordPress/DevRoot/Python27/Scripts:/cygdrive/d/tmp/dev_install_root/PostgreSQL/8.3/bin:/cygdrive/d/tmp/dev_install_root/ant/apache-ant-1.8.4/bin:/cygdrive/c/Program Files/nodejs:/cygdrive/c/Program Files/Microsoft/Web Platform Installer:/cygdrive/c/Program Files/TortoiseSVN/bin:/cygdrive/d/DevRoot/IndustrialMobileAutomation/HandheldDataSetter/ANTLR/batchFile:/cygdrive/c/Program Files (x86)/QuickTime/QTSystem:/cygdrive/d/tmp/tmp_dev_root/android/adt-bundle-windows/sdk/platform-tools:/cygdrive/d/tmp/dev_install_root/Tesseract-OCR:/cygdrive/d/tmp/dev_install_root/jython2.5.3/bin:/cygdrive/d/devinstallroot/gnuarm/bin:/cygdrive/c/Users/CLi/AppData/Roaming/npm:/usr/lib/lapack:/opt/crosstool-ng/bin' CLi@PC-CLI-1 ~/develop/crosstool-ng/crosstool-ng-1.9.3 $ ct-ng help bash: ct-ng: command not found
2.后来自己去看了看,对应位置,的确是有的:
CLi@PC-CLI-1 ~/develop/crosstool-ng/crosstool-ng-1.9.3 $ ls /opt/crosstool-ng/bin/ct-ng /opt/crosstool-ng/bin/ct-ng CLi@PC-CLI-1 ~/develop/crosstool-ng/crosstool-ng-1.9.3 $ /opt/crosstool-ng/bin/ct-ng help This is crosstool-NG version 1.9.3 Copyright (C) 2008 Yann E. MORIN <[email protected]> This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See below for a list of available actions, listed by category: Configuration actions: menuconfig - Update current config using a menu based program oldconfig - Update current config using a provided .config as base extractconfig - Extract to stdout the configuration items from a build.log file piped to stdin saveconfig - Save current config as a preconfigured target show-tuple - Print the tuple of the currently configured toolchain Preconfigured toolchains (#: force number of // jobs): list-samples - prints the list of all samples (for scripting) show-<sample> - show a brief overview of <sample> (list with list-samples) <sample> - preconfigure crosstool-NG with <sample> (list with list-samples) build-all[.#] - Build *all* samples (list with list-samples) and install in ${CT_PREFIX} (which you must set) Build actions (#: force number of // jobs): build[.#] - Build the currently configured toolchain list-steps - List all build steps Clean actions: clean - Remove generated files distclean - Remove generated files, configuration and build directories Distribution actions: wiki-samples - Print a DokuWiki table of samples updatetools - Update the config tools tarball - Build a tarball of the configured toolchain Environement variables (see /opt/crosstool-ng/share/doc/ct-ng-1.9.3/0 - Table of content.txt): STOP=step - Stop the build just after this step (list with list-steps) RESTART=step - Restart the build just before this step (list with list-steps) CT_PREFIX=dir - install samples in dir (see action "build-all", above). V=0|1|2 - 0 => show only human-readable messages (default) 1 => show only the commands being executed 2 => show both Use action "menuconfig" to configure your toolchain Use action "build" to build your toolchain Use action "version" to see the version See "man 1 ct-ng" for some help as well CLi@PC-CLI-1 ~/develop/crosstool-ng/crosstool-ng-1.9.3
3.算了,还是自己手动去更改bashrc吧:
结果,上述动作,的确已经把PATH值添加进入了,但是不是原先的PATH,而是展开后的:
所以改为自己要的:
PATH=$PATH:/opt/crosstool-ng/bin
效果是:
再重启Cygwin脚本,看看是否有效,结果就可以了:
CLi@PC-CLI-1 ~/develop/crosstool-ng $ echo $PATH /usr/local/bin:/usr/bin:/cygdrive/d/tmp/dev_install_root/Python27_x64:/cygdrive/d/tmp/dev_install_root/Python27_x64/Lib/site-packages/PyQt4:/cygdrive/d/tmp/dev_install_root/Perl64/site/bin:/cygdrive/d/tmp/dev_install_root/Perl64/bin:/cygdrive/c/Program Files/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/Program Files (x86)/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files (x86)/Microsoft SQL Server/100/Tools/Binn:/cygdrive/c/Program Files/Microsoft SQL Server/100/Tools/Binn:/cygdrive/c/Program Files/Microsoft SQL Server/100/DTS/Binn:/cygdrive/d/tmp/WordPress/mysql/mysql-5.5.18/MySQL/MySQL Server 5.5/bin:/cygdrive/d/tmp/WordPress/DevRoot/MySQL/MySQL Server 5.5/bin:/cygdrive/d/tmp/WordPress/DevRoot/php-5.3.6-Win32-VC9-x64:/cygdrive/d/tmp/WordPress/DevRoot/php-5.3.6-Win32-VC9-x64/ext:/cygdrive/d/tmp/WordPress/DevRoot/Python27:/cygdrive/c/Program Files (x86)/Common Files/Acronis/SnapAPI:/cygdrive/c/Program Files (x86)/Windows Live/Shared:/cygdrive/c/Program Files/Java/jdk1.7.0_11/bin:/home/CLi/develop/docbook/tools/fop/lib:/home/CLi/develop/docbook/tools/fop:/cygdrive/d/DevInstallRoot/FF/DD_IDE_1.1.2/TOK/BIN:/cygdrive/d/DevInstallRoot/FF/DD_IDE_1.2.0/TOK/BIN:/cygdrive/d/DevRoot/EmbeddedDevelop/trunk/Research/CLI/FF/FBK/develop/tools/develop-tools:/cygdrive/d/tmp/WordPress/DevRoot/Python27/Scripts:/cygdrive/d/tmp/dev_install_root/PostgreSQL/8.3/bin:/cygdrive/d/tmp/dev_install_root/ant/apache-ant-1.8.4/bin:/cygdrive/c/Program Files/nodejs:/cygdrive/c/Program Files/Microsoft/Web Platform Installer:/cygdrive/c/Program Files/TortoiseSVN/bin:/cygdrive/d/DevRoot/IndustrialMobileAutomation/HandheldDataSetter/ANTLR/batchFile:/cygdrive/c/Program Files (x86)/QuickTime/QTSystem:/cygdrive/d/tmp/tmp_dev_root/android/adt-bundle-windows/sdk/platform-tools:/cygdrive/d/tmp/dev_install_root/Tesseract-OCR:/cygdrive/d/tmp/dev_install_root/jython2.5.3/bin:/cygdrive/d/devinstallroot/gnuarm/bin:/cygdrive/c/Users/CLi/AppData/Roaming/npm:/usr/lib/lapack:/opt/crosstool-ng/bin CLi@PC-CLI-1 ~/develop/crosstool-ng $ ct-ng help This is crosstool-NG version 1.9.3 Copyright (C) 2008 Yann E. MORIN <[email protected]> This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See below for a list of available actions, listed by category: Configuration actions: menuconfig - Update current config using a menu based program oldconfig - Update current config using a provided .config as base extractconfig - Extract to stdout the configuration items from a build.log file piped to stdin saveconfig - Save current config as a preconfigured target show-tuple - Print the tuple of the currently configured toolchain Preconfigured toolchains (#: force number of // jobs): list-samples - prints the list of all samples (for scripting) show-<sample> - show a brief overview of <sample> (list with list-samples) <sample> - preconfigure crosstool-NG with <sample> (list with list-samples) build-all[.#] - Build *all* samples (list with list-samples) and install in ${CT_PREFIX} (which you must set) Build actions (#: force number of // jobs): build[.#] - Build the currently configured toolchain list-steps - List all build steps Clean actions: clean - Remove generated files distclean - Remove generated files, configuration and build directories Distribution actions: wiki-samples - Print a DokuWiki table of samples updatetools - Update the config tools tarball - Build a tarball of the configured toolchain Environement variables (see /opt/crosstool-ng/share/doc/ct-ng-1.9.3/0 - Table of content.txt): STOP=step - Stop the build just after this step (list with list-steps) RESTART=step - Restart the build just before this step (list with list-steps) CT_PREFIX=dir - install samples in dir (see action "build-all", above). V=0|1|2 - 0 => show only human-readable messages (default) 1 => show only the commands being executed 2 => show both Use action "menuconfig" to configure your toolchain Use action "build" to build your toolchain Use action "version" to see the version See "man 1 ct-ng" for some help as well CLi@PC-CLI-1 ~/develop/crosstool-ng $
4.此处,echo内容到.bashrc中,其中的$PATH,会自动展开为当前的值,而不是针对原先的字符串,原样导入的。
所以,再去研究研究,结果如下:
CLi@PC-CLI-1 ~/develop/crosstool-ng $ echo "PATH=$PATH:/just/test" >> ~/.bashrc CLi@PC-CLI-1 ~/develop/crosstool-ng $ source ~/.bashrc bash: /home/CLi/.bashrc: line 200: syntax error near unexpected token `(' bash: /home/CLi/.bashrc: line 200: `PATH=xxxxxx:/opt/crosstool-ng/bin:/just/test' CLi@PC-CLI-1 ~/develop/crosstool-ng $ echo "PATH=$$PATH:/just/test/2" >> ~/.bashrc CLi@PC-CLI-1 ~/develop/crosstool-ng $ source ~/.bashrc bash: /home/CLi/.bashrc: line 200: syntax error near unexpected token `(' bash: /home/CLi/.bashrc: line 200: `PATH=xxxxxx:/opt/crosstool-ng/bin:/just/test' CLi@PC-CLI-1 ~/develop/crosstool-ng $ echo "PATH=\$PATH:/just/test/3" >> ~/.bashrc CLi@PC-CLI-1 ~/develop/crosstool-ng $ source ~/.bashrc bash: /home/CLi/.bashrc: line 200: syntax error near unexpected token `(' bash: /home/CLi/.bashrc: line 200: `PATH=xxxxxx:/opt/crosstool-ng/bin:/just/test' CLi@PC-CLI-1 ~/develop/crosstool-ng $
对应的.bashrc文件内容为:
PATH=$PATH:/opt/crosstool-ng/bin PATH=xxxxxx:/just/test PATH=9468PATH:/just/test/2 PATH=$PATH:/just/test/3
很明显,结果是:
【总结】
如果通过echo字符串到文件(.bashrc)中,则其中包括环境变量的话,即$XXX的形式,以$PATH为例,则:
- 直接用:"xxx$PATHxxx",则其会自动展开$PATH这个环境变量的值,然后输出到对应的文件中
- 如果想要保留$PATH值本身,则需要用\$PATH,比如:
echo "PATH=\$PATH:/new/added/some/path" >> ~/.bashrc
转载请注明:在路上 » 【已解决】Cygwin中安装完crosstool-ng后,运行ct-ng help出错:bash: ct-ng: command not found