[Question] How to dllexport NvOptimusEnablement symbol to auto select dedicated Nvidia GPU?


#1

This is a question I had asked on the rust-sdl2 repository, but it makes more sense to ask it here.
Here is the question link from there

In normal C/C++ SDL2 app I wrote, adding the following code
extern "C" {
_declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
}
causes the GPU driver system with integrated and dedicated nvidia gpu, to auto select the dedicated nvidia gpu.

I searched around rust documentation but things i found were about dllexport of pub methods of libs, not applications, and not just symbol values. I got confused about the best way to export this symbol from a normal rust app - not a lib (using crate options maybe?)

How can I make my rust app (not a library) dllexport this symbol with this value ?
I saw information about exporting public functions here


but I could not find simple info on just exporting a value like above, and not from a library but an application.

Thanks for any links or help.