Skip to content
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

can't compile correctly on the window platform #727

Open
ac169 opened this issue Oct 8, 2024 · 1 comment
Open

can't compile correctly on the window platform #727

ac169 opened this issue Oct 8, 2024 · 1 comment
Assignees

Comments

@ac169
Copy link

ac169 commented Oct 8, 2024

environment: win 10 + clion + vcpkg + VS 2022 toolchain
opendht version: v3.2.0

Cmakelists.txt files in the source code are almost unavailable. Combining the current compilation environment rewriting CMAKELISTS.txt file,

...
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED on)

set(OPENDHT_HTTP ON)
set(OPENDHT_TOOLS OFF)
set(OPENDHT_PROXY_CLIENT ON)

list(APPEND opendht_SOURCES src/base64.h src/base64.cpp)

find_package(PkgConfig REQUIRED)

pkg_search_module(GnuTLS REQUIRED IMPORTED_TARGET gnutls)
pkg_search_module(Nettle REQUIRED IMPORTED_TARGET nettle)
pkg_search_module(OPENSSL REQUIRED IMPORTED_TARGET openssl)
pkg_search_module(argon2 REQUIRED IMPORTED_TARGET libargon2)

find_package(fmt CONFIG REQUIRED)
find_package(msgpack-cxx CONFIG REQUIRED)
find_package(Restinio CONFIG REQUIRED)
find_package(jsoncpp CONFIG REQUIRED)
find_package(unofficial-readline-win32 CONFIG REQUIRED)

add_definitions(-DOPENDHT_JSONCPP)
add_definitions(-D_WINSOCK_DEPRECATED_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -DWIN32_LEAN_AND_MEAN -DSTATIC_GETOPT -DGNUTLS_INTERNAL_BUILD)

set(DISABLE_MSC_WARNINGS "/wd4101 /wd4244 /wd4267 /wd4273 /wd4804 /wd4834 /wd4996")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${DISABLE_MSC_WARNINGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMSGPACK_NO_BOOST -DMSGPACK_DISABLE_LEGACY_NIL -DMSGPACK_DISABLE_LEGACY_CONVERT")
...
  1. Configure the above option, compile error:
include\opendht\infohash.h(254): error C2375: “dht::operator <<”: redefinition; different linkage

Modify include\opendht\infohash.h the following modifications of the following, You can compile and generate the OpenDHT library file.

...
// template <size_t M>
// OPENDHT_PUBLIC friend std::ostream& operator<< (std::ostream& s, const Hash<M>& h);
template <size_t M> friend std::ostream& operator<< (std::ostream& s, const Hash<M>& h);
...
// template <size_t N> std::ostream& operator<< (std::ostream& s, const Hash<N>& h)
template <size_t N>
OPENDHT_PUBLIC std::ostream& operator<< (std::ostream& s, const Hash<N>& h)
...
  1. After turning on OpenDHT_C option, compile the error:
opendht.cpp.obj : error LNK2001: unresolved external symbol "struct dht::HexMap const dht::hex_map" (?hex_map@dht@@3UHexMap@1@B)
opendht.cpp.obj : error LNK2001: unresolved external symbol "public: static struct dht::ValueType const dht::ValueType::USER_DATA" (?USER_DATA@ValueType@dht@@2U12@B)
@ac169
Copy link
Author

ac169 commented Oct 13, 2024

#722 (comment)

According to the version provided by the author, it has been successfully compiled after adapting to the CLion + VCPKG environment, but the problem encountered by dhtchat is also the same!

I hope the official can optimize the package management method of VCPKG.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants