Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
The Intel sign-in experience is changing in February to support enhanced security controls. If you sign in, click here for more information.
27557 Discussions

Automatic linking of a dependent C++-DLL project in Visual Studio 2015

Tim_R_
Beginner
373 Views

Hello,

I have a Fortran console application project in Visual Studio 2015 and want to include other projects, namely C/C++ and other Fortran-projects.

In Fortran, I can either create a static or dynamic library, write a subroutine there, and call this subroutine from my console application. All i have to do is set the library as a dependency of my main console application, and, in case of the dll, declare "!DEC$ ATTRIBUTES DLLEXPORT :: MYFUNCTION" and make sure that the dll will be in the same directory as my .exe when starting the program.

If I create a static library in C++, I can also set this library as a dependency of my console application, and then call a function from this library declared as e.g. (my fortran calling convention is set to "CVF"):

extern "C" __declspec(dllexportvoid __stdcall MYFUNCTION();

This also works like a charm! Now, however, if I make a dynamic library in C++, setting it as a dependency of my console application is not enough for it to get linked - it will throw me "unresolved external symbol"-errors. What I have to do is specify the name of the generated *.lib-file under the Fortran project settings -> Linker -> Input -> Additional dependencies, and add the folder of this .lib-File under "Additional Library Directories" under the Linker -> General tab. If I do this, everything is working fine.

Now, my question is: Is there a possibility to avoid these last steps (explicitly adding the C++-dll to the additional dependencies), so that the linking will work just as easily as with a static C++-library or the fortran-libraries?

Thanks,

Tim

0 Kudos
1 Solution
Steve_Lionel
Black Belt Retired Employee
373 Views

Unfortunately, no. This problem is caused by Microsoft Visual C++ not supplying its DLL library as an "output" of the DLL project in a way that Fortran can find it. This started in VS2013, I think. Note also that a C++ project won't see any Fortran library dependencies.

View solution in original post

2 Replies
Steve_Lionel
Black Belt Retired Employee
374 Views

Unfortunately, no. This problem is caused by Microsoft Visual C++ not supplying its DLL library as an "output" of the DLL project in a way that Fortran can find it. This started in VS2013, I think. Note also that a C++ project won't see any Fortran library dependencies.

Tim_R_
Beginner
373 Views

Okay, I will then deal with the few C++-DLL-Projects manually. Thank you for your quick answer!

Reply