Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are a few ways you could handle this, depending on the libraries and their names/locations:</p> <p>If both have the same name (opengl32.dll), then you need to add the Mesa DLL location to the search path such that it is searched <em>before</em> the system directory. The order directories are checked in is detailed <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms682586%28v=vs.85%29.aspx#search_order_for_desktop_applications" rel="nofollow">here</a>. As you can see, <code>$PATH</code> comes last, after system, so you can't just add the directory to that. However, you can make use of the second step ("The current directory") by setting the working directory to a path containing the mesa files. Generally this means starting the application using an absolute path while in the directory containing the files.</p> <p>That's still not particularly pleasant, though. If you can, you should use <code>LoadLibrary</code> and check for an environment variable (<code>OPENGL_LIBRARY_PATH</code>) when your app starts up. Assuming the exports from <code>opengl32.dll</code> and Mesa's DLL are the same, you can do something like:</p> <pre><code>void LoadExports() { char location[MAX_PATH]; getenv("OPENGL_LIBRARY_PATH", location); HMODULE oglLib = LoadLibrary(location); function1 = GetProcAddress(oglLib, "glVertex2f"); ... } </code></pre> <p>This will work perfectly fine, doing almost exactly what you want.</p> <p>However, if you want to do that, you can't import <code>opengl32.dll</code>, which you're probably doing, you have to dynamically link throughout. Make sure not to link against <code>opengl32.lib</code> and you should be fine. Depending on how many functions you use, it may be a pain to set up, but the code can easily be scripted and only needs done once, you can also use <code>static</code> variables to cache the results for the lifetime of the program. It's also possible to use different function names for different libraries, although that takes a bit more logic, so I'll leave the details to you.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COYes, both have the same name, opengl32.dll. I have already tried to use the "current directory" - it does not work. The current directory comes after the system directory in the search order. I had also thought about modifying the code to do GetProcAddress, but that isn't desirable since all the OpenGL calls are coming from the Qt library. At the moment, I'm resorting to the stupid technique of having the same executable reside in different directories, with one of the directories having the Mesa libraries reside with the executable, so that they get loaded based on the dll search order.
      singulars
    2. COThere is a trick you can use, if you know for sure that your library will load before Qt (or you can make a stub that will do so): call `LoadLibrary` on the desired library from there, so that a loaded module with the name exists when the Qt library loads. The linker will check for `opengl32.dll`, and if one is already loaded, use *that*. Otherwise, you'll have to work with load order, and maybe check in a dependency/process trace tool what paths it's searching.
      singulars
    3. CODo you have more info on this "trick"? I tried to do something like this in a simple test program (as suggested already by KevinDTimm), where I did the LoadLibrary on the Mesa opengl32.dll and osmesa32.dll and then made calls to OSMesaCreateContext, OSMesaMakeCurrent, and glGetIntegerv. The test program would always grab the system opengl32.dll unless I specifically put the Mesa library in the same directory.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload