hjack 发表于 2008-4-9 12:34

Makefile 报错.segmentation fault

make的时候出错了,coredump了。

>make
g++ -c test_read.cpp
make: *** 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: *** 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
#00x0fee8488 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)

Leon001 发表于 2008-4-9 13:37

编译是链接到这个/lib/tls/libc.so.6?

看下环境变量等设置

hjack 发表于 2008-4-9 23:56

网上查了下,据说是gcc版本问题.........

hjack 发表于 2008-4-10 18:11

今天在另一台server上跑相同的文件,运行十分顺利....
页: [1]
查看完整版本: Makefile 报错.segmentation fault