1. 程式人生 > >make時提示GCC找不到,但又能查到版本問題

make時提示GCC找不到,但又能查到版本問題

[email protected]:~/linux/tiny6410/linux-2.6.38$ make
make: gcc: Command not found
  HOSTCC  scripts/kconfig/conf.o
/bin/sh: 1: gcc: not found
make[2]: *** [scripts/kconfig/conf.o] Error 127
make[1]: *** [silentoldconfig] Error 2
make: *** No rule to make target `include/config/auto.conf', needed by `include/config/kernel.release'.  Stop.
提示/bin/sh: 1: gcc: not found,但是執行命令arm-linux-gcc -v後
[email protected]
:~/linux/tiny6410/linux-2.6.38$ arm-linux-gcc -v
Using built-in specs.
COLLECT_GCC=arm-linux-gcc
COLLECT_LTO_WRAPPER=/home/daron/linux/opt/FriendlyARM/toolschain/4.5.1/bin/../libexec/gcc/arm-none-linux-gnueabi/4.5.1/lto-wrapper
Target: arm-none-linux-gnueabi
Configured with: /work/toolchain/build/src/gcc-4.5.1/configure --build=i686-build_pc-linux-gnu --host=i686-build_pc-linux-gnu --target=arm-none-linux-gnueabi --prefix=/opt/FriendlyARM/toolschain/4.5.1 --with-sysroot=/opt/FriendlyARM/toolschain/4.5.1/arm-none-linux-gnueabi/sys-root --enable-languages=c,c++ --disable-multilib --with-cpu=arm1176jzf-s --with-tune=arm1176jzf-s --with-fpu=vfp --with-float=softfp --with-pkgversion=ctng-1.8.1-FA --with-bugurl=http://www.arm9.net/ --disable-sjlj-exceptions --enable-__cxa_atexit --disable-libmudflap --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-gmp=/work/toolchain/build/arm-none-linux-gnueabi/build/static --with-mpfr=/work/toolchain/build/arm-none-linux-gnueabi/build/static --with-ppl=/work/toolchain/build/arm-none-linux-gnueabi/build/static --with-cloog=/work/toolchain/build/arm-none-linux-gnueabi/build/static --with-mpc=/work/toolchain/build/arm-none-linux-gnueabi/build/static --with-libelf=/work/toolchain/build/arm-none-linux-gnueabi/build/static --enable-threads=posix --with-local-prefix=/opt/FriendlyARM/toolschain/4.5.1/arm-none-linux-gnueabi/sys-root --disable-nls --enable-symvers=gnu --enable-c99 --enable-long-long
Thread model: posix
gcc version 4.5.1 (ctng-1.8.1-FA) 又能查到gcc的版本資訊。
[email protected]
:~/linux/tiny6410/linux-2.6.38# cat /proc/version
Linux version 3.13.0-32-generic ([email protected]) (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) ) #57~precise1-Ubuntu SMP Tue Jul 15 03:51:20 UTC 2014 [email protected]:~/linux/tiny6410/linux-2.6.38# gcc --version
The program 'gcc' can be found in the following packages:
 * gcc
 * pentium-builder
Try: apt-get install <selected package>
即使重新安裝gcc,也不能解決此問題。解決辦法如下
解決辦法1: sudo apt-get install build-essential
[email protected]
:~/linux# sudo apt-get install build-essential
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following package was automatically installed and is no longer required:
  liblzo2-2
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  g++ gcc
Suggested packages:
  g++-multilib gcc-multilib autoconf automake1.9 libtool flex bison gcc-doc
The following NEW packages will be installed:
  build-essential g++ gcc
0 upgraded, 3 newly installed, 0 to remove and 322 not upgraded.
Need to get 5,114 B/12.4 kB of archives.
After this operation, 115 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://cn.archive.ubuntu.com/ubuntu/ precise/main gcc amd64 4:4.6.3-1ubuntu5 [5,114 B]
Fetched 5,114 B in 3s (1,699 B/s)
Selecting previously unselected package gcc.
(Reading database ... 151853 files and directories currently installed.)
Unpacking gcc (from .../gcc_4%3a4.6.3-1ubuntu5_amd64.deb) ...
Selecting previously unselected package g++.
Unpacking g++ (from .../g++_4%3a4.6.3-1ubuntu5_amd64.deb) ...
Selecting previously unselected package build-essential.
Unpacking build-essential (from .../build-essential_11.5ubuntu2.1_amd64.deb) ...
Processing triggers for man-db ...
Setting up gcc (4:4.6.3-1ubuntu5) ...
Setting up g++ (4:4.6.3-1ubuntu5) ...
update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode.
Setting up build-essential (11.5ubuntu2.1) ... 問題解決,再用gcc -v 查詢一下gcc的版本,可以找到了,
在make或make menuconfig也沒問題了 [email protected]:~/linux/tiny6410/linux-2.6.38# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)
以下在網上找的解決辦法,沒什麼卵用,並不適合我這個問題,讓我很是糾結,為什麼這個不行。 後來發現原因如下:
exportPATH=$PATH:/usr/local/arm/4.4.3/bin
是設定當前使用者的PATH,而sudo執行make的時候,使用的是超級使用者許可權,那也就使用了超級使用者的PATH(但是這個PATH裡,並沒有/usr/local/arm/4.4.3/bin)
 
解決方法:
1.先開啟一個超級使用者許可權的shell:
     命令:sudo –s
2.在當前shell下,設定環境變數:
      命令:gedit /etc/profile
在檔案末端加上 export PATH=$PATH:/usr/local/arm/4.4.3/bin,並儲存。
3. 執行source /etc/profile    這是避免重新啟動ubuntu而又使剛剛修改的環境變數生效的方法。
 
再進入到/opt/FriendlyARM/mini2440/linux-2.6.32.2  目錄,執行make zImage(有可能加sudo),
arm-linux-gcc了,可以編譯了。