-D_GLIBCXX_USE_CXX11_ABI=0不要乱用,会导致野指针

今天遇到一个问题:交叉编译jthread和jrtp,然后将生成的静态库文件copy到我们自己的工程里面,我们的工程调用jrtp.a里面的函数,从网络上获取rtp数据,但是在status = sess.Create(sessparams,&transparams);的时候程序崩溃了,原因是transparams变量对应的类

class JRTPLIB_IMPORTEXPORT RTPUDPv4TransmissionParams : public RTPTransmissionParams
{
public:
	RTPUDPv4TransmissionParams();

	/** Sets the IP address which is used to bind the sockets to \c ip. */
	void SetBindIP(uint32_t ip)									{ bindIP = ip; }

	/** Sets the multicast interface IP address. */
	void SetMulticastInterfaceIP(uint32_t ip)					{ mcastifaceIP = ip; }

	/** Sets the RTP portbase to \c pbase, which has to be an even number
	 *  unless RTPUDPv4TransmissionParams::SetAllowOddPortbase was called;
	 *  a port number of zero will cause a port to be chosen automatically. */
	void SetPortbase(uint16_t pbase)							{ portbase = pbase; }

	/** Sets the multicast TTL to be used to \c mcastTTL. */
	void SetMulticastTTL(uint8_t mcastTTL)						{ multicastTTL = mcastTTL; }

	/** Passes a list of IP addresses which will be used as the local IP addresses. */
	void SetLocalIPList(std::list &iplist)			{ localIPs = iplist; } 

	/** Clears the list of local IP addresses. 
	 *  Clears the list of local IP addresses. An empty list will make the transmission 
	 *  component itself determine the local IP addresses.
	 */
	void ClearLocalIPList()										{ localIPs.clear(); }

	/** Returns the IP address which will be used to bind the sockets. */
	uint32_t GetBindIP() const									{ return bindIP; }

	/** Returns the multicast interface IP address. */
	uint32_t GetMulticastInterfaceIP() const					{ return mcastifaceIP; }

	/** Returns the RTP portbase which will be used (default is 5000). */
	uint16_t GetPortbase() const								{ return portbase; }

	/** Returns the multicast TTL which will be used (default is 1). */
	uint8_t GetMulticastTTL() const								{ return multicastTTL; }

	/** Returns the list of local IP addresses. */
	const std::list &GetLocalIPList() const			{ return localIPs; }

	/** Sets the RTP socket's send buffer size. */
	void SetRTPSendBuffer(int s)								{ rtpsendbuf = s; }

	/** Sets the RTP socket's receive buffer size. */
	void SetRTPReceiveBuffer(int s)								{ rtprecvbuf = s; }

	/** Sets the RTCP socket's send buffer size. */
	void SetRTCPSendBuffer(int s)								{ rtcpsendbuf = s; }

	/** Sets the RTCP socket's receive buffer size. */
	void SetRTCPReceiveBuffer(int s)							{ rtcprecvbuf = s; }

	/** Enables or disables multiplexing RTCP traffic over the RTP channel, so that only a single port is used. */
	void SetRTCPMultiplexing(bool f)							{ rtcpmux = f; }

	/** Can be used to allow the RTP port base to be any number, not just even numbers. */
	void SetAllowOddPortbase(bool f)							{ allowoddportbase = f; }

	/** Force the RTCP socket to use a specific port, not necessarily one more than
	 *  the RTP port (set this to zero to disable). */
	void SetForcedRTCPPort(uint16_t rtcpport)					{ forcedrtcpport = rtcpport; }

	/** Use sockets that have already been created, no checks on port numbers
	 *  will be done, and no buffer sizes will be set; you'll need to close
	 *  the sockets yourself when done, it will **not** be done automatically. */
	void SetUseExistingSockets(SocketType rtpsocket, SocketType rtcpsocket) { rtpsock = rtpsocket; rtcpsock = rtcpsocket; useexistingsockets = true; }

	/** If non null, the specified abort descriptors will be used to cancel
	 *  the function that's waiting for packets to arrive; set to null (the default
	 *  to let the transmitter create its own instance. */
	void SetCreatedAbortDescriptors(RTPAbortDescriptors *desc) { m_pAbortDesc = desc; }

	/** Returns the RTP socket's send buffer size. */
	int GetRTPSendBuffer() const								{ return rtpsendbuf; }

	/** Returns the RTP socket's receive buffer size. */
	int GetRTPReceiveBuffer() const								{ return rtprecvbuf; }

	/** Returns the RTCP socket's send buffer size. */
	int GetRTCPSendBuffer() const								{ return rtcpsendbuf; }

	/** Returns the RTCP socket's receive buffer size. */
	int GetRTCPReceiveBuffer() const							{ return rtcprecvbuf; }

	/** Returns a flag indicating if RTCP traffic will be multiplexed over the RTP channel. */
	bool GetRTCPMultiplexing() const							{ return rtcpmux; }

	/** If true, any RTP portbase will be allowed, not just even numbers. */
	bool GetAllowOddPortbase() const							{ return allowoddportbase; }

	/** If non-zero, the specified port will be used to receive RTCP traffic. */
	uint16_t GetForcedRTCPPort() const							{ return forcedrtcpport; }

	/** Returns true and fills in sockets if existing sockets were set
	 *  using RTPUDPv4TransmissionParams::SetUseExistingSockets. */
	bool GetUseExistingSockets(SocketType &rtpsocket, SocketType &rtcpsocket) const { if (!useexistingsockets) return false; rtpsocket = rtpsock; rtcpsocket = rtcpsock; return true; }

	/** If non-null, this RTPAbortDescriptors instance will be used internally,
	 *  which can be useful when creating your own poll thread for multiple
	 *  sessions. */
	RTPAbortDescriptors *GetCreatedAbortDescriptors() const		{ return m_pAbortDesc; }
private:
	uint16_t portbase;
	uint32_t bindIP, mcastifaceIP;
	std::list localIPs;
	uint8_t multicastTTL;
	int rtpsendbuf, rtprecvbuf;
	int rtcpsendbuf, rtcprecvbuf;
	bool rtcpmux;
	bool allowoddportbase;
	uint16_t forcedrtcpport;

	SocketType rtpsock, rtcpsock;
	bool useexistingsockets;

	RTPAbortDescriptors *m_pAbortDesc;
}

这里面有个函数RTPAbortDescriptors *GetCreatedAbortDescriptors(),在status = sess.Create(sessparams,&transparams);之前打印这个函数返回的指针为NULL,但是到了静态库中的函数打印这个函数返回的指针就不是NULL了,后来发现我们的makefile里面编译C++程序的时候加了参数-D_GLIBCXX_USE_CXX11_ABI=0,去掉以后就正常了。具体原因偶也不知道啊,哪位大神指导可以告诉我一下,谢谢。

你可能感兴趣的:(-D_GLIBCXX_USE_CXX11_ABI=0不要乱用,会导致野指针)