- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'v built a Fortran DLL which can be called from a .NET application on my system. A relative path is been set and everything works fine.
Copying the EXE and DLL to another system (same directory) leads to a calling failure. The DLL can't be found. What could be the reason for that?
Best regards, Marc
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
------
Wendy
Attaching or including files in a post
To use the DLL from another image:
Add the import .LIB file with its path and library name to the other image.
In the integrated development environment, add the .LIB import library file to your project. In the Project menu, select Add Existing Item... . If the importing project and the DLL are in the same solution, you can add the DLL project as a dependency of the importing project instead.
On the command line, specify the .LIB file on the command line.
The import .LIB file contains information that your program needs to work with the DLL.
If your DLL exports data, consistently use the same property page options in the Fortran Data category /align option as was used to create the DLL. In the Fortran Data category, specify the appropriate values for Common Element Alignment (common block data) and Structure Member Alignment (structures in a module). This sets the /align option, which specifies whether padding is needed to ensure that imported data items are naturally aligned.
In the Project Property Pages dialog box, make sure the type of libraries specified is consistent with that specified for the Fortran DLL.
If you need to specify linker options:
In the IDE, specify linker options in the Linker category.
On the ifort command line, place linker options after the /link option.
Copy the DLL into your path.
For an application to access your DLL, it must be located in a directory on the search path or in the same directory as the main project. If you have more than one program accessing your DLL, you can keep it in a convenient directory identified in the environment path. If you have several DLLs, you can place them all in the same directory to avoid adding numerous directories to the path specification.
You should log out and back in after modifying the system path.
Build the image that references the DLL.
When using the visual development environment:
Like building other projects in the integrated development environment, use the Build menu items to create the executable.
When using the command line:
Specify the import library at the end of the command line.
If your DLL exports data that will be used by the application being built, specify the same /align options that were used to build the DLL.
If you are building a main application, omit the /dll option.
When building a Fortran DLL that references another DLL, specify the /dll option.
For example, to build the main application from the command line that references 4-byte items in a common block defined in dllfile.dll:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
First, make sure your DLL was built as a Release configuration and not Debug. Second, you'll need the Intel Fortran redistributables inatalled on the target system - you can download an installer from the Intel Registration Center alongside the compiler. You may need a Microsoft Visual C++ redistributables insaller as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regards
David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Nevertheless I'm interested in a solution without installing this package. Therefore I have checked the items 1-6 in Wendy's post. Yet nothing helps. But there must be some Linker option for that?!
Edit: Dependency Walker says that the DLL is dependent on another DLL. Is it possible to link this libary statically?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is how to create a static library from the documentation installed on your system or online.
------
Wendy
Attaching or including files in a post
To build a static library (Windows OS):
To build a static library from the integrated development environment (IDE), select the Fortran Static Library project type.
To build a static library using the command line:
Use the /c option to generate object files from the source files:
ifort /c my_source1.f90 my_source2.f90
Use the Microsoft LIB tool to create the library file from the object files:
lib /out:my_lib.lib my_source1.obj my_source2.obj
Compile and link your project with your new library:
ifort main.f90 my_lib.lib
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think there is a misunderstanding. I don't want use a static liberay instead of a DLL. There are some dependencies to other DLLs. I just want to abrogate these dependencies by linking statically.
Regards
Marc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That is rather extreme. A more reasonable goal would be to build your DLL by linking against static versions of only those libraries that are required by the DLL but are not found (as DLLs) in every Windows installation. However, this can be done only if you have the necessary libraries on the build machine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Today I tried to run a simple EXE on another system without this package. It did not run!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
but I tried to link the DLL statically. So far I have not managed it.
Marc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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