Issues with GLFW and GLEW

As I’ve been learning C and C++, I started with SDL2 to visualize the programs I’m making. I use Visual Studio Code as I like the look of it and I don’t want to use an IDE, and I use either the command line (gcc/g++) or the tasks.json (which by extension is just the command line I guess) to compile. I just started getting into GLFW and by extension using GLEW so I can get into some shader stuff.

My issue is twofold. I cannot static link GLFW or GLEW (it throws errors when I try to link the libraries) and even if I use the .dll files instead, some functions are not available (such as glGetString(), I haven’t tried any more than that).

Here’s my tasks.json file

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++.exe build active file",
            "command": "C:\msys64\ucrt64\bin\g++.exe",
            "args": [
                "-g",
                "${workspaceFolder}\src\**",
                "-I",
                "C:\GLFW\include",
                "-I",
                "C:\GLEW\include",
                "-L",
                "C:\GLFW\lib-static-ucrt",
                "-L",
                "C:\GLEW\lib\Release\x64",
                "-o",
                "${workspaceFolder}\bin\GLFWtest.exe",
                "-D",
                "GLEW_STATIC",
                "-lglew32s",
                "-lglfw3dll",
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "compiler: C:\msys64\ucrt64\bin\g++.exe"
        }
    ]
}

I’ve selected the glew32s library as I want to static link but like I said it’s throwing these errors

Warning: corrupt .drectve at end of def file
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:GLEWlibReleasex64/glew32s.lib(tmp/glew_static/Release/x64/glew.obj):(.text$mn+0xd): undefined reference to `__imp_wglGetProcAddress'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:GLEWlibReleasex64/glew32s.lib(tmp/glew_static/Release/x64/glew.obj):(.text$mn+0xf): undefined reference to `__imp_wglGetProcAddress'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:GLEWlibReleasex64/glew32s.lib(tmp/glew_static/Release/x64/glew.obj):(.text$mn+0x29): undefined reference to `__imp_wglGetProcAddress'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:GLEWlibReleasex64/glew32s.lib(tmp/glew_static/Release/x64/glew.obj):(.text$mn+0x48): undefined reference to `__imp_wglGetProcAddress'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:GLEWlibReleasex64/glew32s.lib(tmp/glew_static/Release/x64/glew.obj):(.text$mn+0x67): undefined reference to `__imp_wglGetProcAddress'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:GLEWlibReleasex64/glew32s.lib(tmp/glew_static/Release/x64/glew.obj):(.text$mn+0xf): more undefined references to `__imp_wglGetProcAddress' follow
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:GLEWlibReleasex64/glew32s.lib(tmp/glew_static/Release/x64/glew.obj):(.text$mn+0xe): undefined reference to `__imp_glGetString'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:GLEWlibReleasex64/glew32s.lib(tmp/glew_static/Release/x64/glew.obj):(.text$mn+0x2de): undefined reference to `__imp_glGetIntegerv'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:GLEWlibReleasex64/glew32s.lib(tmp/glew_static/Release/x64/glew.obj):(.text$mn+0x2f3): undefined reference to `__imp_glGetIntegerv'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:GLEWlibReleasex64/glew32s.lib(tmp/glew_static/Release/x64/glew.obj):(.text$mn+0x300): undefined reference to `__imp_wglGetProcAddress'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:GLEWlibReleasex64/glew32s.lib(tmp/glew_static/Release/x64/glew.obj):(.text$mn+0x363): undefined reference to `__imp_glGetString'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:GLEWlibReleasex64/glew32s.lib(tmp/glew_static/Release/x64/glew.obj):(.text$mn+0x2d): undefined reference to `__imp_wglGetCurrentDC'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:GLEWlibReleasex64/glew32s.lib(tmp/glew_static/Release/x64/glew.obj):(.text$mn+0x1c): undefined reference to `__imp_wglGetProcAddress'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:GLEWlibReleasex64/glew32s.lib(tmp/glew_static/Release/x64/glew.obj):(.text$mn+0x30): undefined reference to `__imp_wglGetProcAddress'
C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:GLEWlibReleasex64/glew32s.lib(tmp/glew_static/Release/x64/glew.obj):(.text$mn+0x5c): undefined reference to `__imp_wglGetCurrentDC'
collect2.exe: error: ld returned 1 exit status

If I instead dynamically link, I can get it to JUST compile, but when I try to use the function I mentioned previously, I get this error

C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:UsersjpwolAppDataLocalTempccasYrmw.o: in function `main':
C:/Coding Practice/C++/GLFWtest/src/main.cpp:16:(.text+0x101): undefined reference to `glGetString'
collect2.exe: error: ld returned 1 exit status

It should be mentioned that I am running the 64 bit compiler, and here’s the entire code for the program I’m trying to compile

#include <iostream>
#include <GL/glew.h>
#include <GLFW/glfw3.h>


int main(void)
{

    glfwInit();
    GLFWwindow* window = glfwCreateWindow(1280, 720, "window", NULL, NULL);
    glfwMakeContextCurrent(window);
    if(glewInit() != GLEW_OK);
    {
        printf("Error!n");
    }
    std::cout << glGetString(GL_VERSION) << 'n';
    glfwSetWindowShouldClose(window, false);
    fprintf(stdout, "Status: Using GLEW %sn", glewGetString(GLEW_VERSION));
    
    return 0;
}

for some reason, it’ll print “Error!” as seen on line 14 no matter what, but glewGetString(GLEW_VERSION) works fine anyways.

I’ve seen people say that you need to download the source for GLEW and compile it yourself, and I’ve tried using arguments that other people have posted but it doesn’t seem to work on my system. Any help would be appreciated as compiling source from things I didn’t make is probably currently out of my league.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật