工大后院

 找回密码
 加入后院

扫一扫,访问微社区

QQ登录

只需一步,快速开始

搜索
查看: 3456|回复: 3

Makefile 报错.segmentation fault

[复制链接]
发表于 2008-4-9 12:34 | 显示全部楼层 |阅读模式
make的时候出错了,coredump了。
>make
g++ -c test_read.cpp
make: *** [test_read.o] Segmentation fault (core dumped)

不管,再make一次。还是报错,但这次是另一个命令报的错。
>make
g++ -c test_read.cpp
g++ -c shmQueue.cpp
g++ -c shm.cpp
g++ -c sem.cpp
g++ -g -o test_read test_read.o shm.o sem.o shmQueue.o
make: *** [test_read] Segmentation fault (core dumped)

gdb去看一看是什么情况。
>gdb g++ core.4069
GNU gdb Red Hat Linux (6.0post-0.20040223.19.ydl.1rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "ppc-yellowdog-linux-gnu"...(no debugging symbols found)...Using host libthread_db library "/lib/tls/libthread_db.so.1".
Core was generated by `g++ -g -o test_read test_read.o shm.o sem.o shmQueue.o'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /lib/tls/libc.so.6...(no debugging symbols found)...done.
Loaded symbols for /lib/tls/libc.so.6
Reading symbols from /lib/ld.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib/ld.so.1
#0  0x0fee8488 in _int_malloc () from /lib/tls/libc.so.6

以下是makefile文件。
OBJS = shm.o sem.o shmQueue.o
CC = g++
all : test_read test_write
.PHONY : all
test_read : test_read.o shmQueue.o shm.o sem.o
        $(CC) -g -o test_read test_read.o $(OBJS)
test_write : test_write.o shmQueue.o shm.o sem.o
        $(CC) -g -o test_write test_write.o $(OBJS)
test_read.o : test_read.cpp
        $(CC) -c test_read.cpp
test_write.o : test_write.cpp
        $(CC) -c test_write.cpp
shmQueue.o : shmQueue.cpp shmQueue.h
        $(CC) -c shmQueue.cpp
shm.o : shm.cpp shm.h
        $(CC) -c shm.cpp
sem.o : sem.cpp sem.h
        $(CC) -c sem.cpp
.PHONY : clean
clean :
        rm test_read test_write test_read.o test_write.o $(OBJS)

使用g++直接编译是没有报错的哦。
使用make就是第一次报错后,第二次再make时,原来报错的命令不报了。变成另一条命令报错了。
以下是g++版本信息:
>g++ -v
Reading specs from /usr/lib/gcc-lib/ppc64-yellowdog-linux/3.3.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --disable-libunwind-exceptions --with-system-zlib --enable-__cxa_atexit --host=ppc64-yellowdog-linux --build=ppc64-yellowdog-linux --target=ppc64-yellowdog-linux --with-cpu=default32 --enable-biarch
Thread model: posix
gcc version 3.3.3 (Yellow Dog Linux 3.3.3-16.ydl.4)
发表于 2008-4-9 13:37 | 显示全部楼层
编译是链接到这个/lib/tls/libc.so.6?

看下环境变量等设置
回复

使用道具 举报

 楼主| 发表于 2008-4-9 23:56 | 显示全部楼层
网上查了下,据说是gcc版本问题.........
回复

使用道具 举报

 楼主| 发表于 2008-4-10 18:11 | 显示全部楼层
今天在另一台server上跑相同的文件,运行十分顺利....[em021] [em021]
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 加入后院

本版积分规则

QQ|Archiver|手机版|小黑屋|广告业务Q|工大后院 ( 粤ICP备10013660号 )

GMT+8, 2024-6-13 11:12

Powered by Discuz! X3.5

Copyright © 2001-2024 Tencent Cloud.

快速回复 返回顶部 返回列表