1

I've been working on a C++/OpenGL Game in Visual Studio and wanted to move to VSCode(Windows 10). To start this off I tried to get the setup running with a simple "Hello World" and my Compiler(MinGW/g++) seems to work fine. But when trying to link my dependencies(glew32.dll and SDL2.dll) I get an error: cannot find -l<AbsolutPath>\glew32.dll.

I'm not too familiar with VSCode and linking libraries, so I tried to link them dynamically (that seems to be easier) by adding the path of the .dll as argument in tasks.json.

"args": [
                "-fdiagnostics-color=always",
                "-g",
                "-std=c++11",
                "${file}",
                "-o", "${fileDirname}\\${fileBasenameNoExtension}.exe",
                "-lmingw32",
                "-lopengl32",
                "-l${fileDirname}\\libs\\glew-2.1.0\\bin\\Release\\x64\\glew32.dll",
                "-l${fileDirname}\\libs\\SDL2-2.0.14\\lib\\x64\\SDL2.dll",

            ]

I have no real clue how to tackle this Problem... (a while ago I tried the same with CLion, but failed at the same Error) Has anybody an Idea what I could do to get rid of the Error?

Is something wrong with the Path ${fileDirname}\\libs\\glew-2.1.0\\bin\\Release\\x64\\glew32.dll?

Should I use .lib instead of the .dll?

I've read one might add the libraries to the include directory of my compiler. Is this necessary?

TheBaum
  • 122
  • 1
  • 6
  • You should rather specify the appropriate stub libraries (.lib without the `lib` prefix and without extension) with the `-l` flags. – πάντα ῥεῖ Feb 12 '22 at 21:50
  • 1
    _"I've read one might add the libraries to the include directory of my compiler. Is this necessary?"_ no that's nonsense. – πάντα ῥεῖ Feb 12 '22 at 21:50
  • 3
    Start by linking SDL2 without Glew or OpenGL. Don't use `.lib` files, those are for MSVC (a different compiler). MinGW uses `.a` instead. Don't pass full path to `-l`, it only accepts a filename (without extension and without the `lib` prefix). The library search path can be configured with `-L`... – HolyBlackCat Feb 12 '22 at 21:52

0 Answers0