Skip to content

please remove the dllexport of static libs #184

Closed

Description

@z16166

hi,

Currently uWebSockets and its dependency "uSockets" define a macro "WIN32_EXPORT" in header file "libusockets.h", as the following.
So all uSockets api functions and a uWebSockets class named "struct WIN32_EXPORT WebSocketProtocol" will appear in exe/dll export tables even if we use their static libs.
Please remove "__declspec(dllexport)" for static lib build configuration. Thanks.

#ifdef _WIN32
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <winsock2.h>
#define LIBUS_SOCKET_DESCRIPTOR SOCKET
#define WIN32_EXPORT __declspec(dllexport)
#else
#define LIBUS_SOCKET_DESCRIPTOR int
#define WIN32_EXPORT
#endif

Activity

  1. z16166 commented on Aug 2, 2022

    @z16166
    Author

    Maybe we can use MSVC macro "_DLL" to detect dll build vs static lib build.

    #ifdef _WIN32
    
    #ifdef _DLL
    #define WIN32_EXPORT __declspec(dllexport)
    #else
    #define WIN32_EXPORT
    #endif
    
    #endif
    
  2. traversaro commented on Jan 2, 2023

    @traversaro

    As the default build system only build static libraries (#99), the easiest fix for this issue is just to define WIN32_EXPORT to an empty string also on Windows. However, at that point WIN32_EXPORT would be empty on all platforms, so probably it could make sense to just remove it altogether. I would be happy to provide a PR to remove it if that is the decision of the mantainers of the library.

  3. uNetworkingAB commented on Jan 2, 2023

    @uNetworkingAB
    Contributor

    if you want to add that _DLL macro check under _WIN32 that's fine with me, that sounds very reasonable make PR plaes

  4. uNetworkingAB commented on Jan 2, 2023

    @uNetworkingAB
    Contributor

    Now that I think of it, who is really building DLL of uSockets? That's really crappy for performance and should never be done. uSockets should always be a static lib

  5. traversaro commented on Jan 2, 2023

    @traversaro

    Now that I think of it, who is really building DLL of uSockets? That's really crappy for performance and should never be done. uSockets should always be a static lib

    Indeed, that is what I mentioned in #184 (comment) . Do you prefer to simply define WIN32_EXPORT to empty also on Windows or just get rid of WIN32_EXPORT altogether?

  6. traversaro commented on Jan 3, 2023

    @traversaro

    Now that I think of it, who is really building DLL of uSockets? That's really crappy for performance and should never be done. uSockets should always be a static lib

    Indeed, that is what I mentioned in #184 (comment) . Do you prefer to simply define WIN32_EXPORT to empty also on Windows or just get rid of WIN32_EXPORT altogether?

    This was handled in b950efd, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions