-
I tried almost all solutions found on the internet but can't make it work. Now i wanted to build my project on all the platforms on github action to make sure it works on all of them. But the problem is when I tried to build / compile the project on windows it shows conflict with windows.h header. The same you all have been dealing with a lot. here is the CMakeList.txt file that i am using to build my project for windows and linux cmake_minimum_required(VERSION 3.10)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
#SET (CMAKE_CXX_COMPILER "/usr/bin/clang++" CACHE STRING "C++ compiler" FORCE)
#set(CMAKE_CXX_CLANG_TIDY clang-tidy -checks=-*,readability-*,clang-analyzer-*,-clang-analyzer-cplusplus*)
set(CMAKE_BUILD_TYPE Debug)
#set(CMAKE_BUILD_TYPE Release)
project(client VERSION 1.0)
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
add_subdirectory(raylib)
add_executable(client.out client/client.cpp)
target_include_directories(
client.out PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/net
${CMAKE_CURRENT_SOURCE_DIR}/game
${CMAKE_CURRENT_SOURCE_DIR}/classes
${CMAKE_CURRENT_SOURCE_DIR}/raylib
${CMAKE_CURRENT_SOURCE_DIR}/asio/asio/include
)
target_link_libraries(client.out raylib)
project(server VERSION 1.0)
add_executable(server.out server/server.cpp)
target_include_directories(
server.out PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/net
${CMAKE_CURRENT_SOURCE_DIR}/asio/asio/include
) in this folder where this CMakeLists.txt file exists i have a submodule to raylib and as you can see the raylib added as add_subfolder() option. Here is the github action configure file that I am using to automate # This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
name: CMake on multiple platforms
on:
push:
branches: [ "master", "android_project" ]
pull_request:
branches: [ "master" ]
jobs:
build_cross:
runs-on: ${{ matrix.os }}
strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: false
# Set up a matrix to run the following 3 configurations:
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
#
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
matrix:
os: [ubuntu-latest, windows-latest]
build_type: [Release]
c_compiler: [gcc, clang, cl]
include:
- os: windows-latest
c_compiler: cl
cpp_compiler: cl
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++
exclude:
- os: windows-latest
c_compiler: gcc
- os: windows-latest
c_compiler: clang
- os: ubuntu-latest
c_compiler: cl
steps:
- uses: actions/checkout@v3
- name: checkout all the submodules
uses: actions/checkout@v3
with:
submodules: recursive
- name: install packages for raylib linux only
if: runner.os == 'Linux'
shell: bash
run: sudo apt install libasound2-dev libx11-dev libxrandr-dev libxi-dev libgl1-mesa-dev libglu1-mesa-dev libxcursor-dev libxinerama-dev
- name: Configure CMake
run: cmake -B Build -S Desktop
- name: Build
run: cmake --build Build --config Release
build_mingw:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: checkout all the submodules
uses: actions/checkout@v3
with:
submodules: recursive
- name: Configure Cmake
run: cmake -G "MinGW Makefiles" -B Build -S Desktop
- name: Build
run: cmake --build Build --config Release
andriod_build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: checkout all the submodules
uses: actions/checkout@v3
with:
submodules: recursive
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
- name: build android
shell: bash
run: |
cd Android
./gradlew build this action works and build the project successfully on both Linux and Android Properly.. But windows on mingw and visual studio builds falis. [ 2%] Building C object raylib/raylib/external/glfw/src/CMakeFiles/glfw.dir/context.c.obj
[ 5%] Building C object raylib/raylib/external/glfw/src/CMakeFiles/glfw.dir/init.c.obj
[ 8%] Building C object raylib/raylib/external/glfw/src/CMakeFiles/glfw.dir/input.c.obj
[ 11%] Building C object raylib/raylib/external/glfw/src/CMakeFiles/glfw.dir/monitor.c.obj
[ 14%] Building C object raylib/raylib/external/glfw/src/CMakeFiles/glfw.dir/platform.c.obj
[ 17%] Building C object raylib/raylib/external/glfw/src/CMakeFiles/glfw.dir/vulkan.c.obj
[ 20%] Building C object raylib/raylib/external/glfw/src/CMakeFiles/glfw.dir/window.c.obj
[ 23%] Building C object raylib/raylib/external/glfw/src/CMakeFiles/glfw.dir/egl_context.c.obj
[ 26%] Building C object raylib/raylib/external/glfw/src/CMakeFiles/glfw.dir/osmesa_context.c.obj
[ 29%] Building C object raylib/raylib/external/glfw/src/CMakeFiles/glfw.dir/null_init.c.obj
[ 32%] Building C object raylib/raylib/external/glfw/src/CMakeFiles/glfw.dir/null_monitor.c.obj
[ 35%] Building C object raylib/raylib/external/glfw/src/CMakeFiles/glfw.dir/null_window.c.obj
[ 38%] Building C object raylib/raylib/external/glfw/src/CMakeFiles/glfw.dir/null_joystick.c.obj
[ 41%] Building C object raylib/raylib/external/glfw/src/CMakeFiles/glfw.dir/win32_module.c.obj
[ 44%] Building C object raylib/raylib/external/glfw/src/CMakeFiles/glfw.dir/win32_time.c.obj
[ 47%] Building C object raylib/raylib/external/glfw/src/CMakeFiles/glfw.dir/win32_thread.c.obj
[ 50%] Building C object raylib/raylib/external/glfw/src/CMakeFiles/glfw.dir/win32_init.c.obj
[ 52%] Building C object raylib/raylib/external/glfw/src/CMakeFiles/glfw.dir/win32_joystick.c.obj
[ 55%] Building C object raylib/raylib/external/glfw/src/CMakeFiles/glfw.dir/win32_monitor.c.obj
[ 58%] Building C object raylib/raylib/external/glfw/src/CMakeFiles/glfw.dir/win32_window.c.obj
[ 61%] Building C object raylib/raylib/external/glfw/src/CMakeFiles/glfw.dir/wgl_context.c.obj
[ 64%] Linking C static library libglfw3.a
[ 64%] Built target glfw
[ 67%] Building C object raylib/raylib/CMakeFiles/raylib.dir/rcore.c.obj
[ 70%] Building C object raylib/raylib/CMakeFiles/raylib.dir/rmodels.c.obj
[ 73%] Building C object raylib/raylib/CMakeFiles/raylib.dir/rshapes.c.obj
[ 76%] Building C object raylib/raylib/CMakeFiles/raylib.dir/rtext.c.obj
[ 79%] Building C object raylib/raylib/CMakeFiles/raylib.dir/rtextures.c.obj
[ 82%] Building C object raylib/raylib/CMakeFiles/raylib.dir/utils.c.obj
[ 85%] Building C object raylib/raylib/CMakeFiles/raylib.dir/raudio.c.obj
[ 88%] Linking C static library libraylib.a
[ 88%] Built target raylib
[ 91%] Building CXX object CMakeFiles/client.out.dir/client/client.cpp.obj
In file included from C:/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/windows.h:71,
from C:/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/winsock2.h:23,
from D:/a/PewPewWar/PewPewWar/Desktop/asio/asio/include/asio/detail/socket_types.hpp:33,
from D:/a/PewPewWar/PewPewWar/Desktop/asio/asio/include/asio/detail/win_tss_ptr.hpp:23,
from D:/a/PewPewWar/PewPewWar/Desktop/asio/asio/include/asio/detail/tss_ptr.hpp:25,
from D:/a/PewPewWar/PewPewWar/Desktop/asio/asio/include/asio/detail/call_stack.hpp:20,
from D:/a/PewPewWar/PewPewWar/Desktop/asio/asio/include/asio/detail/thread_context.hpp:20,
from D:/a/PewPewWar/PewPewWar/Desktop/asio/asio/include/asio/detail/recycling_allocator.hpp:20,
from D:/a/PewPewWar/PewPewWar/Desktop/asio/asio/include/asio/detail/handler_alloc_helpers.hpp:21,
from D:/a/PewPewWar/PewPewWar/Desktop/asio/asio/include/asio/detail/executor_function.hpp:19,
from D:/a/PewPewWar/PewPewWar/Desktop/asio/asio/include/asio/execution/any_executor.hpp:24,
from D:/a/PewPewWar/PewPewWar/Desktop/asio/asio/include/asio/execution.hpp:19,
from D:/a/PewPewWar/PewPewWar/Desktop/asio/asio/include/asio/any_completion_executor.hpp:22,
from D:/a/PewPewWar/PewPewWar/Desktop/asio/asio/include/asio.hpp:18,
from D:/a/PewPewWar/PewPewWar/Desktop/net/common.hpp:4,
from D:/a/PewPewWar/PewPewWar/Desktop/net/client.hpp:3,
from D:/a/PewPewWar/PewPewWar/Desktop/net/net.hpp:3,
from D:\a\PewPewWar\PewPewWar\Desktop\client\client.cpp:7:
C:/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/wingdi.h:3158:83: error: 'WINBOOL Rectangle(HDC, int, int, int, int)' redeclared as different kind of entity
3158 | WINGDIAPI WINBOOL WINAPI Rectangle(HDC hdc,int left,int top,int right,int bottom);
| ^
In file included from D:\a\PewPewWar\PewPewWar\Desktop\client\client.cpp:3:
D:/a/PewPewWar/PewPewWar/Desktop/raylib/src/raylib.h:249:3: note: previous declaration 'typedef struct Rectangle Rectangle'
249 | } Rectangle;
| ^~~~~~~~~
In file included from C:/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/windows.h:72:
C:/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/winuser.h:2282:29: error: conflicting declaration of C function 'WINBOOL CloseWindow(HWND)'
2282 | WINUSERAPI WINBOOL WINAPI CloseWindow (HWND hWnd);
| ^~~~~~~~~~~
D:/a/PewPewWar/PewPewWar/Desktop/raylib/src/raylib.h:942:12: note: previous declaration 'void CloseWindow()'
942 | RLAPI void CloseWindow(void); // Close window and unload OpenGL context
| ^~~~~~~~~~~
C:/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/winuser.h:3760:25: error: conflicting declaration of C function 'int ShowCursor(WINBOOL)'
3760 | WINUSERAPI int WINAPI ShowCursor(WINBOOL bShow);
| ^~~~~~~~~~
D:/a/PewPewWar/PewPewWar/Desktop/raylib/src/raylib.h:998:12: note: previous declaration 'void ShowCursor()'
998 | RLAPI void ShowCursor(void); // Shows cursor
| ^~~~~~~~~~
D:\a\PewPewWar\PewPewWar\Desktop\client\client.cpp: In function 'int main()':
D:\a\PewPewWar\PewPewWar\Desktop\client\client.cpp:89:36: error: cannot convert 'const char*' to 'HDC' {aka 'HDC__*'}
89 | DrawText ( "move the ball with arrow keys", 10, 10, 20, DARKGRAY );
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| |
| const char*
C:/ProgramData/chocolatey/lib/mingw/tools/install/mingw64/x86_64-w64-mingw32/include/winuser.h:3479:39: note: initializing argument 1 of 'int DrawTextA(HDC, LPCSTR, int, LPRECT, UINT)'
3479 | WINUSERAPI int WINAPI DrawTextA(HDC hdc,LPCSTR lpchText,int cchText,LPRECT lprc,UINT format);
| ~~~~^~~
mingw32-make[2]: *** [CMakeFiles\client.out.dir\build.make:76: CMakeFiles/client.out.dir/client/client.cpp.obj] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:150: CMakeFiles/client.out.dir/all] Error 2
mingw32-make: *** [Makefile:155: all] Error 2
Error: Process completed with exit code 1. as you can see when it builds the raylib folder just fine but when it starts to build my project it shows the conflict. The asio is also a git submodule from the networking asio c++ git repo. Here is the build error for Visual studio style build which is cmakes default on windows ( i think ) MSBuild version 17.7.2+d6990bcfa for .NET Framework
1>Checking Build System
Building Custom Rule D:/a/PewPewWar/PewPewWar/Desktop/raylib/src/external/glfw/src/CMakeLists.txt
context.c
init.c
input.c
monitor.c
platform.c
vulkan.c
window.c
egl_context.c
osmesa_context.c
null_init.c
null_monitor.c
null_window.c
null_joystick.c
win32_module.c
win32_time.c
win32_thread.c
win32_init.c
win32_joystick.c
win32_monitor.c
win32_window.c
Generating Code...
Compiling...
wgl_context.c
Generating Code...
glfw.vcxproj -> D:\a\PewPewWar\PewPewWar\Build\raylib\raylib\external\glfw\src\Release\glfw3.lib
Building Custom Rule D:/a/PewPewWar/PewPewWar/Desktop/raylib/src/CMakeLists.txt
rcore.c
rmodels.c
rshapes.c
rtext.c
rtextures.c
utils.c
raudio.c
Generating Code...
raylib.vcxproj -> D:\a\PewPewWar\PewPewWar\Build\raylib\raylib\Release\raylib.lib
Building Custom Rule D:/a/PewPewWar/PewPewWar/Desktop/CMakeLists.txt
client.cpp
Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately. For example:
- add -D_WIN32_WINNT=0x0601 to the compiler command line; or
- add _WIN32_WINNT=0x0601 to your project's Preprocessor Definitions.
Assuming _WIN32_WINNT=0x0601 (i.e. Windows 7 target).
C:\Program Files (x86)\Windows Kits\10\Include\10.0.20348.0\um\winuser.h(4706,1): error C2733: 'CloseWindow': you cannot overload a function with 'extern "C"' linkage [D:\a\PewPewWar\PewPewWar\Build\client.out.vcxproj]
D:\a\PewPewWar\PewPewWar\Desktop\raylib\src\raylib.h(942,12): message : see declaration of 'CloseWindow' [D:\a\PewPewWar\PewPewWar\Build\client.out.vcxproj]
C:\Program Files (x86)\Windows Kits\10\Include\10.0.20348.0\um\winuser.h(9310,1): error C2733: 'ShowCursor': you cannot overload a function with 'extern "C"' linkage [D:\a\PewPewWar\PewPewWar\Build\client.out.vcxproj]
D:\a\PewPewWar\PewPewWar\Desktop\raylib\src\raylib.h(998,12): message : see declaration of 'ShowCursor' [D:\a\PewPewWar\PewPewWar\Build\client.out.vcxproj]
D:\a\PewPewWar\PewPewWar\Desktop\client\client.cpp(89,4): error C2664: 'int DrawTextA(HDC,LPCSTR,int,LPRECT,UINT)': cannot convert argument 1 from 'const char [30]' to 'HDC' [D:\a\PewPewWar\PewPewWar\Build\client.out.vcxproj]
D:\a\PewPewWar\PewPewWar\Desktop\client\client.cpp(89,15): message : Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or parenthesized function-style cast [D:\a\PewPewWar\PewPewWar\Build\client.out.vcxproj]
C:\Program Files (x86)\Windows Kits\10\Include\10.0.20348.0\um\winuser.h(8172,1): message : see declaration of 'DrawTextA' [D:\a\PewPewWar\PewPewWar\Build\client.out.vcxproj]
D:\a\PewPewWar\PewPewWar\Desktop\client\client.cpp(89,4): message : while trying to match the argument list '(const char [30], int, int, int, Color)' [D:\a\PewPewWar\PewPewWar\Build\client.out.vcxproj]
Building Custom Rule D:/a/PewPewWar/PewPewWar/Desktop/CMakeLists.txt
server.cpp
Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately. For example:
- add -D_WIN32_WINNT=0x0601 to the compiler command line; or
- add _WIN32_WINNT=0x0601 to your project's Preprocessor Definitions.
Assuming _WIN32_WINNT=0x0601 (i.e. Windows 7 target).
server.out.vcxproj -> D:\a\PewPewWar\PewPewWar\Build\Release\server.out.exe
Error: Process completed with exit code 1. So this is the problem. Can anyone please help me how can i fix this problem. PS: if i remove the raylib from my project it builds on all the platform just fine on github actions. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Asio included the windows.h. |
Beta Was this translation helpful? Give feedback.
Asio included the windows.h.
my bad.