[Libwebsockets] Integrate new file into libwebsocket make build system

Andy Green andy at warmcat.com
Sat Nov 23 01:18:10 CET 2013



Hemant Kumar <hkumar at arubanetworks.com> wrote:
>Hi Andy
>
>This is because, I want to use my own select() based callback mechanism
>to directly operate on the 
>socket file descriptor and so need access to it. Is it not possible  by
>design?

You can use the external poll support.

Have a look in the docs and sample apps.

-Andy

>Thanks
>Hemant
>
>-----Original Message-----
>From: Andy Green [mailto:extracats at googlemail.com] On Behalf Of Andy
>Green
>Sent: Friday, November 22, 2013 3:53 PM
>To: Hemant Kumar
>Cc: libwebsockets at ml.libwebsockets.org
>Subject: Re: [Libwebsockets] Integrate new file into libwebsocket make
>build system
>
>On 23/11/13 07:49, the mail apparently from Hemant Kumar included:
>> Hi Edwin/Andy
>>
>> Thanks!! You are right, I missed including -lwebsockets.
>> That solved some of my problem but not all of it:
>>
>> I need to access the socket file descriptor, which is defined as sock
>
>There is a reason some things are in private-libwebsockets.h, it means
>you should not need to touch them.
>
>So the problem is probably with your idea that you "need to access the
>socket file descriptor".
>
>Why do you think you "need" to do that?
>
>-Andy
>
>
>> variable in wsi.
>> So, I use the following :
>>
>>   void socket_send(struct libwebsocket* client_socket)
>>   73 {
>>   74     int new_fd = client_socket->sock;
>>
>>
>> If I dont include private-libwebsockets.h , then it ends up in 
>> following
>> error:
>> 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  -lwebsockets -o trafficclient
>> tcp_nb_send.c: In function ‘socket_send’:
>> tcp_nb_send.c:74: error: dereferencing pointer to incomplete type
>>
>>
>> And if I include the file , then it results in following:
>>
>> 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  -lwebsockets -o trafficclient In file included from 
>> tcp_nb_send.c:13:
>> *../lib/private-libwebsockets.h:29:20: error: config.h: No such file 
>> or
>> directory*
>> tcp_nb_send.c: In function ‘socket_send’:
>> tcp_nb_send.c:139: warning: format ‘%d’ expects type ‘int’, but 
>> argument
>> 2 has type ‘__time_t’
>>
>>
>> I am kind of stuck at this point, will appreciate any suggestion to 
>> overcome this.
>> Thanks for your time.
>>
>> Regards
>> Hemant
>>
>>
>>
>----------------------------------------------------------------------
>> --
>> *From:* Andy Green [extracats at googlemail.com] on behalf of Edwin van 
>> den Oetelaar [andy.green at linaro.org]
>> *Sent:* Friday, November 22, 2013 3:44 PM
>> *To:* Hemant Kumar
>> *Cc:* libwebsockets at ml.libwebsockets.org
>> *Subject:* Re: [Libwebsockets] Integrate new file into libwebsocket 
>> make build system
>>
>>
>> The undefined references happen when you do not link to the library.
>> Add the libwebsockets library and the errors will go away.
>>
>> gcc  -Wall  -I/home/hkumar/libwebsockets/lib/ 
>> -L/home/hkumar/libwebsockets/build/lib/ traffic_client.c 
>> traffic_client_send.c  -lrt*-lwebsockets* -o trafficclient
>>
>> Greetings and good luck,
>> Edwin van den Oetelaar
>>
>> On Sat, Nov 23, 2013 at 12:25 AM, Hemant Kumar <andy.green at linaro.org
>
>> <mailto:andy.green at linaro.org>> wrote:
>>
>>     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
>>     <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
>>     <mailto: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
>> http://ml.libwebsockets.org/mailman/listinfo/libwebsockets
>>
>
>
>--
>Andy Green | Fujitsu Landing Team Leader Linaro.org │ Open source
>software for ARM SoCs | Follow Linaro
>http://facebook.com/pages/Linaro/155974581091106  -
>http://twitter.com/#!/linaroorg - http://linaro.org/linaro-blog
>_______________________________________________
>Libwebsockets mailing list
>Libwebsockets at ml.libwebsockets.org
>http://ml.libwebsockets.org/mailman/listinfo/libwebsockets

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.



More information about the Libwebsockets mailing list