【已解决】Ubuntu下编译xmlrpc出错:gcc: error trying to exec ‘cc1’: execvp: No such file or directory

【问题】

折腾:

【记录】Ubuntu下用arm-xscale-linux-gnueabi交叉编译xmlrpc

期间,用gcc去编译,结果出错:

crifan@ubuntu:xmlrpc-c-1.06.31$ file lib/expat/gennmtab/gennmtab
lib/expat/gennmtab/gennmtab: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.19, not stripped
crifan@ubuntu:xmlrpc-c-1.06.31$ rm lib/expat/genmtab/genmtab
rm: cannot remove ‘lib/expat/genmtab/genmtab’: No such file or directory
crifan@ubuntu:xmlrpc-c-1.06.31$ rm lib/expat/gennmtab/gennmtab
crifan@ubuntu:xmlrpc-c-1.06.31$ gcc -I. lib/expat/gennmtab/gennmtab.c -o lib/expat/gennmtab/gennmtab
gcc: error trying to exec 'cc1': execvp: No such file or directory
crifan@ubuntu:xmlrpc-c-1.06.31$ 

【解决过程】

1.参考:

Can not compile any C code under Xubuntu

去试试:

crifan@ubuntu:xmlrpc-c-1.06.31$ sudo apt-get purge gcc
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  g++-4.7 libstdc++6-4.7-dev
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  dkms* g++* gcc* open-vm-dkms*
0 upgraded, 0 newly installed, 4 to remove and 202 not upgraded.
After this operation, 6,256 kB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 158315 files and directories currently installed.)
Removing open-vm-dkms ...

-------- Uninstall Beginning --------
Module:  open-vm-tools
Version: 2012.12.26
Kernel:  3.8.0-19-generic (i686)
-------------------------------------

Status: Before uninstall, this module version was ACTIVE on this kernel.

vmblock.ko:
 - Uninstallation
   - Deleting from: /lib/modules/3.8.0-19-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.


vmci.ko:
 - Uninstallation
   - Deleting from: /lib/modules/3.8.0-19-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.


vmhgfs.ko:
 - Uninstallation
   - Deleting from: /lib/modules/3.8.0-19-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.


vmxnet.ko:
 - Uninstallation
   - Deleting from: /lib/modules/3.8.0-19-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.


vsock.ko:
 - Uninstallation
   - Deleting from: /lib/modules/3.8.0-19-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

depmod....

DKMS: uninstall completed.

------------------------------
Deleting module version: 2012.12.26
completely from the DKMS tree.
------------------------------
Done.
Removing dkms ...
Purging configuration files for dkms ...
Removing g++ ...
Removing gcc ...
Processing triggers for man-db ...
crifan@ubuntu:xmlrpc-c-1.06.31$ sudo apt-get update
Hit http://extras.ubuntu.com raring Release.gpg
Hit http://extras.ubuntu.com raring Release   
Hit http://extras.ubuntu.com raring/main Sources
Hit http://extras.ubuntu.com raring/main i386 Packages
Ign http://extras.ubuntu.com raring/main Translation-en_US
Ign http://extras.ubuntu.com raring/main Translation-en
Hit http://mirrors.163.com precise Release.gpg
Hit http://mirrors.163.com precise-security Release.gpg
Hit http://mirrors.163.com precise-updates Release.gpg
Hit http://mirrors.163.com precise-proposed Release.gpg
Hit http://mirrors.163.com precise-backports Release.gpg
Hit http://mirrors.163.com raring Release.gpg
Hit http://mirrors.163.com raring-updates Release.gpg
Hit http://mirrors.163.com raring-backports Release.gpg
Hit http://mirrors.163.com raring-security Release.gpg
Hit http://mirrors.163.com precise Release
Hit http://mirrors.163.com precise-security Release
Hit http://mirrors.163.com precise-updates Release
Hit http://mirrors.163.com precise-proposed Release
Hit http://mirrors.163.com precise-backports Release
Hit http://mirrors.163.com raring Release       
Hit http://mirrors.163.com raring-updates Release
Hit http://mirrors.163.com raring-backports Release
Hit http://mirrors.163.com raring-security Release
Hit http://mirrors.163.com precise/main Sources 
Hit http://mirrors.163.com precise/restricted Sources
Hit http://mirrors.163.com precise/universe Sources
Hit http://mirrors.163.com precise/multiverse Sources
Hit http://mirrors.163.com precise/main i386 Packages
Hit http://mirrors.163.com precise/restricted i386 Packages
Hit http://mirrors.163.com precise/universe i386 Packages
Hit http://mirrors.163.com precise/multiverse i386 Packages
Hit http://mirrors.163.com precise/main Translation-en
Hit http://mirrors.163.com precise/multiverse Translation-en
Hit http://mirrors.163.com precise/restricted Translation-en
Hit http://mirrors.163.com precise/universe Translation-en
Hit http://mirrors.163.com precise-security/main Sources
Hit http://mirrors.163.com precise-security/restricted Sources
Hit http://mirrors.163.com precise-security/universe Sources
Hit http://mirrors.163.com precise-security/multiverse Sources
Hit http://mirrors.163.com precise-security/main i386 Packages
Hit http://mirrors.163.com precise-security/restricted i386 Packages
Hit http://mirrors.163.com precise-security/universe i386 Packages
Hit http://mirrors.163.com precise-security/multiverse i386 Packages
Hit http://mirrors.163.com precise-security/main Translation-en
Hit http://mirrors.163.com precise-security/multiverse Translation-en
Hit http://mirrors.163.com precise-security/restricted Translation-en
Hit http://mirrors.163.com precise-security/universe Translation-en
Hit http://mirrors.163.com precise-updates/main Sources
Hit http://mirrors.163.com precise-updates/restricted Sources
Hit http://mirrors.163.com precise-updates/universe Sources
Hit http://mirrors.163.com precise-updates/multiverse Sources
Hit http://mirrors.163.com precise-updates/main i386 Packages
Hit http://mirrors.163.com precise-updates/restricted i386 Packages
Hit http://mirrors.163.com precise-updates/universe i386 Packages
Hit http://mirrors.163.com precise-updates/multiverse i386 Packages
Hit http://mirrors.163.com precise-updates/main Translation-en
Hit http://mirrors.163.com precise-updates/multiverse Translation-en
Hit http://mirrors.163.com precise-updates/restricted Translation-en
Hit http://mirrors.163.com precise-updates/universe Translation-en
Hit http://mirrors.163.com precise-proposed/main Sources
Hit http://mirrors.163.com precise-proposed/restricted Sources
Hit http://mirrors.163.com precise-proposed/universe Sources
Hit http://mirrors.163.com precise-proposed/multiverse Sources
Hit http://mirrors.163.com precise-proposed/main i386 Packages
Hit http://mirrors.163.com precise-proposed/restricted i386 Packages
Hit http://mirrors.163.com precise-proposed/universe i386 Packages
Hit http://mirrors.163.com precise-proposed/multiverse i386 Packages
Hit http://mirrors.163.com precise-proposed/main Translation-en
Hit http://mirrors.163.com precise-proposed/multiverse Translation-en
Hit http://mirrors.163.com precise-proposed/restricted Translation-en
Hit http://mirrors.163.com precise-proposed/universe Translation-en
Hit http://mirrors.163.com precise-backports/main Sources
Hit http://mirrors.163.com precise-backports/restricted Sources
Hit http://mirrors.163.com precise-backports/universe Sources
Hit http://mirrors.163.com precise-backports/multiverse Sources
Hit http://mirrors.163.com precise-backports/main i386 Packages
Hit http://mirrors.163.com precise-backports/restricted i386 Packages
Hit http://mirrors.163.com precise-backports/universe i386 Packages
Hit http://mirrors.163.com precise-backports/multiverse i386 Packages
Hit http://mirrors.163.com precise-backports/main Translation-en
Hit http://mirrors.163.com precise-backports/multiverse Translation-en
Hit http://mirrors.163.com precise-backports/restricted Translation-en
Hit http://mirrors.163.com precise-backports/universe Translation-en
Hit http://mirrors.163.com raring/main Sources
Hit http://mirrors.163.com raring/restricted Sources
Hit http://mirrors.163.com raring/universe Sources
Hit http://mirrors.163.com raring/multiverse Sources
Hit http://mirrors.163.com raring/main i386 Packages
Hit http://mirrors.163.com raring/restricted i386 Packages
Hit http://mirrors.163.com raring/universe i386 Packages
Hit http://mirrors.163.com raring/multiverse i386 Packages
Hit http://mirrors.163.com raring/main Translation-en
Hit http://mirrors.163.com raring/multiverse Translation-en
Hit http://mirrors.163.com raring/restricted Translation-en
Hit http://mirrors.163.com raring/universe Translation-en
Hit http://mirrors.163.com raring-updates/main Sources
Hit http://mirrors.163.com raring-updates/restricted Sources
Hit http://mirrors.163.com raring-updates/universe Sources
Hit http://mirrors.163.com raring-updates/multiverse Sources
Hit http://mirrors.163.com raring-updates/main i386 Packages
Hit http://mirrors.163.com raring-updates/restricted i386 Packages
Hit http://mirrors.163.com raring-updates/universe i386 Packages
Hit http://mirrors.163.com raring-updates/multiverse i386 Packages
Hit http://mirrors.163.com raring-updates/main Translation-en
Hit http://mirrors.163.com raring-updates/multiverse Translation-en
Hit http://mirrors.163.com raring-updates/restricted Translation-en
Hit http://mirrors.163.com raring-updates/universe Translation-en
Hit http://mirrors.163.com raring-backports/main Sources
Hit http://mirrors.163.com raring-backports/restricted Sources
Hit http://mirrors.163.com raring-backports/universe Sources
Hit http://mirrors.163.com raring-backports/multiverse Sources
Hit http://mirrors.163.com raring-backports/main i386 Packages
Hit http://mirrors.163.com raring-backports/restricted i386 Packages
Hit http://mirrors.163.com raring-backports/universe i386 Packages
Hit http://mirrors.163.com raring-backports/multiverse i386 Packages
Hit http://mirrors.163.com raring-backports/main Translation-en
Hit http://mirrors.163.com raring-backports/multiverse Translation-en
Hit http://mirrors.163.com raring-backports/restricted Translation-en
Hit http://mirrors.163.com raring-backports/universe Translation-en
Hit http://mirrors.163.com raring-security/main Sources
Hit http://mirrors.163.com raring-security/restricted Sources
Hit http://mirrors.163.com raring-security/universe Sources
Hit http://mirrors.163.com raring-security/multiverse Sources
Hit http://mirrors.163.com raring-security/main i386 Packages
Hit http://mirrors.163.com raring-security/restricted i386 Packages
Hit http://mirrors.163.com raring-security/universe i386 Packages
Hit http://mirrors.163.com raring-security/multiverse i386 Packages
Hit http://mirrors.163.com raring-security/main Translation-en
Hit http://mirrors.163.com raring-security/multiverse Translation-en
Hit http://mirrors.163.com raring-security/restricted Translation-en
Hit http://mirrors.163.com raring-security/universe Translation-en
Ign http://mirrors.163.com precise/main Translation-en_US
Ign http://mirrors.163.com precise/multiverse Translation-en_US
Ign http://mirrors.163.com precise/restricted Translation-en_US
Ign http://mirrors.163.com precise/universe Translation-en_US
Ign http://mirrors.163.com precise-security/main Translation-en_US
Ign http://mirrors.163.com precise-security/multiverse Translation-en_US
Ign http://mirrors.163.com precise-security/restricted Translation-en_US
Ign http://mirrors.163.com precise-security/universe Translation-en_US
Ign http://mirrors.163.com precise-updates/main Translation-en_US
Ign http://mirrors.163.com precise-updates/multiverse Translation-en_US
Ign http://mirrors.163.com precise-updates/restricted Translation-en_US
Ign http://mirrors.163.com precise-updates/universe Translation-en_US
Ign http://mirrors.163.com precise-proposed/main Translation-en_US
Ign http://mirrors.163.com precise-proposed/multiverse Translation-en_US
Ign http://mirrors.163.com precise-proposed/restricted Translation-en_US
Ign http://mirrors.163.com precise-proposed/universe Translation-en_US
Ign http://mirrors.163.com precise-backports/main Translation-en_US
Ign http://mirrors.163.com precise-backports/multiverse Translation-en_US
Ign http://mirrors.163.com precise-backports/restricted Translation-en_US
Ign http://mirrors.163.com precise-backports/universe Translation-en_US
Ign http://mirrors.163.com raring/main Translation-en_US
Ign http://mirrors.163.com raring/multiverse Translation-en_US
Ign http://mirrors.163.com raring/restricted Translation-en_US
Ign http://mirrors.163.com raring/universe Translation-en_US
Ign http://mirrors.163.com raring-updates/main Translation-en_US
Ign http://mirrors.163.com raring-updates/multiverse Translation-en_US
Ign http://mirrors.163.com raring-updates/restricted Translation-en_US
Ign http://mirrors.163.com raring-updates/universe Translation-en_US
Ign http://mirrors.163.com raring-backports/main Translation-en_US
Ign http://mirrors.163.com raring-backports/multiverse Translation-en_US
Ign http://mirrors.163.com raring-backports/restricted Translation-en_US
Ign http://mirrors.163.com raring-backports/universe Translation-en_US
Ign http://mirrors.163.com raring-security/main Translation-en_US
Ign http://mirrors.163.com raring-security/multiverse Translation-en_US
Ign http://mirrors.163.com raring-security/restricted Translation-en_US
Ign http://mirrors.163.com raring-security/universe Translation-en_US
Reading package lists... Done
crifan@ubuntu:xmlrpc-c-1.06.31$ sudo apt-get install gcc
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  fakeroot g++-4.7 libstdc++6-4.7-dev
Use 'apt-get autoremove' to remove them.
Suggested packages:
  gcc-multilib automake1.9 gcc-doc
The following NEW packages will be installed:
  gcc
0 upgraded, 1 newly installed, 0 to remove and 202 not upgraded.
Need to get 5,130 B of archives.
After this operation, 42.0 kB of additional disk space will be used.
Get:1 http://mirrors.163.com/ubuntu/ raring/main gcc i386 4:4.7.3-1ubuntu10 [5,130 B]
Fetched 5,130 B in 14s (364 B/s)
Selecting previously unselected package gcc.
(Reading database ... 157578 files and directories currently installed.)
Unpacking gcc (from .../gcc_4%3a4.7.3-1ubuntu10_i386.deb) ...
Processing triggers for man-db ...
Setting up gcc (4:4.7.3-1ubuntu10) ...
crifan@ubuntu:xmlrpc-c-1.06.31$ 

2.然后看看是否已解决问题,结果问题依旧。

3.参考:

gcc-4.6: error trying to exec ‘cc1’

去试试:

crifan@ubuntu:xmlrpc-c-1.06.31$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
Target: arm-xscale-linux-gnueabi
Configured with: /home/crifan/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/gcc-4.6.0/configure --build=i686-build_pc-linux-gnu --host=i686-build_pc-linux-gnu --target=arm-xscale-linux-gnueabi --prefix=/home/crifan/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi --with-sysroot=/home/crifan/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi/arm-xscale-linux-gnueabi/sysroot --enable-languages=c,c++ --with-arch=armv5te --with-cpu=xscale --with-tune=xscale --with-float=softfp --with-pkgversion='crosstool-NG 1.18.0' --disable-__cxa_atexit --disable-libmudflap --disable-libgomp --disable-libssp --disable-libquadmath --disable-libquadmath-support --with-gmp=/home/crifan/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-xscale-linux-gnueabi/buildtools --with-mpfr=/home/crifan/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-xscale-linux-gnueabi/buildtools --with-mpc=/home/crifan/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-xscale-linux-gnueabi/buildtools --with-ppl=no --with-cloog=no --with-libelf=no --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --enable-threads=posix --enable-target-optspace --disable-nls --disable-multilib --with-local-prefix=/home/crifan/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi/arm-xscale-linux-gnueabi/sysroot --enable-c99 --enable-long-long
Thread model: posix
gcc version 4.6.0 (crosstool-NG 1.18.0) 
crifan@ubuntu:xmlrpc-c-1.06.31$ ls /usr/lib/gcc/i686-linux-gnu/4.7
4.7/   4.7.3/ 
crifan@ubuntu:xmlrpc-c-1.06.31$ ls /usr/lib/gcc/i686-linux-gnu/4.7^C
crifan@ubuntu:xmlrpc-c-1.06.31$ 

很明显,此处,是不小心,把交叉工具链中的gcc的路径,加到环境变量中,导致x86的gcc,变成了xscale的gcc了。

4.所以,去看看自己的.bashrc中的PATH环境变量。

把PATH放到前面去:

#PATH=/opt/crosstool-ng/bin:/opt/crosscompile/xscale/gcc-4.6.0-glibc-2.9/bin:$PATH
PATH=$PATH:/opt/crosstool-ng/bin:/opt/crosscompile/xscale/gcc-4.6.0-glibc-2.9/bin

 

bashrc makesure path is first

这样,应该就可以先找到x86的gcc,而不是arm-xscale-linux-gnueabi的gcc了。

再source一下,结果竟然还是不行:

crifan@ubuntu:xmlrpc-c-1.06.31$ gedit ~/.bashrc
crifan@ubuntu:xmlrpc-c-1.06.31$ source ~/.bashrc
crifan@ubuntu:xmlrpc-c-1.06.31$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
Target: arm-xscale-linux-gnueabi
Configured with: /home/crifan/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/gcc-4.6.0/configure --build=i686-build_pc-linux-gnu --host=i686-build_pc-linux-gnu --target=arm-xscale-linux-gnueabi --prefix=/home/crifan/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi --with-sysroot=/home/crifan/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi/arm-xscale-linux-gnueabi/sysroot --enable-languages=c,c++ --with-arch=armv5te --with-cpu=xscale --with-tune=xscale --with-float=softfp --with-pkgversion='crosstool-NG 1.18.0' --disable-__cxa_atexit --disable-libmudflap --disable-libgomp --disable-libssp --disable-libquadmath --disable-libquadmath-support --with-gmp=/home/crifan/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-xscale-linux-gnueabi/buildtools --with-mpfr=/home/crifan/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-xscale-linux-gnueabi/buildtools --with-mpc=/home/crifan/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-xscale-linux-gnueabi/buildtools --with-ppl=no --with-cloog=no --with-libelf=no --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --enable-threads=posix --enable-target-optspace --disable-nls --disable-multilib --with-local-prefix=/home/crifan/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi/arm-xscale-linux-gnueabi/sysroot --enable-c99 --enable-long-long
Thread model: posix
gcc version 4.6.0 (crosstool-NG 1.18.0) 
crifan@ubuntu:xmlrpc-c-1.06.31$ ls /usr/bin/g
Display all 152 possibilities? (y or n)
crifan@ubuntu:xmlrpc-c-1.06.31$ ls /usr/bin/gcc
gcc             gcc-4.7         gcc-ar-4.7      gcc-nm-4.7      gcc-ranlib-4.7  
crifan@ubuntu:xmlrpc-c-1.06.31$ ls /usr/bin/gcc
/usr/bin/gcc
crifan@ubuntu:xmlrpc-c-1.06.31$  /usr/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.7/lto-wrapper
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.7.3-1ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --with-system-zlib --enable-objc-gc --enable-targets=all --with-cloog --enable-cloog-backend=ppl --disable-cloog-version-check --disable-ppl-version-check --enable-multiarch --disable-werror --with-arch-32=i686 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-1ubuntu1) 
crifan@ubuntu:xmlrpc-c-1.06.31$ 

真是有点诡异。

5.重启终端后,再试试,果然可以了:

crifan@ubuntu:crosstool-ng-1.18.0_build$ cd /home/crifan/develop/crosscompile/xmlrpc/xmlrpc-c-1.06.31
crifan@ubuntu:xmlrpc-c-1.06.31$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.7/lto-wrapper
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.7.3-1ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --with-system-zlib --enable-objc-gc --enable-targets=all --with-cloog --enable-cloog-backend=ppl --disable-cloog-version-check --disable-ppl-version-check --enable-multiarch --disable-werror --with-arch-32=i686 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-1ubuntu1) 
crifan@ubuntu:xmlrpc-c-1.06.31$ 

6,然后就可以继续去执行gcc了,就可以了:

crifan@ubuntu:xmlrpc-c-1.06.31$ gcc -I. lib/expat/gennmtab/gennmtab.c -o lib/expat/gennmtab/gennmtab
crifan@ubuntu:xmlrpc-c-1.06.31$ file lib/expat/gennmtab/gennmtab
lib/expat/gennmtab/gennmtab: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x0ffeed5fa074553c65c6e69cc84349d71c7e95a7, not stripped
crifan@ubuntu:xmlrpc-c-1.06.31$ 

 

【总结】

去用gcc时,出现此处错误:

gcc: error trying to exec ‘cc1’: execvp: No such file or directory

我此处的问题的原因是:

之前在编译完毕xscale的交叉编译器后,将其路径加到PATH中时,不小心,加到$PATH之前了,导致系统去(通过PATH而)找到的(第一个)gcc,不是x86的gcc:

crifan@ubuntu:xmlrpc-c-1.06.31$ /usr/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.7/lto-wrapper
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.7.3-1ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --with-system-zlib --enable-objc-gc --enable-targets=all --with-cloog --enable-cloog-backend=ppl --disable-cloog-version-check --disable-ppl-version-check --enable-multiarch --disable-werror --with-arch-32=i686 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-1ubuntu1) 

而是xscale的gcc,即这个:

crifan@ubuntu:xmlrpc-c-1.06.31$ ls /home/crifan/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi/arm-xscale-linux-gnueabi/bin
ar  as  c++  g++  gcc  ld  ld.bfd  nm  objcopy  objdump  ranlib  strip
crifan@ubuntu:xmlrpc-c-1.06.31$ /home/crifan/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi/arm-xscale-linux-gnueabi/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/home/crifan/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi/arm-xscale-linux-gnueabi/bin/gcc
Target: arm-xscale-linux-gnueabi
Configured with: /home/crifan/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/src/gcc-4.6.0/configure --build=i686-build_pc-linux-gnu --host=i686-build_pc-linux-gnu --target=arm-xscale-linux-gnueabi --prefix=/home/crifan/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi --with-sysroot=/home/crifan/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi/arm-xscale-linux-gnueabi/sysroot --enable-languages=c,c++ --with-arch=armv5te --with-cpu=xscale --with-tune=xscale --with-float=softfp --with-pkgversion='crosstool-NG 1.18.0' --disable-__cxa_atexit --disable-libmudflap --disable-libgomp --disable-libssp --disable-libquadmath --disable-libquadmath-support --with-gmp=/home/crifan/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-xscale-linux-gnueabi/buildtools --with-mpfr=/home/crifan/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-xscale-linux-gnueabi/buildtools --with-mpc=/home/crifan/develop/crosstool-ng/crosstool-ng-1.18.0_build/.build/arm-xscale-linux-gnueabi/buildtools --with-ppl=no --with-cloog=no --with-libelf=no --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --enable-threads=posix --enable-target-optspace --disable-nls --disable-multilib --with-local-prefix=/home/crifan/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi/arm-xscale-linux-gnueabi/sysroot --enable-c99 --enable-long-long
Thread model: posix
gcc version 4.6.0 (crosstool-NG 1.18.0) 
crifan@ubuntu:xmlrpc-c-1.06.31$ 

所以解决办法是:

修改自己的.bashrc,确保其中交叉编译器的路径,是放在PATH之后的,比如:

#PATH=/opt/crosstool-ng/bin:/opt/crosscompile/xscale/gcc-4.6.0-glibc-2.9/bin:$PATH
PATH=$PATH:/opt/crosstool-ng/bin:/opt/crosscompile/xscale/gcc-4.6.0-glibc-2.9/bin

这样,就确保了,系统寻找gcc等工具时,找到的是此处的x86的,而不是xscale的。



发表评论

电子邮件地址不会被公开。 必填项已用*标注

无觅相关文章插件,快速提升流量