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

Building using MinGW-W64 fails with "'InetPton' was not declared in this scope" #2225

Open
i3abghany opened this issue Dec 28, 2021 · 3 comments

Comments

@i3abghany
Copy link

I use CMake to generate a ninja.build file, which I use to try to build the library. However, it fails with the following output:

nil@DESKTOP-0K54F8M MINGW64 /path/to/spdlog/build (v1.x)
$ ninja
[4/10] Building CXX object example/CMakeFiles/example.dir/example.cpp.obj
FAILED: example/CMakeFiles/example.dir/example.cpp.obj
C:\PROGRA~1\MINGW-~1\X86_64~1.0-P\mingw64\bin\C__~1.EXE  -DSPDLOG_COMPILED_LIB -I../include -O3 -DNDEBUG   -std=c++11 -MD -MT example/CMakeFiles/example.dir/example.cpp.obj -MF example\CMakeFiles\example.dir\example.cpp.obj.d -o example/CMakeFiles/example.dir/example.cpp.obj -c ../example/example.cpp 
In file included from ../include/spdlog/sinks/udp_sink.h:10,
                 from ../example/example.cpp:232:
../include/spdlog/details/udp_client-windows.h: In constructor 'spdlog::details::udp_client::udp_client(const string&, uint16_t)':
../include/spdlog/details/udp_client-windows.h:67:13: error: 'InetPton' was not declared in this scope
         if (InetPton(PF_INET, TEXT(host.c_str()), &addr_.sin_addr.s_addr) != 1)
             ^~~~~~~~
../include/spdlog/details/udp_client-windows.h:67:13: note: suggested alternative: 'inet_ntoa'
         if (InetPton(PF_INET, TEXT(host.c_str()), &addr_.sin_addr.s_addr) != 1)
             ^~~~~~~~
             inet_ntoa
[8/10] Building CXX object CMakeFiles/spdlog.dir/src/spdlog.cpp.obj
ninja: build stopped: subcommand failed.

Can someone please help me with how to debug/overcome this issue, please?

@gabime
Copy link
Owner

gabime commented Feb 12, 2022

Did you overcome this issue ?which version of ming2 are you using ?

@baagod
Copy link

baagod commented Feb 19, 2022

Under the Windows Platform, Open as Administrator the x64 Native Tools Command Prompt for VS 2022 command prompt window execution:

$ cd spdlog && mkdir build && cd build
$ cmake .. -G "Ninja" && ninja install

config CMakeLists.txt :

cmake_minimum_required(VERSION 3.21)
project(01-hello)

set(CMAKE_PREFIX_PATH C:/Program Files (x86))
find_package(spdlog REQUIRED)

add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE spdlog::spdlog spdlog::spdlog_header_only)

@irvingzhang0512
Copy link

Same issue here.

A simple workaround is to set -DSPDLOG_BUILD_EXAMPLE=OFF since this issue is in example codes

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

No branches or pull requests

4 participants