Q & A for linux

Q:gcc: error trying to exec 'cc1plus': execvp: 没有该文件或目录

A:

> gcc: error trying to exec 'cc1plus': execvp: 没有该文件或目录

出错的时候要注意看信息提示,你的问题是没有 cc1pluc
表明你的系统缺少 g++ 包。

$sudo aptitude install g++

Q:undefined reference to `__gxx_personality_v0

A:注意使用C++对象的程序必须使用g++链接(link),以提供对应的C++库。如果用gcc链接,则会导致"undefined reference"之类的错误。

Undefined references to internal run-time library functions, such as__gxx_personality_v0, are also a symptom of linking C++ objectfiles with gcc instead of g++. Linking the same objectfile with g++ supplies all the necessary C++ libraries and willproduce a working executable.

有意思的是gcc如果检测到文件的后缀是c++文件,则可以对其进行编译,但却不能链接。
因此,为防止这类错误,对于C++程序用g++,c程序用gcc。
posted @ 2009-11-13 20:07  行走的麦哥  阅读(565)  评论(0)    收藏  举报