Linker problem on Windows

Hi all,

I encountered a problem on compiling my sources on Windows. I use functions of Glew from ‘glew.h’ which compiles on Mac fine but fails on Windows with that message from the linker:

$ make
CPU architecture is: x86_64

g++ -o plugin.dll build/src/LRModule.cpp.o (...) -l:libRack.a -shared -L../.. -lRack

C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: build/src/widgets/LRBufferedSvg.cpp.o: in function `lrt::LRBufferedSvg::createFbo()':
C:\msys64\home\ReinaME\Rack\plugins\LRTRack/src/widgets/LRBufferedSvg.cpp:61: undefined reference to `glViewport'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\msys64\home\ReinaME\Rack\plugins\LRTRack/src/widgets/LRBufferedSvg.cpp:62: undefined reference to `glClearColor'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\msys64\home\ReinaME\Rack\plugins\LRTRack/src/widgets/LRBufferedSvg.cpp:63: undefined reference to `glClear'
collect2.exe: error: ld returned 1 exit status
make: *** [../../compile.mk:59: plugin.dll] Error 1

I have absolutely no glue… any ideas from the expert C++ hackers? :slight_smile:

Thanks in advance, Patrick

I think you need this in your plugin’s Makefile:

ifdef ARCH_WIN
    LDFLAGS += -lopengl32
endif

a lot of us use functions in glfw3.h, and that doesn’t need any special linking. I think because those functions end up being exported from rack?

If you do add extra things to link against, I’d advise building against the official toolchain. The official makefile is different from what we do on the desktop. Of maybe I’m just being paranoid: GitHub - VCVRack/rack-plugin-toolchain

Patrick is asking about functions in OpenGL, not GLFW. On Windows, OpenGL is present as a system DLL, and in order for an executable (plugin.dll in this case) to call into it, you need to link with the corresponding import library using -lopengl32.

1 Like

Got it. I think my main point, try it in the toolchain, is still valid? oh, wait - rack itself links against that DLL… So it should be in the toolchain (although I don’t know if rack itself is built that way).

Hi Richie,

thanks a lot for the fast response! Now it works without any issues. :smiley:

Cheers, Patrick

1 Like