Skip to content

Build Issue: Linker errors when building with shared library option #438

Open
@TheGorge7

Description

@TheGorge7

Environment

  • OS: Windows on ARM64
  • Compiler: Clang (LLVM)
  • Build System: CMake with Ninja
  • Repository: socket.io-client-cpp (latest version from main branch)

Steps to Reproduce:

  • Cloned the repository recursively:
git clone --recursive https://github.com/socketio/socket.io-client-cpp.git
cd socket.io-client-cpp
  • Generated build files with CMake:

cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON
ninja

Error

The main library seems to build but when linking the test executable, I'm getting multiple "undefined symbol" errors for various methods in the sio::packet class:

[113/113] Linking CXX executable test\sio_test.exe
FAILED: test/sio_test.exe
C:\Windows\system32\cmd.exe /C "cd . && C:\PROGRA~1\LLVM\bin\CLANG_~1.EXE -nostartfiles -nostdlib -O3 -DNDEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrt -Xlinker /subsystem:console -fuse-ld=lld-link test/CMakeFiles/sio_test.dir/sio_test.cpp.obj -o test\sio_test.exe -Xlinker /MANIFEST:EMBED -Xlinker /implib:test\sio_test.lib -Xlinker /pdb:test\sio_test.pdb -Xlinker /version:0.0   _deps/catch2-build/src/Catch2Main.lib  sioclient.lib  _deps/catch2-build/src/Catch2.lib  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -loldnames  && cd ."
lld-link: error: undefined symbol: public: __cdecl sio::packet::packet(class std::basic_string<char, struct std::char_traits<char>, class std::allocator<char>> const &, class std::shared_ptr<class sio::message> const &, int, bool)
>>> referenced by test/CMakeFiles/sio_test.dir/sio_test.cpp.obj:(void __cdecl CATCH2_INTERNAL_TEST_0(void))
>>> referenced by test/CMakeFiles/sio_test.dir/sio_test.cpp.obj:(void __cdecl CATCH2_INTERNAL_TEST_12(void))

lld-link: error: undefined symbol: public: enum sio::packet::frame_type __cdecl sio::packet::get_frame(void) const
>>> referenced by test/CMakeFiles/sio_test.dir/sio_test.cpp.obj:(void __cdecl CATCH2_INTERNAL_TEST_0(void))

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