openglgpulnk2005

LNK2005 with __declspec(dllexport)


I am programming a simple OpenGL 3D application. If I am running the application on a laptop, the performance is terrible since the internal Intel GPU is selected always and not the more powerfull dedicated AMD GPU.

I did read that I have to inlclude this line to force the application to run on the dedicated GPU:

extern "C" __declspec(dllexport) DWORD AmdPowerXpressRequestHighPerformance = 0x00000001;

However, I get an LNK2005 error that AmdPowerXpressRequestHighPerformanceis already defined in multiple .obj files. I don't know how to fix this and I didn't find this variable name in any of the files that I did include in my application.

If it helps: I am using GLFW3 and GLAD for the OpenGL rendering.


Solution

  • Solved by putting the code in the correct place, as suggested in the comments above.