CMake WxWidgets项目成功地在Linux上构建,但没有在Windows上构建
CMake WxWidgets project successfully built on linux but not on windows
我已经设法在Ubuntu 19.10上构建了一个基于CMake的WxWidgets,但在Windows 10上失败了,说它找不到WxWidgets,尽管我已经成功地构建了它(静态,发布和Unicode支持(。
WxWidgets 路径C:wxWidgets-3.1.3
,构建目录C:wxWidgets-3.1.3msw-release
。
生成文件是
cmake_minimum_required(VERSION 3.0)
project(ChessPgnReviser VERSION 0.1.0)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
ADD_DEFINITIONS(-Wall -Wno-sign-compare -O2)
set(SRCS
src/main.cpp
)
set (HEADERS
)
message( "--Root--" ${wxWidgets_ROOT_DIR} )
message( "--Lib dir--" ${wxWidgets_LIB_DIR} )
add_executable(ChessPgnReviser ${SRCS} ${HEADERS})
find_package(wxWidgets COMPONENTS net gl core base)
if(wxWidgets_FOUND)
include(${wxWidgets_USE_FILE})
target_link_libraries(ChessPgnReviser ${wxWidgets_LIBRARIES})
else()
message(FATAL_ERROR "Failed to find WxWidgets library")
endif()
我正在使用 Msys 64 位来编译项目。在其子文件夹等/配置文件的底部,我添加了
PATH=$PATH:/c/dev/cmake/bin
wxWidgets_ROOT_DIR=/c/wxWidgets-3.1.3
wxWidgets_LIBRARIES=$wxWidgets_ROOT_DIR/msw-release/lib
wxWidgets_LIB_DIR=$wxWidgets_ROOT_DIR/msw-release/lib
wxWidgets_INCLUDE_DIRS=$wxWidgets_ROOT_DIR/include
所以我试过了
$ mkdir build && cd build
$ cmake .. -G "MinGW Makefiles"
-- The C compiler identification is GNU 10.1.0
-- The CXX compiler identification is GNU 10.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/msys64/mingw64/bin/gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/msys64/mingw64/bin/g++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
--Root--
--Lib dir--
-- Could NOT find wxWidgets (missing: wxWidgets_LIBRARIES wxWidgets_INCLUDE_DIRS net gl core base)
CMake Error at CMakeLists.txt:27 (message):
Failed to find WxWidgets library
-- Configuring incomplete, errors occurred!
See also "C:/Users/laure/Documents/Programmation/ProjetsPersos/Cpp/ChessPgnReviserWxWidgets/build/CMakeFiles/CMakeOutput.log".
另外,多亏了@squareskittles,我还尝试了:
$ cmake .. -G "MinGW Makefiles" -DwxWidgets_ROOT_DIR="C:wxWidgets-3.1.3" -DwxWidgets_LIB_DIR="C:wxWidgets-3.1.3msw-releaselib"
-- The C compiler identification is GNU 10.1.0
-- The CXX compiler identification is GNU 10.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/msys64/mingw64/bin/gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/msys64/mingw64/bin/g++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
--Root--C:wxWidgets-3.1.3
--Lib dir--C:wxWidgets-3.1.3msw-releaselib
-- Could NOT find wxWidgets (missing: wxWidgets_LIBRARIES wxWidgets_INCLUDE_DIRS net gl core base)
CMake Error at CMakeLists.txt:27 (message):
Failed to find WxWidgets library
-- Configuring incomplete, errors occurred!
See also "C:/Users/laure/Documents/Programmation/ProjetsPersos/Cpp/ChessPgnReviserWxWidgets/build/CMakeFiles/CMakeOutput.log".
你可以找到 msw-release 文件夹的内容 : 那里。
也:
$ ls /c/wxWidgets-3.1.3/msw-release/lib/
libwx_baseu_net-3.1.a libwx_baseu-3.1.a libwx_mswu_aui-3.1.a libwx_mswu_gl-3.1.a libwx_mswu_media-3.1.a libwx_mswu_qa-3.1.a libwx_mswu_richtext-3.1.a libwx_mswu_webview-3.1.a libwxregexu-3.1.a wx
libwx_baseu_xml-3.1.a libwx_mswu_adv-3.1.a libwx_mswu_core-3.1.a libwx_mswu_html-3.1.a libwx_mswu_propgrid-3.1.a libwx_mswu_ribbon-3.1.a libwx_mswu_stc-3.1.a libwx_mswu_xrc-3.1.a libwxscintilla-3.1.a
那我是不是忘了什么?
要正确检测 wxWidgets,您需要wx-config
.
存在 Windows 版本的wx-config
,可以从以下位置下载:https://github.com/kowey/wx-config-win
要wx-config
知道您的 wxWidgets 在哪里,您需要设置以下环境变量:
WXWIN
(在您的情况下C:/wxWidgets-3.1.3
(WXCFG
(在您的情况下是like msw/gcc_mswu
(。
相关文章:
- 无法使用Qt Creator在Windows中构建yaml-cpp
- CMake WxWidgets项目成功地在Linux上构建,但没有在Windows上构建
- 使用 VS2015 在 Windows 10 上构建 Fortran .lib x64 位并将其链接到 C++
- 在Windows 10上使用Visual Studio 2019构建的Tesseract API c ++程序在Wind
- 如何在 Linux for Windows 上通过 MinGW 构建静态 ICU 的 Boost
- meson-build:wxWidgets 资源文件,用于 Windows 未构建
- 使用 MinGW 在 Windows 上构建 GLEW 时遇到问题
- 坚持编译QDoc以在Windows上构建qt5
- MSYS2 MinGW64 在 Windows 上构建 GMP/MPFR 作为静态库,并将它们链接到使用 CL 编译的
- 如何使用PJSIP库在MINGW上安装NASM,以构建Windows应用程序的OpenH264库
- 在开始使用 ISOCPP.net C++ 构建 Windows 时遇到问题 (Nuwen)
- 构建 Windows 7 驱动程序时出错
- 关于构建windows dll的建议
- 在使用 CMake 构建 Windows DLL 期间运行单元测试
- QtCreator如何在构建Windows应用程序时避开控制台窗口
- 如何使用C++(非控制台应用程序)在Eclipse中构建Windows GUI应用程序
- 使用cmake构建Windows DLL的简单示例
- 使用Visual c++ 2015工具集构建Windows/Windows Phone 8.1
- Boost-Build:从linux构建windows可执行文件
- visual在没有运行时的情况下构建windows c++库