Я бы хотел скомпилировать учебник Hello World для Windows. Я следовал инструкциям на wxWidgets вики: загрузил исходные файлы, скомпилировал его, используя
./configure --prefix=/usr/x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --build=x86_64-linux && make && sudo make install
Я использую CLion IDE, а он использует CMake, поэтому я изменил свой CMakeList; Txt на:
cmake_minimum_required(VERSION 3.15)
project(wxWidgets)
set(CMAKE_CXX_STANDARD 20)
find_package(wxWidgets REQUIRED COMPONENTS net core base)
include(${wxWidgets_USE_FILE})
if(WIN32)
set(SRCS ${SRCS} minimal.rc)
endif(WIN32)
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
add_executable(wxWidgets WIN32 main.cpp)
target_link_libraries(wxWidgets ${wxWidgets_LIBRARIES})
У меня возникли некоторые ошибки при компиляции (мне кажется, отсутствует файл заголовков). Я не очень дружу с CMake, особенно с импортом и компоновкой внешних библиотек ....
Здесь вы можете увидеть ошибки:
In file included from /usr/include/wx-3.0/wx/defs.h:27,
from /usr/include/wx-3.0/wx/wxprec.h:12,
from /home/ubuntu/Dev/C++/wxWidgets/main.cpp:3:
/usr/include/wx-3.0/wx/platform.h:438:13: fatal error: wx/msw/libraries.h: No such file or folder
438 | # include "wx/msw/libraries.h"
| ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[3]: *** [CMakeFiles/wxWidgets.dir/build.make:63: CMakeFiles/wxWidgets.dir/main.cpp.o] Error 1
make[2]: *** [CMakeFiles/Makefile2:76: CMakeFiles/wxWidgets.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/wxWidgets.dir/rule] Error 2
make: *** [Makefile:118: wxWidgets] Error 2
Я хотел бы заметить, что у меня тоже есть компьютер Windows, и я мог бы легко перейти к windows и скомпилировать его здесь. Но это не моя цель, я действительно хочу понять, как работает процесс компоновки и кросс-компиляции.
РЕДАКТИРОВАТЬ:
После обновления моего CMakeList это выглядит как все файлы найдены, но теперь я получил много ошибок неопределенных вещей:
CMakeList:
cmake_minimum_required(VERSION 3.15)
project(wxWidgets)
find_package(wxWidgets REQUIRED COMPONENTS net core base)
include(${wxWidgets_USE_FILE})
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_PREFIX_PATH )
if(WIN32)
set(SRCS ${SRCS} minimal.rc)
endif(WIN32)
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
add_executable(wxWidgets WIN32 main.cpp)
target_include_directories(wxWidgets PRIVATE /usr/include/wx-3.0_win/include/wx-3.1)
target_link_libraries(wxWidgets ${wxWidgets_LIBRARIES})
Ошибки:
In file included from /usr/include/wx-3.0_win/include/wx-3.1/wx/platform.h:529,
from /usr/include/wx-3.0_win/include/wx-3.1/wx/defs.h:45,
from /usr/include/wx-3.0_win/include/wx-3.1/wx/wxprec.h:12,
from /home/ubuntu/Dev/C++/wxWidgets/main.cpp:3:
/usr/include/wx-3.0_win/include/wx-3.1/wx/chkconf.h:282:9: error: #error "wxUSE_SECRETSTORE must be defined, please read comment near the top of this file."
282 | # error "wxUSE_SECRETSTORE must be defined, please read comment near the top of this file."
| ^~~~~
/usr/include/wx-3.0_win/include/wx-3.1/wx/chkconf.h:322:9: error: #error "wxUSE_STD_CONTAINERS_COMPATIBLY must be defined, please read comment near the top of this file."
322 | # error "wxUSE_STD_CONTAINERS_COMPATIBLY must be defined, please read comment near the top of this file."
| ^~~~~
/usr/include/wx-3.0_win/include/wx-3.1/wx/chkconf.h:378:9: error: #error "wxUSE_UNSAFE_WXSTRING_CONV must be defined, please read comment near the top of this file."
378 | # error "wxUSE_UNSAFE_WXSTRING_CONV must be defined, please read comment near the top of this file."
| ^~~~~
/usr/include/wx-3.0_win/include/wx-3.1/wx/chkconf.h:446:9: error: #error "wxUSE_ADDREMOVECTRL must be defined, please read comment near the top of this file."
446 | # error "wxUSE_ADDREMOVECTRL must be defined, please read comment near the top of this file."
| ^~~~~
/usr/include/wx-3.0_win/include/wx-3.1/wx/chkconf.h:454:9: error: #error "wxUSE_ACTIVITYINDICATOR must be defined, please read comment near the top of this file."
454 | # error "wxUSE_ACTIVITYINDICATOR must be defined, please read comment near the top of this file."
| ^~~~~
/usr/include/wx-3.0_win/include/wx-3.1/wx/chkconf.h:988:9: error: #error "wxUSE_PRIVATE_FONTS must be defined, please read comment near the top of this file."
988 | # error "wxUSE_PRIVATE_FONTS must be defined, please read comment near the top of this file."
| ^~~~~
In file included from /usr/include/wx-3.0_win/include/wx-3.1/wx/chkconf.h:1268,
from /usr/include/wx-3.0_win/include/wx-3.1/wx/platform.h:529,
from /usr/include/wx-3.0_win/include/wx-3.1/wx/defs.h:45,
from /usr/include/wx-3.0_win/include/wx-3.1/wx/wxprec.h:12,
from /home/ubuntu/Dev/C++/wxWidgets/main.cpp:3:
/usr/include/wx-3.0_win/include/wx-3.1/wx/msw/chkconf.h:27:10: error: #error "wxUSE_WINRT must be defined."
27 | # error "wxUSE_WINRT must be defined."
| ^~~~~
/usr/include/wx-3.0_win/include/wx-3.1/wx/msw/chkconf.h:43:9: error: #error "wxUSE_DBGHELP must be defined"
43 | # error "wxUSE_DBGHELP must be defined"
| ^~~~~
/usr/include/wx-3.0_win/include/wx-3.1/wx/msw/chkconf.h:107:9: error: #error "wxUSE_TASKBARBUTTON must be defined."
107 | # error "wxUSE_TASKBARBUTTON must be defined."
| ^~~~~
/usr/include/wx-3.0_win/include/wx-3.1/wx/msw/chkconf.h:123:10: error: #error "wxUSE_WINSOCK2 must be defined."
123 | # error "wxUSE_WINSOCK2 must be defined."
| ^~~~~
/usr/include/wx-3.0_win/include/wx-3.1/wx/msw/chkconf.h:386:13: error: #error "wxUSE_DRAG_AND_DROP requires wxUSE_OLE"
386 | # error "wxUSE_DRAG_AND_DROP requires wxUSE_OLE"
| ^~~~~
/usr/include/wx-3.0_win/include/wx-3.1/wx/msw/chkconf.h:397:13: error: #error "wxMediaCtl requires wxActiveXContainer"
397 | # error "wxMediaCtl requires wxActiveXContainer"
| ^~~~~
In file included from /usr/include/wx-3.0_win/include/wx-3.1/wx/platform.h:529,
from /usr/include/wx-3.0_win/include/wx-3.1/wx/defs.h:45,
from /usr/include/wx-3.0_win/include/wx-3.1/wx/wxprec.h:12,
from /home/ubuntu/Dev/C++/wxWidgets/main.cpp:3:
/usr/include/wx-3.0_win/include/wx-3.1/wx/chkconf.h:1305:13: error: #error "2.8.X compatibility requires 3.0.X compatibility"
1305 | # error "2.8.X compatibility requires 3.0.X compatibility"
| ^~~~~
In file included from /usr/include/wx-3.0_win/include/wx-3.1/wx/wxprec.h:12,
from /home/ubuntu/Dev/C++/wxWidgets/main.cpp:3:
/usr/include/wx-3.0_win/include/wx-3.1/wx/defs.h: In function ‘wxUIntPtr wxPtrToUInt(const void*)’:
/usr/include/wx-3.0_win/include/wx-3.1/wx/defs.h:906:41: error: cast from ‘const void*’ to ‘wxUIntPtr’ {aka ‘long unsigned int’} loses precision [-fpermissive]
906 | return reinterpret_cast<wxUIntPtr>(p);
| ^