[英]A compilation error occurs when using clang in a Windows environment
I compliation the code with Vscode.我用 Vscode 编译代码。 The
clang -v
: clang -v
:
clang version 14.0.3
Target: x86_64-w64-windows-gnu
Thread model: posix
InstalledDir: C:/msys64/mingw64/bin
You can see I get clang form msys.你可以看到我从 msys 得到了 clang。
The file I compliate use such header file:我编译的文件使用这样的 header 文件:
#include <windows.h>
#include <windowsx.h>
#include <tchar.h>
#include <d2d1.h>
The task I use:我使用的任务:
"args": [
"-fdiagnostics-color=always",
"C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.22000.0\\um\\x86\\user32.lib",
"C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.22000.0\\um\\x86\\ole32.lib",
"C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.22000.0\\um\\x86\\d2d1.lib",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"-mwindows"
],
And the complier messages:和编译器消息:
C:\msys64\mingw64\bin\clang-cpp.exe -fdiagnostics-color=always "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22000.0\um\x86\user32.lib" "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22000.0\um\x86\ole32.lib" "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22000.0\um\x86\d2d1.lib" -g C:\Users\cookie\Desktop\GameEngineFromScratch\Platform\Windows\helloengine_d2d.cpp -o C:\Users\cookie\Desktop\GameEngineFromScratch\Platform\Windows\helloengine_d2d.exe -mwindows
clang-cpp: warning: C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22000.0\um\x86\user32.lib: 'linker' input unused in cpp mode [-Wunused-command-line-argument]
clang-cpp: warning: C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22000.0\um\x86\ole32.lib: 'linker' input unused in cpp mode [-Wunused-command-line-argument]
clang-cpp: warning: C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22000.0\um\x86\d2d1.lib: 'linker' input unused in cpp mode [-Wunused-command-line-argument]
clang-cpp: warning: argument unused during compilation: '-mwindows' [-Wunused-command-line-argument]
I got a executable file but when I run it my terminal give me an erro message Unable to run: The specified executable is not a valid application for this operating system platform
我得到了一个可执行文件,但是当我运行它时,我的终端给我一条错误消息
Unable to run: The specified executable is not a valid application for this operating system platform
It look like I got a executable file for linux but not windows.How to solve this question.看起来我得到了 linux 而不是 windows 的可执行文件。如何解决这个问题。
clang-cpp
is the Clang preprocessor , not the C++ compiler. clang-cpp
是 Clang预处理器,而不是 C++ 编译器。 You should use clang++
for the C++ compiler front-end program. C++编译前端程序应该使用
clang++
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.