|
我写了一个工程,包括两个类(SerialPort和EstablishPort)和一个接口文件,其中SerialPort是EstablishPort的基类,想编译成一个.so文件
但是在编译的时候,其他文件都编译过了,就是在编译SerialPort的时候总是提示段错误
输出如下:
make
/usr/local/qt/bin/moc serialport.h -o .moc/moc_serialport.cpp
make: *** [.moc/moc_serialport.cpp] 段错误 (core dumped)
我是使用qmake 生成Makefile文件的
serialport.h
#ifndef SERIALPORT_H
#define SERIALPORT_H
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <termios.h>
#include <sys/ioctl.h>
#include <qobject.h>
#include <pthread.h>
#include <semaphore.h>
#include "constdefinition.h"
//缓冲区记录信息
struct BUFRECORD
{
bool Empty;
bool Full;
int Front;
int Tail;
};
class SerialPort : public QObject
{
Q_OBJECT
public:
SerialPort(const char& comno='a', int cardtype=1);
~SerialPort();
bool initPort(const tcflag_t& baud=B9600, const uint& databit=8, const uint& parity=0, const uint& stopbit=1);
int WriteToPort(const unsigned char * lpByte, int dwBytesToWrite );
void StartMonitoring();
void StopMonitoring();
virtual void ProcessReceiveData();
virtual void EndProcessData();
protected:
static void WriteChar(SerialPort * port);
static void ReceiveChar(SerialPort * port);
static void* CommThread(void* ptr);
bool bThreadAlive;
int ReceivePos;
pthread_t comm_thread;
pthread_mutex_t write_lock;
pthread_mutex_t read_lock;
sem_t shutdown_sem;
sem_t write_semaphore;
sem_t buf_full_semaphore;
unsigned char * szWriteBuffer[ARRAYLEN];
int nBytesToWrite[ARRAYLEN];
int nWriteBufferSize;
BUFRECORD BufInfo;
unsigned char* szReceiveBuffer;
int fd;
};
#endif |
|