Кросс-компиляция программы C++ для Windows на Debian с помощью Clang и Mingw-w64.C++

Программы на C++. Форум разработчиков
Ответить Пред. темаСлед. тема
Anonymous
 Кросс-компиляция программы C++ для Windows на Debian с помощью Clang и Mingw-w64.

Сообщение Anonymous »

Я пытаюсь скомпилировать программу на C++ в Debian 12.05.00 с помощью clang для Windows. Когда я запускаю следующую команду:

Код: Выделить всё

clang++ --target=x86_64-w64-mingw32-g++ -o main.exe main.cpp
Я получаю следующий результат:

Код: Выделить всё

main.cpp:1:9: fatal error: 'iostream' file not found
#include
^~~~~~~~~~
1 error generated.
Буду благодарен за любую помощь в решении проблемы.
Что я уже пробовал:
< ol>
[*]Установка gcc, mingw-w64 и clang
[*]Компиляция программы с помощью clang: clang++ -o main main.cpp -> работает нормально
[*]Компиляция программы с помощью mingw-w64: x86_64-w64-mingw32-g++ -o main.exe main.cpp -> тоже работает нормально
[*]Компиляция с помощью clang и target: clang++ --target=x86_64-w64-mingw32-g++ -o main.exe main.cpp -> показывает указанную выше ошибку

Я также знаю, что clang должен найти файлы headers/lib. Короче говоря, я попытался найти библиотеки с помощью этой команды:

Код: Выделить всё

x86_64-w64-mingw32-g++ -o main.exe main.cpp --verbose
Я получаю следующий результат:

Код: Выделить всё

Using built-in specs.
COLLECT_GCC=x86_64-w64-mingw32-g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-w64-mingw32/12-win32/lto-wrapper
Target: x86_64-w64-mingw32
Configured with: ../../src/configure --build=x86_64-linux-gnu --prefix=/usr --includedir='/usr/include' --mandir='/usr/share/man' --infodir='/usr/share/info' --sysconfdir=/etc --localstatedir=/var --disable-option-checking --disable-silent-rules --libdir='/usr/lib/x86_64-linux-gnu' --libexecdir='/usr/lib/x86_64-linux-gnu' --disable-maintainer-mode --disable-dependency-tracking --prefix=/usr --enable-shared --enable-static --disable-multilib --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --libdir=/usr/lib --enable-libstdcxx-time=yes --with-tune=generic --with-headers --enable-version-specific-runtime-libs --enable-fully-dynamic-string --enable-libgomp --enable-languages=c,c++,fortran,objc,obj-c++,ada --enable-lto --enable-threads=win32 --program-suffix=-win32 --program-prefix=x86_64-w64-mingw32- --target=x86_64-w64-mingw32 --with-as=/usr/bin/x86_64-w64-mingw32-as --with-ld=/usr/bin/x86_64-w64-mingw32-ld --enable-libatomic --enable-libstdcxx-filesystem-ts=yes --enable-dependency-tracking SED=/bin/sed
Thread model: win32
Supported LTO compression algorithms: zlib
gcc version 12-win32 (GCC)
COLLECT_GCC_OPTIONS='-o' 'main.exe' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-w64-mingw32/12-win32/cc1plus -quiet -v -U_REENTRANT main.cpp -quiet -dumpbase main.cpp -dumpbase-ext .cpp -mtune=generic -march=x86-64 -version -o /tmp/cc24ZVrH.s
GNU C++17 (GCC) version 12-win32 (x86_64-w64-mingw32)
compiled by GNU C version 12.2.0, GMP version 6.2.1, MPFR version 4.1.1-p1, MPC version 1.3.1, isl version isl-0.25-GMP

warning: MPFR header version 4.1.1-p1 differs from library version 4.2.0.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/lib/gcc/x86_64-w64-mingw32/12-win32/../../../../x86_64-w64-mingw32/sys-include"
#include "..." search starts here:
#include   search starts here:
/usr/lib/gcc/x86_64-w64-mingw32/12-win32/include/c++
/usr/lib/gcc/x86_64-w64-mingw32/12-win32/include/c++/x86_64-w64-mingw32
/usr/lib/gcc/x86_64-w64-mingw32/12-win32/include/c++/backward
/usr/lib/gcc/x86_64-w64-mingw32/12-win32/include
/usr/lib/gcc/x86_64-w64-mingw32/12-win32/include-fixed
/usr/lib/gcc/x86_64-w64-mingw32/12-win32/../../../../x86_64-w64-mingw32/include
End of search list.
GNU C++17 (GCC) version 12-win32 (x86_64-w64-mingw32)
compiled by GNU C version 12.2.0, GMP version 6.2.1, MPFR version 4.1.1-p1, MPC version 1.3.1, isl version isl-0.25-GMP

warning: MPFR header version 4.1.1-p1 differs from library version 4.2.0.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 388fe3850a437d75cb1b8b3548fb400f
COLLECT_GCC_OPTIONS='-o' 'main.exe' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
/usr/bin/x86_64-w64-mingw32-as -v -o /tmp/ccxoZGfx.o /tmp/cc24ZVrH.s
GNU assembler version 2.40 (x86_64-w64-mingw32) using BFD version (GNU Binutils) 2.40
COMPILER_PATH=/usr/lib/gcc/x86_64-w64-mingw32/12-win32/:/usr/lib/gcc/x86_64-w64-mingw32/12-win32/:/usr/lib/gcc/x86_64-w64-mingw32/:/usr/lib/gcc/x86_64-w64-mingw32/12-win32/:/usr/lib/gcc/x86_64-w64-mingw32/:/usr/lib/gcc/x86_64-w64-mingw32/12-win32/../../../../x86_64-w64-mingw32/bin/
LIBRARY_PATH=/usr/lib/gcc/x86_64-w64-mingw32/12-win32/:/usr/lib/gcc/x86_64-w64-mingw32/12-win32/../../../../x86_64-w64-mingw32/lib/
COLLECT_GCC_OPTIONS='-o' 'main.exe' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir' 'main.'
/usr/lib/gcc/x86_64-w64-mingw32/12-win32/collect2 -plugin /usr/lib/gcc/x86_64-w64-mingw32/12-win32/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x86_64-w64-mingw32/12-win32/lto-wrapper -plugin-opt=-fresolution=/tmp/ccJna9iv.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lkernel32 -m i386pep -Bdynamic -o main.exe /usr/lib/gcc/x86_64-w64-mingw32/12-win32/../../../../x86_64-w64-mingw32/lib/crt2.o /usr/lib/gcc/x86_64-w64-mingw32/12-win32/crtbegin.o -L/usr/lib/gcc/x86_64-w64-mingw32/12-win32 -L/usr/lib/gcc/x86_64-w64-mingw32/12-win32/../../../../x86_64-w64-mingw32/lib /tmp/ccxoZGfx.o -lstdc++ -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -lkernel32 -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -lkernel32 /usr/lib/gcc/x86_64-w64-mingw32/12-win32/crtend.o
COLLECT_GCC_OPTIONS='-o' 'main.exe' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir' 'main.'

Итак, насколько я вижу, библиотеки расположены в:

Код: Выделить всё

LIBRARY_PATH=/usr/lib/gcc/x86_64-w64-mingw32/12-win32/
Бег:

Код: Выделить всё

clang++ --target=x86_64-pc-win64-mingw32 --sysroot=/usr/lib/gcc/x86_64-w64-mingw32/12-posix -o main.exe main.cpp --verbose
Доходность:

Код: Выделить всё

Debian clang version 14.0.6
Target: x86_64-pc-windows-gnu
Thread model: posix
InstalledDir: /usr/bin
"/usr/lib/llvm-14/bin/clang"  -cc1 -triple x86_64-pc-windows-gnu -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -mms-bitfields -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -v -fcoverage-compilation-dir=/home/lukas/Downloads -resource-dir /usr/lib/llvm-14/lib/clang/14.0.6 -isysroot /usr/lib/gcc/x86_64-w64-mingw32/12-posix -internal-isystem /usr/lib/gcc/x86_64-w64-mingw32/12-posix/x86_64-w64-mingw32/include/c++ -internal-isystem /usr/lib/gcc/x86_64-w64-mingw32/12-posix/x86_64-w64-mingw32/include/c++/x86_64-w64-mingw32 -internal-isystem /usr/lib/gcc/x86_64-w64-mingw32/12-posix/x86_64-w64-mingw32/include/c++/backward -internal-isystem /usr/lib/gcc/x86_64-w64-mingw32/12-posix/x86_64-w64-mingw32/include/c++/ -internal-isystem /usr/lib/gcc/x86_64-w64-mingw32/12-posix/x86_64-w64-mingw32/include/c++//x86_64-w64-mingw32 -internal-isystem /usr/lib/gcc/x86_64-w64-mingw32/12-posix/x86_64-w64-mingw32/include/c++//backward -internal-isystem /usr/lib/gcc/x86_64-w64-mingw32/12-posix/include/c++/ -internal-isystem /usr/lib/gcc/x86_64-w64-mingw32/12-posix/include/c++//x86_64-w64-mingw32 -internal-isystem /usr/lib/gcc/x86_64-w64-mingw32/12-posix/include/c++//backward -internal-isystem include/c++ -internal-isystem include/c++/x86_64-w64-mingw32 -internal-isystem include/c++/backward -internal-isystem /usr/lib/llvm-14/lib/clang/14.0.6/include -internal-isystem /usr/lib/gcc/x86_64-w64-mingw32/12-posix/x86_64-w64-mingw32/sys-root/mingw/include -internal-isystem /usr/lib/gcc/x86_64-w64-mingw32/12-posix/x86_64-w64-mingw32/include -internal-isystem /usr/lib/gcc/x86_64-w64-mingw32/12-posix/include -fdeprecated-macro -fdebug-compilation-dir=/home/lukas/Downloads -ferror-limit 19 -fno-use-cxa-atexit -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -exception-model=seh -fcolor-diagnostics -faddrsig -o /tmp/main-e19f09.o -x c++ main.cpp
clang -cc1 version 14.0.6 based upon LLVM 14.0.6 default target x86_64-pc-linux-gnu
ignoring nonexistent directory "/usr/lib/gcc/x86_64-w64-mingw32/12-posix/x86_64-w64-mingw32/include/c++"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-w64-mingw32/12-posix/x86_64-w64-mingw32/include/c++/x86_64-w64-mingw32"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-w64-mingw32/12-posix/x86_64-w64-mingw32/include/c++/backward"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-w64-mingw32/12-posix/x86_64-w64-mingw32/include/c++/"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-w64-mingw32/12-posix/x86_64-w64-mingw32/include/c++//x86_64-w64-mingw32"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-w64-mingw32/12-posix/x86_64-w64-mingw32/include/c++//backward"
ignoring nonexistent directory "include/c++"
ignoring nonexistent directory "include/c++/x86_64-w64-mingw32"
ignoring nonexistent directory "include/c++/backward"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-w64-mingw32/12-posix/x86_64-w64-mingw32/sys-root/mingw/include"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-w64-mingw32/12-posix/x86_64-w64-mingw32/include"
#include "..." search starts here:
#include  search starts here:
/usr/lib/gcc/x86_64-w64-mingw32/12-posix/include/c++
/usr/lib/gcc/x86_64-w64-mingw32/12-posix/include/c++//x86_64-w64-mingw32
/usr/lib/gcc/x86_64-w64-mingw32/12-posix/include/c++//backward
/usr/lib/llvm-14/lib/clang/14.0.6/include
/usr/lib/gcc/x86_64-w64-mingw32/12-posix/include
End of search list.
In file included from main.cpp:1:
In file included from /usr/lib/gcc/x86_64-w64-mingw32/12-posix/include/c++/iostream:39:
In file included from /usr/lib/gcc/x86_64-w64-mingw32/12-posix/include/c++/ostream:38:
In file included from /usr/lib/gcc/x86_64-w64-mingw32/12-posix/include/c++/ios:38:
In file included from /usr/lib/gcc/x86_64-w64-mingw32/12-posix/include/c++/iosfwd:40:
In file included from /usr/lib/gcc/x86_64-w64-mingw32/12-posix/include/c++/bits/postypes.h:40:
/usr/lib/gcc/x86_64-w64-mingw32/12-posix/include/c++/cwchar:44:10: fatal error: 'wchar.h' file not found
На этом этапе мне понадобится помощь, чтобы понять, что я делаю неправильно. Я установил не те версии или что еще мне нужно сделать, чтобы найти библиотеки. Я не обязательно ищу готовый инструмент, а чтобы понять, что мне нужно делать.

Подробнее здесь: https://stackoverflow.com/questions/783 ... -mingw-w64
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение
  • В mingw/msys2 используйте «pip install abc» или «pacman -S mingw-w64-i686-python-abc»?
    Anonymous » » в форуме Python
    0 Ответы
    98 Просмотры
    Последнее сообщение Anonymous
  • Как использовать pip для установки пакетов с помощью компилятора MinGW-w64 в Windows 7?
    Anonymous » » в форуме Python
    0 Ответы
    27 Просмотры
    Последнее сообщение Anonymous
  • Как использовать PIP для установки пакетов с помощью компилятора Mingw-W64 в Windows 7?
    Anonymous » » в форуме Python
    0 Ответы
    4 Просмотры
    Последнее сообщение Anonymous
  • Установка последней версии mingw-w64 в Windows
    Anonymous » » в форуме C++
    0 Ответы
    16 Просмотры
    Последнее сообщение Anonymous
  • Как скомпилировать приложение Vulkan с Mingw-W64 с использованием Cmake от Linux в Target Windows?
    Anonymous » » в форуме C++
    0 Ответы
    1 Просмотры
    Последнее сообщение Anonymous

Вернуться в «C++»