【发布时间】:2021-09-29 00:51:07
【问题描述】:
https://github.com/kyledavis124/guide/tree/refactor
我正在尝试将 wxWidgets 作为子目录添加到我的项目中。我不断收到错误,
"C:\Program Files (x86)\JetBrains\CLion 2021.1.3\bin\cmake\win\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - NMake Makefiles" C:\Project\guide
-- cotire 1.8.0 loaded.
-- Which libraries should wxWidgets use?
wxUSE_STL: OFF (use C++ STL classes)
wxUSE_REGEX: builtin (enable support for wxRegEx class)
wxUSE_ZLIB: builtin (use zlib for LZW compression)
wxUSE_EXPAT: builtin (use expat for XML parsing)
wxUSE_LIBJPEG: builtin (use libjpeg (JPEG file format))
wxUSE_LIBPNG: builtin (use libpng (PNG image format))
wxUSE_LIBTIFF: builtin (use libtiff (TIFF file format))
wxUSE_LIBLZMA: OFF (use liblzma for LZMA compression)
-- Configured wxWidgets 3.1.5 for Windows-10.0.19043
Min OS Version required at runtime: Windows Vista / Windows Server 2008
Which GUI toolkit should wxWidgets use? msw
Should wxWidgets be compiled into single library? OFF
Should wxWidgets be linked as a shared library? ON
Should wxWidgets support Unicode? ON
What wxWidgets compatibility level should be used? 3.0
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Project/guide/build
Problems were encountered while collecting compiler information:
C:\Users\kyled\AppData\Local\Temp\compiler-file3714472391677385802: fatal error C1083: Cannot open include file: 'C:\Project\guide\build\vendor\wxwidgets\libs\adv\cotire\wxadv_CXX_prefix.hxx': No such file or directory
C:\Users\kyled\AppData\Local\Temp\compiler-file3714472391677385802: fatal error C1083: Cannot open include file: 'C:\Project\guide\build\vendor\wxwidgets\libs\aui\cotire\wxaui_CXX_prefix.hxx': No such file or directory
C:\Users\kyled\AppData\Local\Temp\compiler-file3714472391677385802: fatal error C1083: Cannot open include file: 'C:\Project\guide\build\vendor\wxwidgets\libs\base\cotire\wxbase_CXX_prefix.hxx': No such file or directory
C:\Users\kyled\AppData\Local\Temp\compiler-file3714472391677385802: fatal error C1083: Cannot open include file: 'C:\Project\guide\build\vendor\wxwidgets\libs\core\cotire\wxcore_CXX_prefix.hxx': No such file or directory
C:\Users\kyled\AppData\Local\Temp\compiler-file3714472391677385802: fatal error C1083: Cannot open include file: 'C:\Project\guide\build\vendor\wxwidgets\libs\gl\cotire\wxgl_CXX_prefix.hxx': No such file or directory
C:\Users\kyled\AppData\Local\Temp\compiler-file3714472391677385802: fatal error C1083: Cannot open include file: 'C:\Project\guide\build\vendor\wxwidgets\libs\html\cotire\wxhtml_CXX_prefix.hxx': No such file or directory
C:\Users\kyled\AppData\Local\Temp\compiler-file3714472391677385802: fatal error C1083: Cannot open include file: 'C:\Project\guide\build\vendor\wxwidgets\libs\media\cotire\wxmedia_CXX_prefix.hxx': No such file or directory
C:\Users\kyled\AppData\Local\Temp\compiler-file3714472391677385802: fatal error C1083: Cannot open include file: 'C:\Project\guide\build\vendor\wxwidgets\libs\net\cotire\wxnet_CXX_prefix.hxx': No such file or directory
C:\Users\kyled\AppData\Local\Temp\compiler-file3714472391677385802: fatal error C1083: Cannot open include file: 'C:\Project\guide\build\vendor\wxwidgets\libs\propgrid\cotire\wxpropgrid_CXX_prefix.hxx': No such file or directory
C:\Users\kyled\AppData\Local\Temp\compiler-file3714472391677385802: fatal error C1083: Cannot open include file: 'C:\Project\guide\build\vendor\wxwidgets\libs\qa\cotire\wxqa_CXX_prefix.hxx': No such file or directory
C:\Users\kyled\AppData\Local\Temp\compiler-file3714472391677385802: fatal error C1083: Cannot open include file: 'C:\Project\guide\build\vendor\wxwidgets\libs\ribbon\cotire\wxribbon_CXX_prefix.hxx': No such file or directory
C:\Users\kyled\AppData\Local\Temp\compiler-file3714472391677385802: fatal error C1083: Cannot open include file: 'C:\Project\guide\build\vendor\wxwidgets\libs\richtext\cotire\wxrichtext_CXX_prefix.hxx': No such file or directory
C:\Users\kyled\AppData\Local\Temp\compiler-file3714472391677385802: fatal error C1083: Cannot open include file: 'C:\Project\guide\build\vendor\wxwidgets\libs\stc\cotire\wxscintilla_CXX_prefix.hxx': No such file or directory
C:\Users\kyled\AppData\Local\Temp\compiler-file3714472391677385802: fatal error C1083: Cannot open include file: 'C:\Project\guide\build\vendor\wxwidgets\libs\stc\cotire\wxstc_CXX_prefix.hxx': No such file or directory
C:\Users\kyled\AppData\Local\Temp\compiler-file3714472391677385802: fatal error C1083: Cannot open include file: 'C:\Project\guide\build\vendor\wxwidgets\libs\webview\cotire\wxwebview_CXX_prefix.hxx': No such file or directory
C:\Users\kyled\AppData\Local\Temp\compiler-file3714472391677385802: fatal error C1083: Cannot open include file: 'C:\Project\guide\build\vendor\wxwidgets\libs\xml\cotire\wxxml_CXX_prefix.hxx': No such file or directory
C:\Users\kyled\AppData\Local\Temp\compiler-file3714472391677385802: fatal error C1083: Cannot open include file: 'C:\Project\guide\build\vendor\wxwidgets\libs\xrc\cotire\wxxrc_CXX_prefix.hxx': No such file or directory
[Finished]
我怎样才能让它工作?
cmake_minimum_required(VERSION 3.6 FATAL_ERROR)
project(guide LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(wxWidgets_ROOT_DIR ${PROJECT_SOURCE_DIR}/vendor/wxwidgets)
set(wxWidgets_LIB_DIR ${PROJECT_SOURCE_DIR}/vendor/wxwidgets/lib/vc_x64_lib)
set(wxWidgets_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/vendor/wxwidgets/include)
set(wxWidgets_CONFIGURATION msw)
add_subdirectory(vendor)
add_subdirectory(Tests)
add_subdirectory(src)
我确定错误必须在 CMakeLists 文件中。我是不是忘记了什么?
我将 CMakeLists 与 Visual Studio 2019 编译器一起使用。我的 IDE 是 CLion。我在 Windows 上,但这应该在所有平台上构建。
我想将 wxWidgets 的源代码添加为我的项目的子目录。这样,当有人签出我的项目时,如果他们没有 wxWidgets,它就会构建它。
编辑:
我设法通过从根 CMakeLists.txt 文件中删除 add_subdirectory(vendor) 来解决我的问题。它现在可以正确编译和运行。
【问题讨论】:
-
请将您的代码添加到问题帖中。这是 Stack Overflow 的要求,而代码的链接 不能满足该要求。请注意,我们不需要您的生产代码。相反,我们期待minimal reproducible example。
-
@KyleDavis,我猜你想使用
CMake来注册?如果是这样-请发布CMakeList.txt的相关内容。另外,您使用的是什么编译器/版本,您是否能够直接构建wxWidgets及其minimal示例(不使用CMake)? (我看到您正在使用 MSVC - 您是否知道 wxWidgets 为构建提供 Makefile,因此无需使用 CMake 重新生成它。只需通过执行cd wxWidgets\build\msw && nmake -f makefile.vcc来启动构建。
标签: windows c++11 cmake visual-studio-2019 wxwidgets