首页 > 解决方案 > Eclipse 不在 Windows (C++) 中编译 .exe

问题描述

我已经对此进行了大量研究,但我无法弄清楚。我在一个团队中,我们都编写了各自的代码,现在,我们的一名团队成员正在将我们所有的代码编译为一个文件。我的代码不允许他编译 .exe。我遇到了同样的问题。这在 Code::Blocks 中对我有用;但是,我们使用的是 Eclipse。我们使用 MinGW 作为编译器,我将 PE64 Windows 解析器设置为二进制解析器。

我已经用 C++17 文件系统库替换了 Boost 文件系统库,不幸的是,结果是一样的。在我的故障排除过程中,我创建了一个 hello, world 程序,其中包含我正在使用的所有库。在这种情况下,不会创建可执行文件。然后我删除了我正在使用的所有库。在那种情况下,创建了一个可执行文件。我怀疑在某些方面找不到 libcurl-x64.dll,这就是为什么无法构建可执行文件的原因。我已经在包含文件夹中查找了重复的文件名。一个都不存在。我的构建日志如下:

19:34:27 **** Rebuild of configuration Debug for project Ethical-Hacking-with-Computer-Viruses-Using-C++ ****
Info: Internal Builder is used for build
g++ -std=c++17 "-IC:\\libraries5\\xlnt-master\\include" "-IC:\\libraries5\\curl-7.70.0-win64-mingw\\include" -O2 -g3 -Wall -c -fmessage-length=0 -o main.o "..\\main.cpp" 
g++ "-LC:\\thirdparty" -static -l -o Ethical-Hacking-with-Computer-Viruses-Using-C++.exe main.o 
g++: error: Ethical-Hacking-with-Computer-Viruses-Using-C++.exe: No such file or directory

19:34:29 Build Finished. 0 errors, 0 warnings. (took 2s.26ms)

对于创建可执行文件的任何帮助,我将不胜感激。谢谢你。

编辑:按照 Julian 的要求,我已经上传了我的 makefile。

https://www.dropbox.com/s/3c11vnccjah3frx/makefile?dl=0

使用 GNU Make 时,我在 Eclipse 中的完整构建日志是:

21:09:58 **** Build of configuration Debug for project Ethical-Hacking-with-Computer-Viruses-Using-C++ ****
make all 
Building file: ../main.cpp
Invoking: GCC C++ Compiler
g++ -std=c++17 -I"C:\libraries5\xlnt-master\include" -I"C:\libraries5\curl-7.70.0-win64-mingw\include" -O2 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.o" -o "main.o" "../main.cpp"
Finished building: ../main.cpp
 
Building target: Ethical-Hacking-with-Computer-Viruses-Using-C++.exe
Invoking: MinGW C++ Linker
g++ -L"C:\thirdparty" -static -l -o "Ethical-Hacking-with-Computer-Viruses-Using-C++.exe"  ./main.o   
g++.exe: error: Ethical-Hacking-with-Computer-Viruses-Using-C++.exe: No such file or directory
makefile:44: recipe for target 'Ethical-Hacking-with-Computer-Viruses-Using-C++.exe' failed
make: *** [Ethical-Hacking-with-Computer-Viruses-Using-C++.exe] Error 1
"make all" terminated with exit code 2. Build might be incomplete.

标签: c++eclipsebuildmingwlibraries

解决方案


如果您有编译问题,也可以使用WSL 终端

安装并设置好 linux 终端后,运行这些命令

$sudo apt update
$sudo apt install g++
$sudo apt install gcc

将您的目录更改为您的 Eclipse 工作目录并运行您的 g++ 命令。


推荐阅读