-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LibTins cannot be statically linked because it using __declspec(dllimport) #11904
Labels
category:port-bug
The issue is with a library, which is something the port should already support
Comments
Thanks to @ras0219-msft on Discord, he figured out that it is necessary to define
Manually setting the
Updates files:
#define TINS_STATIC
#include <tins/tins.h>
int main() {
const auto interface = Tins::NetworkInterface::default_interface();
Tins::Sniffer sniffer(interface.name());
return 0;
}
cmake_minimum_required(VERSION 3.16)
project(staticLibTinsTesting)
set(CMAKE_CXX_STANDARD 11)
add_executable(staticLibTinsTesting main.cpp)
find_package(Boost COMPONENTS date_time REQUIRED)
find_package(libtins CONFIG REQUIRED)
target_link_libraries(staticLibTinsTesting PRIVATE
Boost::date_time
[...]/vcpkg/installed/x64-windows-static/lib/Packet.lib
Version # Required by Packet
tins
)
set_property(TARGET staticLibTinsTesting PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
LilyWangL
added
the
category:port-bug
The issue is with a library, which is something the port should already support
label
Jun 15, 2020
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
category:port-bug
The issue is with a library, which is something the port should already support
Describe the bug
A clear and concise description of what the bug is.
Environment
To Reproduce
vcpkg install libtins:x86-windows-static
or
vcpkg install libtins:x64-windows-static
main.cpp
CMakeLists.txt
Expected behavior
Expecting to successfully link
libtins
without any dll-requirements.Failure logs
main.cpp.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class Tins::NetworkInterface __cdecl Tins::NetworkInterface::default_interface(void)" (__imp_?default_interface@NetworkInterface@Tins@@SA?AV12@XZ) referenced in function main staticLibTinsTesting.exe : fatal error LNK1120: 1 unresolved externals
The text was updated successfully, but these errors were encountered: