举报

vs code使用msys2 编译失败

0

D:\msys64\ucrt64\bin\g++.exe -fdiagnostics-color=always -g E:\VSCode\easyXstar\main.cpp -o E:\VSCode\easyXstar\main.exe -I E:\VSCode\easyXstar\easyX\include -L E:\VSCode\easyXstar\easyX\lib -lgdi32 -luser32 -lcomdlg32 -lgdiplus -loleaut32 -lole32 -static-libgcc -static-libstdc++ -lstdc++ -leasyx 

In file included from E:\VSCode\easyXstar\easyX\include/graphics.h:12,
                 from E:\VSCode\easyXstar\main.cpp:2:
E:\VSCode\easyXstar\easyX\include/easyx.h:147:71: warning: converting to non-pointer type 'long int' from NULL [-Wconversion-null]
  147 | void setfillstyle(int style, long hatch = NULL, IMAGE* ppattern = NULL);                // Set fill style
      |                                                                       ^
D:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: E:\VSCode\easyXstar\easyX\lib/libeasyx.a(EasyX.GraphWnd.o):EasyX.GraphWnd.cpp:(.text+0x198c): undefined reference to `__imp___iob_func'
collect2.exe: error: ld returned 1 exit status

 *  终端进程“C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command D:\msys64\ucrt64\bin\g++.exe -fdiagnostics-color=always -g E:\VSCode\easyXstar\main.cpp -o E:\VSCode\easyXstar\main.exe -I E:\VSCode\easyXstar\easyX\include -L E:\VSCode\easyXstar\easyX\lib -lgdi32 -luser32 -lcomdlg32 -lgdiplus -loleaut32 -lole32 -static-libgcc -static-libstdc++ -lstdc++ -leasyx”已终止,退出代码: 1。 
 *  终端将被任务重用,按任意键关闭。 

使用的vscode ,编译器用的msys2里的msys64,我是把easyX直接放在项目文件里的,编译的时候也指定路径了,但是编译失败,我感觉是easyx不支持msys2下的g++编译器,希望能支持一下

我的编译器版本:

C:\Users\Time>gcc --version
gcc (Rev3, Built by MSYS2 project) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


C:\Users\Time>g++ --version
g++ (Rev3, Built by MSYS2 project) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


C:\Users\Time>gdb --version
GNU gdb (GDB) 14.1
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

电脑系统win10 企业版 ltsc

#include <iostream>
#include <graphics.h>

int main()
{
    // void setfillstyle(int style, long hatch = 0, IMAGE* ppattern = 0);
    initgraph(1280, 720);
    int x = 300;
    int y = 300;
    while (true)
    {
        ExMessage msg;
        while (peekmessage(&msg))
        {
            if (msg.message == WM_MOUSEMOVE)
            {
                x = msg.x;
                y = msg.y;
            }
        }
        solidcircle(x, y, 50);
    }

    return 0;
}
技术讨论社区