[问题]gcc出了个很奇怪的问题

C、C++和Java语言
回复
头像
zhujie
帖子: 22
注册时间: 2007-05-06 8:59
送出感谢: 0
接收感谢: 0
联系:

[问题]gcc出了个很奇怪的问题

#1

帖子 zhujie » 2008-08-22 0:52

第一次出问题的时候,我没摸着头脑,换成下面的程序

代码: 全选

#include <stdio.h>
int
main(void)
{
  printf("Hello, world!\n");
  return 0;
}

代码: 全选

[daryl@localhost Desktop]$ gcc a.cpp
/tmp/ccc6xabK.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
[daryl@localhost Desktop]$ 
第一次碰到这种问题,一开始我以为是先前装的ICC把环境变量给搞乱了

代码: 全选

[daryl@localhost Desktop]$ env
MKLROOT=/opt/intel/mkl/10.0.4.023
MANPATH=/opt/intel/mkl/10.0.4.023/man:/opt/intel/cc/10.1.015/man:/usr/kerberos/man:/usr/local/share/man:/usr/share/man/en:/usr/share/man:/opt/intel/cc/10.1.015/man
SSH_AGENT_PID=23449
HOSTNAME=localhost.localdomain
INTEL_LICENSE_FILE=/opt/intel/cc/10.1.015/licenses:/opt/intel/licenses:/home/daryl/intel/licenses:/Users/Shared/Library/Application Support/Intel/Licenses
DESKTOP_STARTUP_ID=
TERM=xterm
SHELL=/bin/bash
HISTSIZE=1000
LIBRARY_PATH=/opt/intel/mkl/10.0.4.023/lib/32
GTK_RC_FILES=/etc/gtk/gtkrc:/home/daryl/.gtkrc-1.2-gnome2
WINDOWID=48234578
FPATH=/opt/intel/mkl/10.0.4.023/include
USER=daryl
LD_LIBRARY_PATH=/opt/intel/cc/10.1.015/lib:/opt/intel/mkl/10.0.4.023/lib/32
LS_COLORS=no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:
GNOME_KEYRING_SOCKET=/tmp/keyring-aMh4RM/socket
CPATH=/opt/intel/mkl/10.0.4.023/include
SSH_AUTH_SOCK=/tmp/ssh-AUASO23412/agent.23412
SESSION_MANAGER=local/localhost.localdomain:/tmp/.ICE-unix/23412
USERNAME=daryl
NLSPATH=/opt/intel/cc/10.1.015/lib/locale/en_US
MAIL=/var/spool/mail/daryl
PATH=/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/daryl/bin:/opt/intel/cc/10.1.015/bin
DESKTOP_SESSION=default
QT_IM_MODULE=scim
GDM_XSERVER_LOCATION=local
INPUTRC=/etc/inputrc
PWD=/home/daryl/Desktop
XMODIFIERS=@im=SCIM
LANG=en_US.UTF-8
GDMSESSION=default
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
SHLVL=2
HOME=/home/daryl
GNOME_DESKTOP_SESSION_ID=Default
DYLD_LIBRARY_PATH=/opt/intel/cc/10.1.015/lib
LOGNAME=daryl
CVS_RSH=ssh
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-SDpYvPPVdf,guid=5808ae48ce4bcc8e318292fdee7c5900
LESSOPEN=|/usr/bin/lesspipe.sh %s
DISPLAY=:0.0
INCLUDE=/opt/intel/mkl/10.0.4.023/include
GTK_IM_MODULE=scim-bridge
G_BROKEN_FILENAMES=1
COLORTERM=gnome-terminal
XAUTHORITY=/tmp/.gdmGV5ZFU
OLDPWD=/home/daryl
_=/usr/bin/env
[daryl@localhost Desktop]$ 
但是又不像,这部分我处理得很仔细

代码: 全选

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
	. ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
##############################################################
if [ -z "${PATH}" ]
then
    PATH="/opt/intel/cc/10.1.015/bin"; export PATH
else
    PATH="${PATH}:/opt/intel/cc/10.1.015/bin"; export PATH
fi

if [ -z "${LD_LIBRARY_PATH}" ]
then
    LD_LIBRARY_PATH="/opt/intel/cc/10.1.015/lib"; export LD_LIBRARY_PATH
else
    LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/opt/intel/cc/10.1.015/lib"; export LD_LIBRARY_PATH
fi

# DYLD_LIBRARY_PATH is used on MAC OS*
if [ -z "${DYLD_LIBRARY_PATH}" ]
then
    DYLD_LIBRARY_PATH="/opt/intel/cc/10.1.015/lib"; export DYLD_LIBRARY_PATH
else
    DYLD_LIBRARY_PATH="${DYLD_LIBRARY_PATH}:/opt/intel/cc/10.1.015/lib"; export DYLD_LIBRARY_PATH
fi

if [ -z "${NLSPATH}" ] 
then
    NLSPATH="/opt/intel/cc/10.1.015/lib/locale/en_US"; export NLSPATH
else
    NLSPATH=":${NLSPATH}:/opt/intel/cc/10.1.015/lib/locale/en_US"; export NLSPATH
fi

if [ -z "${MANPATH}" ]
then
    MANPATH="/opt/intel/cc/10.1.015/man":$(manpath); export MANPATH
else
    MANPATH="/opt/intel/cc/10.1.015/man:${MANPATH}"; export MANPATH
fi


if [ -z "${INTEL_LICENSE_FILE}" ]
then
	INTEL_LICENSE_FILE="/opt/intel/cc/10.1.015/licenses:/opt/intel/licenses:${HOME}/intel/licenses:/Users/Shared/Library/Application Support/Intel/Licenses"; export INTEL_LICENSE_FILE 
else
	INTEL_LICENSE_FILE="${INTEL_LICENSE_FILE}:/opt/intel/cc/10.1.015/licenses:/opt/intel/licenses:${HOME}/intel/licenses:/Users/Shared/Library/Application Support/Intel/Licenses"; export INTEL_LICENSE_FILE
fi
##################################################################
export MKLROOT="/opt/intel/mkl/10.0.4.023"

if [ -z "${INCLUDE}" ]
then
    export INCLUDE="${MKLROOT}/include"
else
    export INCLUDE="$INCLUDE:${MKLROOT}/include"
fi

if [ -z "${LD_LIBRARY_PATH}" ]
then
    export LD_LIBRARY_PATH="${MKLROOT}/lib/32"
else
    export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${MKLROOT}/lib/32"
fi

if [ -z "${MANPATH}" ]
then
    export MANPATH="${MKLROOT}/man:$(manpath)"
else
    export MANPATH="${MKLROOT}/man:$MANPATH"
fi

if [ -z "${LIBRARY_PATH}" ]
then
    export LIBRARY_PATH="${MKLROOT}/lib/32"
else
    export LIBRARY_PATH="$LIBRARY_PATH:${MKLROOT}/lib/32"
fi

if [ -z "${CPATH}" ]
then
    export CPATH="${MKLROOT}/include"
else
    export CPATH="$CPATH:${MKLROOT}/include"
fi

if [ -z "${FPATH}" ]
then
    export FPATH="${MKLROOT}/include"
else
    export FPATH="$FPATH:${MKLROOT}/include"
fi
#######################################################################

代码: 全选

[daryl@localhost Desktop]$ gcc --version
gcc (GCC) 4.1.2 20071124 (Red Hat 4.1.2-42)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[daryl@localhost Desktop]$ rpm -V gcc
[daryl@localhost Desktop]$ 
很奇怪,我用ntfs-3g-1.2812测试了一下configure和make,gcc并没有报错,而且自始至终ICC都是好的。
搞了三个钟头,还是没有搞明白,现在向各位求助:问题到底处在什么地方?
先谢过各位了~
dbzhang800
帖子: 3182
注册时间: 2006-03-10 15:10
来自: xi'an China
送出感谢: 0
接收感谢: 2 次
联系:

#2

帖子 dbzhang800 » 2008-08-22 13:02

很可能是你的用法不规范造成的。
不妨试试下面的常规用法

1.
将a.cpp 改为 a.c
然后 gcc a.c

2.
将gcc 改为g++
即 g++ a.cpp

3.
添加编译选项 -lstdc++
即 gcc a.cpp -lstdc++
回复

回到 “C/C++/Java”