drogonframework / drogonframework/drogon

Usage of external spdlog library cause a compilation error when using system calls

Open
#2,060 1 comment 0 reactions 1 assignee Claimed by @Greisby View on GitHub
Dominant language
C++
Stars
14.3k
Forks
1.4k
Avg merge
1d 13h
Merged PRs (30d)
14

Description

**Describe the bug**
A Drogon project does not compile when spdlog and fmt libraries are already installed on the project when the compilation commands are executed using MINGW32 for Windows 11.
After a little investigation, I cannot say that this behavior is an error introduced by Drogon because I may have forgotten something in the CMakefiles of the project to configure system libraries to define the UNICODE version of the access functions.
The issue may be solve if os_access definition points to the _waccess system (from io.h) call but I couldn't find the way to enable it on the project.

To add more information about how the project is configured:
- Definition \_WIN32 is defined to 1
- Definition \_\_MINGW32\_\_ is defined to 1

**To Reproduce**
Steps to reproduce the behavior:
1. Clone and build the project:
```
git clone https://github.com/iscapla/drogon_spdlog.git
cd drogon_spdlog
mkdir build

cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=TRUE -DCMAKE_C_COMPILER:FILEPATH=C:\msys64\ucrt64\bin\gcc.exe -DCMAKE_CXX_COMPILER:FILEPATH=C:\msys64\ucrt64\bin\g++.exe -S. -B./build -G "MinGW Makefiles"

cmake --build ./build --config Debug --target all -j 22 --
```
2. See errors:
```bash
drogon_spdlog\build\_deps\drogon-src\lib\src\AccessLogger.cc:143:55: error: cannot convert 'const wchar_t*' to 'const char*'
143 | if (os_access(fsLogPath.native().c_str(), W_OK) != 0)

drogon_spdlog\build\_deps\drogon-src\lib\src\HttpAppFrameworkImpl.cc:1087:55: error: cannot convert 'const wchar_t*' to 'const char*'
1087 | if (os_access(fsLogPath.native().c_str(), W_OK) != 0)
```

**Expected behavior**
A successful compilation.

**Screenshots**
N/A

**Desktop (please complete the following information):**
- OS: Windows
- cmake version: 3.29.3
- g++version: 14.1.0
- cpp version: 14.1.0

Binaries uses the msys64\ucrt64 versions.

**Smartphone (please complete the following information):**
N/A

**Additional context**
N/A

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.