我使用window10和vs code编译了一些源代码。 我可以编译代码,但是当我运行 .exe 文件时。什么都不显示。 我收到了这个错误。
我的cmakefile如下:
cmake_minimum_required(VERSION 3.11.3)
set(CMAKE_CXX_STANDARD 17)
project(membot)
set(wxWidgets_ROOT_DIR "C:/wxWidgets-3.1.4")
set(wxWidgets_LIB_DIR "C:/wxWidgets-3.1.4/lib/gcc_dll"
CACHE PATH "wxWidgets_LIB_DIR ")
find_package(wxWidgets REQUIRED COMPONENTS core base)
include(${wxWidgets_USE_FILE})
file(GLOB project_SRCS src/*.cpp)
add_executable(membot ${project_SRCS})
target_link_libraries(membot ${wxWidgets_LIBRARIES})
target_include_directories(membot PRIVATE ${wxWidgets_INCLUDE_DIRS})
不知道怎么解决。我也尝试在 c_cpp_properties.json 中包含路径,但仍然不起作用。
答案 0 :(得分:0)
我找到了我的解决方案。
find_package(wxWidgets REQUIRED gl core base OPTIONAL_COMPONENTS net)
而不是 find_package(wxWidgets REQUIRED COMPONENTS core base)
我最终的cmakefile.txt是这样的
cmake_minimum_required(VERSION 3.11.3)
set(CMAKE_CXX_STANDARD 17)
project(membot)
set(wxWidgets_ROOT_DIR "C:/wxWidgets-3.1.4")
set(wxWidgets_LIB_DIR "C:/wxWidgets-3.1.4/lib/gcc_dll")
find_package(wxWidgets REQUIRED gl core base OPTIONAL_COMPONENTS net)
include(${wxWidgets_USE_FILE})
file(GLOB project_SRCS src/*.cpp)
add_executable(membot ${project_SRCS})
target_link_libraries(membot ${wxWidgets_LIBRARIES})
target_include_directories(membot PRIVATE ${wxWidgets_INCLUDE_DIRS})
mingw32-make -f makefile.gcc SHARED=1 UNICODE=1 BUILD=release clean
清理动态库并使用 mingw32-make -f makefile.gcc SHARED=0 UNICODE=1 BUILD=release clean
清理静态库。然后我使用这个 mingw32-make -j8 -f makefile.gcc BUILD=release SHARED=0 UNICODE=1 VENDOR=custom
来构建静态库。cmake -G "MinGW Makefiles" ..
和 make
编译源代码。成功了。