[Libwebsockets] protocol_example_standalone / Win32

Joel Winarske joel.winarske at gmail.com
Mon Jan 30 04:15:32 CET 2017


I have the build setup like below.  I need this to build on Linux, Windows,
and Mac.  Mac is next.  One I have all three sorted out I'll submit a PR if
interested.

cmake ..
-DLWS_WITH_LWSWS=1 # enable libuv
-DLWS_WITH_SSL=1 # find SSL headers
-DLWS_LIBUV_LIBRARIES=C:\Users\joel\Documents\GitHub\libuv\Debug\lib\libuv.lib
-DLWS_LIBUV_INCLUDE_DIRS=C:\Users\joel\Documents\GitHub\libuv\include
-DLWS_WEBSOCKET_LIBRARIES=C:\Users\joel\Documents\GitHub\libwebsockets\build\lib\Debug\websockets.lib
-DLWS_WEBSOCKET_INCLUDE_DIRS=C:\Users\joel\Documents\GitHub\libwebsockets\build


On Sun, Jan 29, 2017 at 12:08 PM, Joel Winarske <joel.winarske at gmail.com>
wrote:

> Windows:
> #define LWS_VISIBLE
> #define LWS_EXTERN extern __declspec(dllexport)
>
> LWS_EXTERN was missing on the plugin-standalone export functions.
>
> LWS_VISIBLE int
> - to -
> LWS_EXTERN LWS_VISIBLE int
>
>
> I also re-worked the CMakeLists.txt so no change is needed in the project
> file prior to building.
>
> On Sat, Jan 28, 2017 at 6:46 PM, Andy Green <andy at warmcat.com> wrote:
>
>>
>>
>> On 01/29/2017 09:42 AM, Joel Winarske wrote:
>>
>>> It was missing the two exports:
>>> 1. destroy_protocol_example_standalone
>>> 2. init_protocol_example_standalone
>>>
>>> It is a configuration issue with the VS project.  After matching project
>>> parameters against known good plugin it's working fine.
>>>
>>
>> That's good to hear.
>>
>>
>>> It involves a multitude of manual steps after what CMakeLists.txt
>>> generates.
>>>
>>
>> The cause - well, the root cause is MSVC / Windows... Microsoft... - is
>> likely that I didn't chop down the main CMakeLists.txt to form the example
>> one for the standalone plugin... I just put enough bits in it to make it
>> work well on Linux.  Windows guys from earlier have hacked the main
>> CMakeLists.txt to do whatever else is needed.
>>
>> The build of the plugin doesn't actually involve anything that isn't done
>> for the build of the lib... it's a DLL with exports coming out in the end
>> the same.  So I guess the "multitude of manual steps" are also workarounds
>> for whatever the cut down CMakeLists.txt isn't doing for the Windows case
>> compared to the main lws one.
>>
>> -Andy
>>
>>
>>> On Sat, Jan 28, 2017 at 12:42 PM, Andy Green <andy at warmcat.com <mailto:
>>> andy at warmcat.com>> wrote:
>>>
>>>
>>>
>>>     On 29 January 2017 03:09:34 GMT+08:00, Joel Winarske
>>>     <joel.winarske at gmail.com <mailto:joel.winarske at gmail.com>> wrote:
>>>     >I am attempting to have lwsws load plugin
>>>     >protocol_example_standalone.dll.
>>>     >
>>>     >I'm seeing:
>>>     >[2017/01/28 10:43:10:2640] ERR: Failed to get init on
>>>     >protocol_example_standalone.dll: The specified procedure could not
>>> be
>>>     >found.
>>>     >
>>>     >It loads all the other plugins built with libwebsocket without
>>> error.
>>>     >
>>>     >Any ideas?
>>>
>>>     The names of the exports in the plugin must match the plugin name.
>>>
>>>     For example 'plugin_standalone' exports
>>>     'init_protocol_example_standalone'.
>>>
>>>     The other reason I can imagine is maybe no exports or decorated
>>>     exports from your plugin dll... you need some objdump like tool to
>>>     check it.
>>>
>>>     -Andy
>>>
>>>     >
>>>     >Thanks,
>>>     >Joel
>>>     >
>>>     >
>>>     >Building this plugin on Windows required some fiddling:
>>>     >
>>>     >
>>>     >*libwebsockets plugin-standalone*
>>>     >1. Open VS2015 x86 Native Tools window
>>>     >2. cd C:\Users\joel\Documents\GitHub\libwebsockets\plugin-standalo
>>> ne
>>>     >3. mkdir build
>>>     >4. cd build
>>>     >5.
>>>     >C:\Users\joel\Documents\GitHub\libwebsockets\plugin-standal
>>> one\build>cmake
>>>     >.. -DLWS_WITH_LWSWS=1
>>>     >-DLWS_OPENSSL_INCLUDE_DIRS=C:\OpenSSL-Win32\include
>>>     >-DLWS_LIBUV_LIBRARIES=C:\Users\joel\Documents\GitHub\libuv\
>>> Debug\lib\libuv.lib
>>>     >-DLWS_LIBUV_INCLUDE_DIRS=C:\Users\joel\Documents\GitHub\lib
>>> uv\include
>>>     >
>>>     >6. Open the protocol_example_standalone sln file, and update as
>>>     >follows:
>>>     >
>>>     >VC++ Directories->Include Directories <append>
>>>     >C:\Users\joel\Documents\GitHub\libuv\include;C:\OpenSSL-Win
>>> 32\include
>>>     >VC++ Directories->Library Directories <append>
>>>     >C:\Users\joel\Documents\GitHub\libwebsockets\build\lib\Debu
>>> g;C:\Users\joel\Documents\GitHub\libuv\Debug\lib
>>>     >Linker->Input <append>
>>>     >websockets.lib;libuv.lib;ws2_32.lib;;userenv.lib;psapi.lib;
>>> iphlpapi.lib
>>>     >
>>>     >7. Build.  you get protocol_example_standalone.dll. Drop this into
>>>     >your
>>>     >lwsws plugin directory.
>>>
>>>     --
>>>     Sent from my Android device with K-9 Mail. Please excuse my brevity.
>>>
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20170129/da9a5ad3/attachment-0002.html>


More information about the Libwebsockets mailing list