簡體   English   中英

使用 Clang / OLLVM 在 Linux 上交叉編譯 helloworld Windows 可執行文件時出現問題

[英]Issues when cross compiling helloworld Windows executable on Linux with Clang / OLLVM

我在 Linux/Ubuntu 系統上使用 Clang / OLLVM 編譯 Windows 應用程序時遇到問題,我知道我“可以”為此使用其他工具(MinGW 等......)但我想這樣做是因為我想使用OLLVM 提供的混淆。 但是我覺得 Clang/LLVM 在交叉編譯方面的文檔非常簡單(在 Linux 系統上編譯 Windows 可執行文件),並且正確設置是某種黑魔法:-(。

我已經建立了這個項目:

https://github.com/qtfreet00/llvm-obfuscator

而且我已經做了以下事情,老實說,我不明白這些標志中的大多數實際上是什么意思,因為有些似乎完全沒有記錄:

https://nosubstance.me/post/coding-windows-cpp-on-linux/

而且我似乎已經走到了盡頭(區分大小寫的問題包括使用<>而不是我修復的“”等......)但現在我被困在一些看起來相當容易解決的問題上。 當我嘗試使用以下標志進行構建時:

/home/puss/dev/clang-llvm-build/bin/clang -isystem "/home/puss/dev/ewdk/program files/windows kits/10/include/10.0.19041.0/km/crt" -isystem "/home/puss/dev/ewdk-insensitive/program files/windows kits/10/include/10.0.19041.0/shared" -isystem "/home/puss/dev/ewdk-insensitive/program files/windows kits/10/include/10.0.19041.0/ucrt" -isystem "/home/puss/dev/ewdk-insensitive/program files/windows kits/10/include/10.0.19041.0/um" -isystem "/home/puss/dev/msf-http-stager/header" -target i386-pc-windows-msvc -x c++ -fsyntax-only -ferror-limit=64 -fms-compatibility-version=19 -Wno-everything -Wno-unknown-pragmas -U__clang__ -U__clang_version__ -U__clang_major__ -U__clang_minor__ -U__clang_patchlevel__ -fms-extensions -std=c++14 -mllvm -bcf -x c++ -c /tmp/hello.cpp -o hello.o

我的 hello.cpp 文件如下所示:

#include <iostream>

int main() {
    std::cout << "Hello World!";
    return 0;
}

這是我得到的錯誤:

/tmp/hello.cpp:4:5: error: use of undeclared identifier 'std'
    std::cout << "Hello World!";
    ^
1 error generated.

我在這里確實有 iostream header,編譯器應該知道它,因為我使用指向它的 -isystem 標志指定了它:

/home/puss/dev/ewdk/program files/windows kits/10/include/10.0.19041.0/km/crt/iostream

看來我的問題與此類似:

https://github.com/JuliaInterop/Cxx.jl/issues/114

關於這里發生了什么的任何想法? 我還嘗試提取與此處描述的完全相同的 EWDK:

https://nosubstance.me/post/coding-windows-cpp-on-linux/

但是當我在我的 hello.cpp 文件上運行它時:

#!/bin/sh

/home/william/dev/clang-llvm-build/bin/clang -x c++ \
    --target=i386-pc-windows-msvc \
    -fsyntax-only \
    -ferror-limit=64 \
    -fms-compatibility-version=19 \
    -Wall \
    -Wextra \
    -Wno-unknown-pragmas \
    -U__clang__ \
    -U__clang_version__ \
    -U__clang_major__ \
    -U__clang_minor__ \
    -U__clang_patchlevel__ \
    -DWIN32 \
    -D_WINDOWS \
    -DNDEBUG \
    -D_MT \
    -D_X86_=1 \
    -DNOMINMAX \
    -D_WIN32_WINNT=0x0501 \
    -DWIN32_LEAN_AND_MEAN=1 \
    -D_CRT_SECURE_NO_WARNINGS=1 \
    -nostdinc \
    -isystem '/home/william/dev/ewdk1703-insensitive/program files/windows kits/10/include/10.0.15063.0/shared' \
    -isystem '/home/william/dev/ewdk1703-insensitive/program files/windows kits/10/include/10.0.15063.0/ucrt' \
    -isystem '/home/william/dev/ewdk1703-insensitive/program files/windows kits/10/include/10.0.15063.0/um' \
    -isystem '/home/william/dev/ewdk1703-insensitive/program files/microsoft visual studio 14.0/vc/include' \
    -isystem '/home/william/dev/ewdk1703-insensitive/program files/windows kits/10/include/10.0.15063.0/km/crt' \
    -c '/tmp/hello.cpp' -o 'hello.obj'

我還收到與“std”相關的錯誤:

/tmp/hello.cpp:4:5: error: use of undeclared identifier 'std'
    std::cout << "Hello World!";
    ^
1 error generated.

奇怪的是, iostream.h header 在這里(“km”):

'/home/william/dev/ewdk1703-insensitive/program files/windows kits/10/include/10.0.15063.0/km/crt'

這似乎與 Kernel 驅動程序有關,而不是用戶模式應用程序。

我終於能夠解決這個問題,似乎這是使用的問題:

<iostream> vs <iostream.h>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM