mingw 编译c++ 最简单的程序出现Program received signal SIGSEGV, Segmentation fault.

现象是基本程序

#include 
#include 
#include "time.h"
#include "receive.h"

void receive::recv(void)
{
	time_t t1;
	time(&t1);
	std::cout << "current time" <

Makefile是这样的

platform = $(shell uname)

#

ifneq (,$(findstring MINGW,$(platform)))
CXXFLAGS = -I$(QTDIR)/include -I$(QTDIR)/include/QtCore -I$(QTDIR)/include/QtGui -I. 
LDFLAGS =  -Wl,--enable-runtime-pseudo-reloc  -L$(QTDIR)/lib
QTLDLIBS =  ${LDFLAGS} -lQtCore4 -lQtGui4 -lSetupApi -lregex 
MOC = $(QTDIR)/bin/moc
else
CXXFLAGS = $(shell pkg-config --cflags QtCore QtGui 2>/dev/null) -Wall -O0
QTLDLIBS = $(shell pkg-config --libs QtCore QtGui 2>/dev/null)
MOC = $(shell pkg-config --variable=moc_location QtCore)
LDLIBS +=  -ldl
LUAPLATFORM = linux
endif


LDLIBS += $(QTLDLIBS)

TARGET = no1
OBJS = no1.o receive.o

all:$(OBJS) 
	g++ -flto $(CXXFLAGS) $^ $(LDLIBS) -o $(TARGET)

#all:$(OBJS)
#	g++ -Wl,--enable-runtime-pseudo-reloc -o ../$(TARGET) $^ ${LDFLAGS} -L/usr/lib/qt3/lib -L/usr/X11R6/lib -lQtCore4 -lQtGui4


%.o:%.cpp
	g++ -pipe -Wall -W -O0 -DQT_NO_DEBUG ${CXXFLAGS} -c $<
	
	
.PHONY:all clean

clean:
	-rm -rf *.o *.exe $(TARGET)

编译结果正常,可是运行的时候出现段错误。


找了很久都没有答案,有些论坛上说是BUG,我不太相信,

后面继续找,终于找到答案了。

就是不知道是什么原因。

http://stackoverflow.com/questions/14368482/mingw-compiled-programs-crash-on-64-bit-windows

mingw 编译c++ 最简单的程序出现Program received signal SIGSEGV, Segmentation fault._第1张图片


mingw-w64编译的程序,

需要使用的dll有libgcc_s_dw2-1.dll,libstdc++-6.dll,libwinpthread-1.dll 具体作用不清楚.如果没有程序运行会出现异常.

mingw 编译c++ 最简单的程序出现Program received signal SIGSEGV, Segmentation fault._第2张图片

你可能感兴趣的:(mingw 编译c++ 最简单的程序出现Program received signal SIGSEGV, Segmentation fault.)