1

I'm trying to build a sample SFML program which uses OpenGL features; the source code is the following:

#include <GL/glew.h>

#include <SFML/Window.hpp>
#include <SFML/OpenGL.hpp>

using namespace sf;

GLuint VBO;

void createVertexBuffer()
{
    using namespace sf;

    Vector3f vertices[] {{0.0f, 0.0f, 0.0f}};

    glGenBuffers(1, &VBO);
}

int main()
{
    

    Window window(sf::VideoMode(800, 600), "OpenGL");

    window.setActive(true);
    
    bool running = true;

    while(running)
    {
        Event event;
        
        while(window.pollEvent(event))
        {
            if(event.type == Event::Closed)
            {
                running = false;
            }
        }

        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        // end the current frame (internally swaps the front and back buffers)
        window.display();
    }

    return 0;
}

I'm compiling it using this command line:

g++ -std=c++2b -L"E:/H/CppLibraries/SFML/libs" -I"E:\H\CppLibraries\glew-2.1.0\include" -L"E:\H\CppLibraries\glew-2.1.0\lib\Release\x64" -mwindows .\main.cpp -lglew32s -lsfml-window -lsfml-system -lopengl32

When I try to compile I get the following error message:

undefined reference to `_imp____glewGenBuffers'

elanilero
  • 29
  • 4
  • `E:\H\CppLibraries\glew-2.1.0\lib\Release\x64` maybe the binaries in this folder are for `msvc` and not compatible with MinGW – drescherjm Jan 17 '23 at 23:11
  • So, do you reccomend building Glew myself? – elanilero Jan 18 '23 at 17:13
  • I recommend you use [msys2](https://www.msys2.org/#installation) to install MinGW and your open source dependencies using the package management pacman. glew and sfml are available: [https://packages.msys2.org/package/mingw-w64-x86_64-glew?repo=mingw64](https://packages.msys2.org/package/mingw-w64-x86_64-glew?repo=mingw64) to install x64 glew for MinGW type `pacman -S mingw-w64-x86_64-glew` at the mingw64 terminal. – drescherjm Jan 18 '23 at 17:16
  • I already have some MinGW installed from winlibs, is there a way to use directly those? I remember Msys2 MinGW to be a little problematic (I think its GCC versions were a bit behind) – elanilero Jan 18 '23 at 17:26
  • It currently has: ***gcc.exe (Rev1, Built by MSYS2 project) 12.2.0*** – drescherjm Jan 18 '23 at 17:34
  • Oh, when I used it I remember it being stuck behind with version. Anyway, I followed your instruction "pacman -S mingw-w64-x86_64-glew", but where is it installed now? – elanilero Jan 18 '23 at 17:37
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/251247/discussion-between-elanilero-and-drescherjm). – elanilero Jan 18 '23 at 17:39
  • Probably `C:\msys64\mingw64\lib` – drescherjm Jan 18 '23 at 17:39

0 Answers0