关于在 VS 中使用 g++

灌水区

zhiyangfan @ 2021-12-16 15:14:59

C:/Program Files (x86)/Embarcadero/Dev-Cpp/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: i386 architecture of input file `C:\Users\fanfa\Desktop\OI\c
\c.exe' is incompatible with i386:x86-64 output

collect2.exe: error: ld returned 1 exit status

求助这个错误信息qwq

发现路径上也没啥隐私就不打码了(


by zhiyangfan @ 2021-12-16 15:17:39

{
            "type": "cppbuild",
            "label": "C/C++: g++.exe 生成活动文件",
            "command": "C:/Program Files (x86)/Embarcadero/Dev-Cpp/TDM-GCC-64/bin/g++.exe",
            "args": [
                "-O2",
                "-Wall",
                "-std=c++14",
                "-o",
                "-lm",
                "${fileDirname}\\${fileBasenameNoExtension}.exe",
                "${file}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$msCompile"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "调试器生成的任务。"
        }

这是 tasks.json

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "g++.exe - 生成和调试活动文件",
            "type": "cppvsdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${fileDirname}",
            "environment": [],
            "console": "externalTerminal",
            "preLaunchTask": "C/C++: g++.exe 生成活动文件"
        }
    ]
}

这是 launch.json,qwq


by zhiyangfan @ 2021-12-16 15:18:13

草不管咋打 markdown 都会挂,凑合着看吧qwq


by rxjdasiwzl @ 2021-12-16 15:44:52

@zhiyangfan 百度出来是这个


by zhiyangfan @ 2021-12-16 15:48:11

@rxjdasiwzl 哦哦谢谢谢谢,之前一直没百度出来qwq


by Qiaoqia @ 2021-12-16 15:48:16

都用 VS 了还想着用 g++ 编译?

或者您想说 VSCode?

i386 architecture of input file `C:\Users\fanfa\Desktop\OI\c \c.exe' is incompatible with i386:x86-64 output

输入文件的 i386 架构与 i386 x86-64 的输出不兼容。

要不试试在编译选项中加 -m32?

"args": [
                "-O2",
                "-Wall",
                "-std=c++14",
                "-o",
+                "-m32",
                "-lm",
                "${fileDirname}\\${fileBasenameNoExtension}.exe",
                "${file}"
            ],

by zhiyangfan @ 2021-12-16 15:55:10

@Qiaoqia 确实是 VSCode,我大意了qwq(

谢谢您,成功了/bx


|