I am getting an error while trying to run my executable:
The code execution cannot proceed because mgapilib.dll was not found. Reinstalling the program may fix this problem.
When I compile I don't have any issues with the system finding the dll, it's only when I try to run the executable. I read a thread about someone else having this error but they are using Python so I think my environment is probably different since i'm using C. I'm running Windows 10, VS2017, and Suite 16 of the OF API.
When you compile/link your program the .lib files are used, not the .dll files. The .dll is used at run time, not build time. How a program on Windows locates DLLs at run time is something you can find tons of info online. Also there is a FAQ that covers this in the OpenFlight API Reference:
Thanks for the reply, sorry I meant during the compile it is able to find the correct library. Originally my setup was wrong and I would get a compile error that mgapiall.h could not be found. Once I got the library path corrected that error was fixed which is where I'm at now. I will download depends and see what that tells me. Thanks,
I understand your problem, this is a very common question. But be aware there are 2 "library" files for mgapilib. The first is the .lib file (which is called the "link library"). This file is used by the compiler/linker to build. It contains information about functions located in the library, their signatures, etc - but contains NO code. The compiler/linker has to have this file at build time to make sure your code is using the functions it contains correctly. You tell Visual Studio where to look for .lib files in the project settings. The second libary file is the .dll file (dynamic link library). This file actually contains the code to run when you call a function specified in the .lib file. The project settings to find the .lib file have nothing to do with how your program (when it is run) finds the .dll files. That is controlled by another mechanism entirely.
To fix this, you must decide how to set up your "runtime environment" so that the DLL files can be found at run time (again... not build time). The locations listed in the FAQ where Windows will look for DLLs will help you decide which is best for you.
For example, you could just drop your exe in the same folder as the mgapilib.dll file. Or you could copy the mgapilib.dll file (and the other dependent DLLs) into the folder where your exe is located. Or you could set up your PATH environment variable. Windows lets you set this up in whatever way makes the most sense for your particular needs.
Also there is very detailed information about how to run your stand-alone program in the OpenFlight API Developer Guide Volume 1. See the following chapter for more information:
Introduction>A Basic API Program>Running Your Program
Thanks for the help Steve,
Your right it was my runtime environment, simple fix I had the wrong path in my environment variables. I was pointing to the wrong bin.
That's great. Glad you sorted it out Rob!