ARM에서 cpp로 pthread_create할때 문제에 대한 문의드립니다.
안녕하세요.
cpp로 컴파일 했더니 에러는없습니다.
그러나 실행 시 "SEGV" 출력됩니다.
=====================================================
protected:
bool m_bRun;
unsigned int m_ulNoSignal;
// pthread_t m_threadRecv;
// pthread_t m_threadGetFile;
// pthread_t m_threadPutFile;
=====================================================
// 여기서 문제가 됩니다..
if(pthread_create(&m_threadRecv, NULL, &recv_thread, (void *)this) != 0) ==> pthread_create를 하면 프로그램 실행 시 "SEGV"가 출력이 됩니다.
.
.
.
.
===========================================================.
void * recv_thread(void *arg)
{
while(1)
pause();
printf("Test =1\n");
// CDidClient * pOwner = (CDidClient *)arg;
printf("Test=2\n");
// pOwner->RecvThread();
printf("Test=3\n");
return 0;
}
==========================================================
Makefile
===========================================================
.SUFFIXES : .x .o .c .s .cpp
ROOT = /usr/local/arm_linux_4.2/
LIB = $(ROOT)/lib/gcc/arm-linux/4.2.1
LIB1 =$(ROOT)/arm-linux/lib
INCSYS:=$(ROOT)/arm-linux/sys-include
INC :=$(ROOT)/arm-linux/include
#CC=arm-linux-gnueabl-g++
#CPP=arm-linux-g++
CC=arm-linux-gcc -O2 -I$(INC) -I$(INCSYS) -static
CPP=arm-none-linux-gnueabi-g++ -O -I$(INC) -I$(INCSYS) -static -DLINUX_ENV
#CPP=arm-linux-g++
#CPP=arm-none-linux-gnueabi-g++
WEC_LDFLAGS=-L$(LIB) -L$(LIB1)
STRIP=arm-linux-strip
#CPP=arm-linux-g++ -O2 -I$(INC) -I$(INCSYS) -static -DLINUX_ENV
TARGET = ARM_didclient
#SRCS := main.cpp didclient.cpp tcpsock.cpp sock.cpp fio.cpp DidPacket.cpp nethlp.cpp stlhlp.cpp
SRCS := main.cpp
#SRCS := \
main.cpp \
didclient.cpp \
DidPacket.cpp \
sock.cpp \
tcpsock.cpp \
fio.cpp \
nethlp.cpp \
stlhlp.cpp
#LIiBS= -lthread -lstdc++
LIBS= -lc -lgcc -lc -lpthread -lstdc++
all:
$(CPP) $(WEC_LDFLAGS) $(SRCS) $(LIBS) -o $(TARGET) -static
# $(CPP) $(WEC_LDFLAGS) $(SRCS) -o $(TARGET) $(LIBS) -static
$(STRIP) $(TARGET)
@echo "Please also copy input patterns to storage"
iclean:
rm -f *.o
rm -f *.x
rm -f *.flat
rm -f *.map
rm -f temp
rm -f *.img
rm -f $(TARGET)
rm -f *.gdb
rm -f *.bak
d
pthread_create(&m_threadRecv, NULL, &recv_thread, (void *)this) ----> pthread_create(&m_threadRecv, NULL, recv_thread, (void *)this)
3번째 argument 가 잘못된듯요.
SYNOPSIS
#include
int pthread_create(pthread_t *restrict thread,
const pthread_attr_t *restrict attr,
void *(*start_routine)(void*), void *restrict arg);
댓글 달기