Skip to content

Include path and Library  #87

@EhsanVahab

Description

@EhsanVahab

dear @bsergean ,
I'm writing a client server program with c++ and Eclipse IDE.
after that IXWebsocket installation was completed, I included the path: /usr/local/include/ixwebsocket and added the library ixwebsocket to the Eclipse .
but when I build my sample code you provided as a sample, I get the following error:

/usr/local/lib/libixwebsocket.a(IXWebSocketPerMessageDeflateCodec.cpp.o): In function `ix::WebSocketPerMessageDeflateCompressor::~WebSocketPerMessageDeflateCompressor()':
IXWebSocketPerMessageDeflateCodec.cpp:(.text+0x82): undefined reference to `deflateEnd'

Here is my sample code :

#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <condition_variable>
#include <mutex>
#include <chrono>
#include <ixwebsocket/IXWebSocket.h>
using namespace std;

int main(int argc, char** argv)
{


	ix::WebSocket webSocket;

	std::string url("ws://localhost:8080/");
	webSocket.setUrl(url);

	// Optional heart beat, sent every 45 seconds when there is not any traffic
	// to make sure that load balancers do not kill an idle connection.
	webSocket.setHeartBeatPeriod(45);

	// Setup a callback to be fired when a message or an event (open, close, error) is received
	webSocket.setOnMessageCallback(
	    [](ix::WebSocketMessageType messageType,
	       const std::string& str,
	       size_t wireSize,
	       const ix::WebSocketErrorInfo& error,
	       const ix::WebSocketOpenInfo& openInfo,
	       const ix::WebSocketCloseInfo& closeInfo)
	    {
	        if (messageType == ix::WebSocketMessageType::Message)
	        {
	            std::cout << str << std::endl;
	        }
	});

	// Now that our callback is setup, we can start our background thread and receive messages
	webSocket.start();

	// Send a message to the server (default to BINARY mode)
	webSocket.send("hello world");

	// The message can be sent in TEXT mode
	webSocket.sendText("hello again");

	// ... finally ...

	// Stop the connection
	webSocket.stop();


}

is there any other library that I have to include in my project?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions