[Libwebsockets] Integrate new file into libwebsocket make build system

Hemant Kumar hkumar at arubanetworks.com
Sat Nov 23 00:25:25 CET 2013


Hi Edwin

Thanks for your reply.
As you mentioned, I first compiled my library and have .so files under libwebsocket/lib . Next , I created a new file under test-server directory and included libwebsockets.h .
On compilation , it throws following errors:

bash-4.1$ gcc  -Wall  -I/home/hkumar/libwebsockets/lib/ -L/home/hkumar/libwebsockets/build/lib/  tcp_nb_client.c tcp_nb_send.c  -lrt  -o trafficclient
/tmp/ccCmQqeF.o: In function `main':
tcp_nb_client.c:(.text+0x1cd): undefined reference to `libwebsocket_create_context'
tcp_nb_client.c:(.text+0x256): undefined reference to `libwebsocket_client_connect'
tcp_nb_client.c:(.text+0x2bd): undefined reference to `libwebsocket_context_destroy'
/tmp/ccMg2kKl.o: In function `socket_send':
tcp_nb_send.c:(.text+0x261): undefined reference to `libwebsocket_write'
collect2: ld returned 1 exit status
I am at loss to understand what's wrong in the above process ? Please suggest.
Right now , I am not accessing sock variable defined inside struct libwebsocket structure, for which I needed to include private-libwebsocket include file also.

Thanks
Hemant

From: Andy Green [mailto:extracats at googlemail.com] On Behalf Of Edwin van den Oetelaar
Sent: Friday, November 22, 2013 3:15 PM
To: Hemant Kumar
Cc: libwebsockets at ml.libwebsockets.org
Subject: Re: [Libwebsockets] Integrate new file into libwebsocket make build system

Hello Hemant,

The usual procedure is to build and install the library and use it as such.
You would make a new project and
#include <libwebsockets.h>

and then link to the library to build the final binary. (using -l flag)
gcc myapp.c -o myapp -lwebsockets

Working inside the library directory is not the normal way.

Greetings,
Edwin van den Oetelaar

On Fri, Nov 22, 2013 at 11:54 PM, Hemant Kumar <andy.green at linaro.org<mailto:andy.green at linaro.org>> wrote:
Hi

I am trying to add a new source file into libwebsocket build system.

I am using libwebsocket_write() and  related APIs mentioned in libwebsocket.c  in my source code and have included the following files. Also, I am trying to reference the sock variable defines inside struct libwebsocket , which is in turn is defined in private-libwebsocket.h  .

#include "../lib/private-libwebsockets.h"
#include <libwebsockets.h>

My source file is placed under test-server directory , I end up with following error when I use gcc separately to compile the file:

gcc  -Wall  -I/home/hkumar/libwebsockets/lib/ -L/home/hkumar/libwebsockets/build/lib/  traffic_client.c traffic_client_send.c  -lrt  -o trafficclient

In file included from traffic_client.c:18:
../lib/private-libwebsockets.h:29:20: error: config.h: No such file or directory
In file included from traffic_client_send.c:13:
../lib/private-libwebsockets.h:29:20: error: config.h: No such file or directory

I do not see any config.h in lib directory which means that it might be taken care by libwebsocket cmake build utility.
Can you please suggest, how I can add my new source file and compile it successfully?

Thanks
Hemant



_______________________________________________
Libwebsockets mailing list
Libwebsockets at ml.libwebsockets.org<mailto:Libwebsockets at ml.libwebsockets.org>
http://ml.libwebsockets.org/mailman/listinfo/libwebsockets

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20131122/a5295ca7/attachment-0001.html>


More information about the Libwebsockets mailing list