- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I have a question about calling dll files.
In my project I have created an exe-file developed in Fortran and this program uses functions from dll-files in different subfolders. I have tested to have all dll-files in the same folder as my exe-file and everything works w/o any problems so this is not the problem.
But I want to use the dlls in the subfolders. (I do not want to ask my users to copy a lot of dlls from subfolders if I can avoid it)
Example what I want:
- The dll sub.dll with visible function calc is placed in subfolder c:user\program\calc
- The program myProg.exe in folder c:user\program needs to use function calc from sub.dll in folder c:user\program\calc
Is there a trick to do this in Fortran? (in other language it has worked with load and unload commands)
Very thankful if anyone can help me!
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The most straightforward way is to modify PATH so that every one of the required DLLs may be found in one of the paths whose concatenation in some order gives %PATH%. This changing of PATH can be made within a batch file or surrounded by SETLOCAL ...ENDLOCAL, if you do not wish to make permanent changes to PATH.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Assuming you load your .dll by using the WinAPI LoadLibrary(dllname), you can prepend path information onto dllname, so that the dll is always sought in a directory which has a defined relationship to where the exe file is located. My programs fetch the startup command line to determine where the exe was invoked from, and parse the original command path to make relative paths to other resources in a predetermined multi-directory structure. This mechanism allows you to have multiple versions of your program and its dll resources, in different root directories.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
mecej_4 and Paul Curtis,
Many thanks for your good advises, it was perfect. I was so into Fortran I forgot I can still use loadLibray that I have used so many times in C++.
Christer

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page