-
Notifications
You must be signed in to change notification settings - Fork 156
Open
Labels
Description
Description
- Version: commit 0828ded
- Platform: Windows 10, C++
I am attempting to build mcap as a static library and link it to a project (similarly to mcap_builder where I ran into the same issue). Everything works as expected on Linux, however on Windows I get multiple warnings like the following:
C:\Users\user\Documents\mcap_win_err_mre\mcap\include\mcap\writer.hpp(475,32): warning C4251: 'mcap
::McapWriter::attachmentIndex_': class 'std::vector<mcap::AttachmentIndex,std::allocator<mcap::AttachmentInde
x>>' needs to have dll-interface to be used by clients of class 'mcap::McapWriter' [C:\Users\user\Documents\mcap_win_err_mre\build\mcap.vcxproj]
followed by linker errors:
mcap_test.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __cdecl mcap::M
capReader::close(void)" (__imp_?close@McapReader@mcap@@QEAAXXZ) referenced in function main [C:\Users\user\
Documents\mcap_win_err_mre\build\mcap_test.vcxproj]
I only get errors if I build statically. If I change add_library (mcap STATIC "mcap.cpp")
to add_library (mcap SHARED "mcap.cpp")
everything seems to work as expected.
Steps To Reproduce
On Windows:
git clone https://github.com/asahtik/mcap_win_err_mre.git
cd mcap_win_err_mre
cmake -S. -Bbuild
cmake --build build
Expected Behavior
Code compiles and links successfully without errors