Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
4 Views

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

Jump to solution

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

Accepted Solutions
Highlighted
Black Belt
4 Views

Unfortunately, no. This

Jump to solution

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.

Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran

View solution in original post

0 Kudos
2 Replies
Highlighted
Black Belt
5 Views

Unfortunately, no. This

Jump to solution

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.

Steve (aka "Doctor Fortran") - https://stevelionel.com/drfortran

View solution in original post

0 Kudos
Highlighted
Beginner
4 Views

Okay, I will then deal with

Jump to solution

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

0 Kudos