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

Error linking static library in Visual Fortran

Jump to solution

I'm having issues linking a library with Intel Composer XE 2013 SP.

I have two projects in a solution. One is a DLL and the other a console application. I've correctly set the compilation dependencies and the "Link Library Dependencies" option to "Yes". Both projects compile and link correctly as Multithreaded (/libs:static) but when I run the project it asks for the .dll file with the message:

"The program can't start because XXXX.dll is missing from your computer. Try reinstalling the program to fix this problem."

I'm using Visual Studio version 12.0.40629.0 and I'm pretty sure it worked with version 12.0.31101.0

 

I've tried manually linking the library (even it should work automatically) by:

  • Going to Linker > General > "Link Library Dependencies" and set "No"
  • Adding the .lib file path in Linker > General > "Additional Library Directories"
  • Adding the library (.lib file) in Linker > Input > "Additional Dependencies"

The project compiles and links correctly again but the problem is still there.

0 Kudos

Accepted Solutions
Highlighted
Black Belt Retired Employee
39 Views

I'm confused by your problem description. You talk about linking in a static library but also say there is a DLL in your project and never mention where this static library comes from. Could it be that you think the .LIB generated when the DLL is built is a static library? It is not - it's an "import library" (also called an "export library", confusingly.) An import library contains no code - it instead "hooks up" applications to the DLL it was built from. When you want an application to use things from a DLL, you link to the import library to satisfy the references. Then when the program is run, Windows activates the DLL named by the import library and it now knows how to find the various entry points.

If this doesn't explain your situation, please ZIP the buildlog.htm from your console application build, attach it to a reply here, and explain what it is you are trying to do.

View solution in original post

0 Kudos
3 Replies
Highlighted
Black Belt Retired Employee
40 Views

I'm confused by your problem description. You talk about linking in a static library but also say there is a DLL in your project and never mention where this static library comes from. Could it be that you think the .LIB generated when the DLL is built is a static library? It is not - it's an "import library" (also called an "export library", confusingly.) An import library contains no code - it instead "hooks up" applications to the DLL it was built from. When you want an application to use things from a DLL, you link to the import library to satisfy the references. Then when the program is run, Windows activates the DLL named by the import library and it now knows how to find the various entry points.

If this doesn't explain your situation, please ZIP the buildlog.htm from your console application build, attach it to a reply here, and explain what it is you are trying to do.

View solution in original post

0 Kudos
Highlighted
Beginner
39 Views

I understand it now. That was exactly my problem.

I have a dynamic library and a tester application. I need the library to be dynamic as it is used in that way in other projects but I intended to link it statically to my tester application so I can debug it easily.

I think I'll add a pre-build command to copy the library to my build directory so it works correctly.

Thank you

0 Kudos
Highlighted
Black Belt Retired Employee
39 Views

A perhaps better solution is to add a static library project to your solution, with the same sources. That way, both will get built and you can choose which one you want to link in using the dependent project property.

0 Kudos