编译pgAgent遇wx/setup.h缺失错误,寻求解决方法
wx/setup.h Missing Error When Compiling pgAgent 3.4.0 Hey, let's tackle that wx/setup.h missing error you're hitting while compiling pgAgent 3.4.0. This is a common compatibility hiccup between the older wxWidgets 2.8 and Visual Studio 2017 (VC15), but we can work through it step by step:
1. Adapt wxWidgets 2.8 for VC15 Compatibility
wxWidgets 2.8 doesn't natively support VS2017, so we need to manually set up the critical setup.h file:
- Head to
F:\pgbuild\wxWidgets\include\wx\msw, copysetup0.h, and rename the copy tosetup.h. - Open this new
setup.hand add VC15 (VS2017) support by inserting these lines:// Add VC15 (VS2017) compiler detection #if defined(_MSC_VER) && (_MSC_VER >= 1910) #define __VISUALC15__ #define wxUSE_COMPILER_TLS 1 #endif - Double-check that
wxUSE_DYNAMIC_LINKINGmatches your wxWidgets build mode: set it to0for static builds,1for dynamic builds.
2. Recompile wxWidgets and Verify File Paths
Your earlier compile of wx_vc15.sln might not have generated the correct directory structure. Let's fix that:
- Open
F:\pgbuild\wxWidgets\build\msw\wx_vc15.sln. Right-click the solution, go to Properties, and confirm all projects are set to Debug configuration and the correct platform (x86 if your PostgreSQL 9.6 is 32-bit, x64 if it's 64-bit). - Rebuild the entire solution. After it finishes, check that
F:\pgbuild\wxWidgets\lib\vc_lib\mswd\wx\exists and contains your modifiedsetup.h. If it's missing, manually copy thesetup.hyou edited into that folder.
3. Correct pgAgent's CMake Configuration
The pgAgent CMake script might not be picking up the wxWidgets path correctly for VC15. Let's manually set those values:
- Open CMake GUI, set the source directory to
F:\pgbuild\pgAgent-3.4.0and the build directory to something likeF:\pgbuild\pgAgent-build. - Click Configure, select
Visual Studio 15 2017as your generator. Once that finishes, find these settings in the configuration list and update them:wxWidgets_ROOT_DIR: Set toF:\pgbuild\wxWidgetswxWidgets_LIB_DIR: Manually point toF:\pgbuild\wxWidgets\lib\vc_libwxWidgets_CONFIGURATION: Set tomswd(matches the Debug static library we built)
- Click Configure again to make sure there are no red errors, then click Generate to create the updated solution file.
4. Double-Check Environment Variables and Build Order
- Make sure your
WXWINandwxMSWenvironment variables are both set toF:\pgbuild\wxWidgets, then restart Visual Studio—it won't pick up new environment variables until you do. - Open the generated pgAgent solution. If there are any wxWidgets-related dependency projects, build those first before compiling the main pgAgent project.
Bonus Tip
pgAgent 3.4.0 is pretty old, and it was designed for older toolchains. If you're still hitting snags after all this, consider downgrading to Visual Studio 2015 (VC14)—it's the latest VS version that wxWidgets 2.8 officially supports, and it'll save you a lot of compatibility hoops.
内容的提问来源于stack exchange,提问作者arthur

