DescentDevelopers / Descent3

Descent 3 by Outrage Entertainment
GNU General Public License v3.0
2.73k stars 231 forks source link

[Build Failure]: Missing `afxwin.h` when building with `-D BUILD_EDITOR=ON` #472

Closed Jayman2000 closed 5 days ago

Jayman2000 commented 6 days ago

Build Version

v1.5 ae626b36eb6ad6f8ff3004cf4c23040406bf9c1f

Operating System Environment

CPU Environment

Description

If I try to build Descent 3 with -D BUILD_EDITOR=ON, then it fails with this error:

D:\Descent 3 build test\Descent3\editor\stdafx.h(31): fatal error C1083: Cannot open include file: 'afxwin.h': No such file or directory

Regression Status

I don’t know.

Steps to Reproduce

  1. Uninstall the Visual Studio Installer. This will help make sure that you don’t have any extra Visual Studio components installed that might prevent this bug from occurring.
  2. Follow Descent 3’s Windows build instructions. When performing the instructions, be sure to do the following:

    • Run the two commands that the instructions provide in order to install Visual Studio 2022 with the “Desktop development with C++” workload. This will also help make sure that you don’t have any extra Visual Studio components installed that might prevent this bug from occurring.
    • When you get to the part where it tells you to run the first cmake command, remember to add -D BUILD_EDITOR=ON to the end of the command-line.
Lgt2x commented 6 days ago

It's missing from the instructions but you need the Microsoft MFC component from the VS installer to build the editor, which is based on this framework. afxwin.h is a MFC header

winterheart commented 6 days ago

Probably need add these instructions to Descent3Editor target:

target_compile_definitions(Descent3Editor _AFXDLL)
set(CMAKE_MFC_FLAG 2) # or 1 for static building
add_executable(Descent3Editor WIN32 ${SRCS})

See https://cmake.org/cmake/help/v3.22/variable/CMAKE_MFC_FLAG.html