Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29273 Discussions

Linking static lib in VS2012 and IVF XE2013

Alexey_M_
Beginner
1,247 Views

How to link static library .lib to executable program?

Documentation tells about VS2008 and 2010 only.

When I place my .lib file into folder with source files and include it into project compiler gives an error:

error #7002: Error in opening the compiled module file.  Check INCLUDE paths.   [FMZM] 

FMZM - name of module in library I want to use.

0 Kudos
1 Solution
mecej4
Honored Contributor III
1,247 Views

Click on the project in the solution explorer tab of VS, then right-click and choose Properties. In the Property Pages pop-up, choose Configuration Properties: Fortran: General. Click on the second box, Additional Include Directories, and enter the directory containing the module files (FMZM.MOD, etc.). Similarly, go to the Configuration Properties: Linker: General: Additional Library Directories, and enter the name of the directory containing the library file; finally, go to Configuration Properties: Linker: Input: Additional Dependencies and enter the name of the library (FMLIB.LIB?). Click OK, and proceed to build your application.

View solution in original post

0 Kudos
6 Replies
mecej4
Honored Contributor III
1,247 Views

Module files (*.mod) are often needed to compile source code that calls routines in a static or dynamic library, but the module files are never (in modern systems, anyway) contained in the libraries. Thus, to use the XYZ library, for example, you might need the file XYZ.MOD as well as the file XYZ.LIB. If you were using a dynamic library, you would also need XYZ.DLL. These are distinct, albeit related, files. The MOD file is used by the compiler to check the arguments that your code passes to the library routine. The LIB file is used by the linker after the compiler has compiled your code and calls the linker. Your EXE may then need to call the DLL, if you used a DLL library.

Module files are located by using the INCLUDE environmental variable, if they are not in the same directory as the source code. Library files are located using LIB, and DLLs are located using PATH. Again, these variables can be related and may share parts of the pathnames of the library components, but the individual files are distinct and have designated roles with no overlap.

Can you tell us some details about the library? Did you build it or obtain it from a vendor? Do you have the MOD files for the library?

0 Kudos
Alexey_M_
Beginner
1,247 Views

Hi.

I used multiprecision libraries from this page: http://myweb.lmu.edu/dmsmith/fmlib.html

I compiled them into static library and then tried to link this library to my another project.

I do not want to use it as a DLL.

Thank you.

0 Kudos
mecej4
Honored Contributor III
1,247 Views

I obtained the source files from the link that you gave and built the library and the two test programs. The resulting program ran and output results that checked out with the results posted at the FMLIB site.  After compilation I do have the file FMZM.MOD, and it is over 1 megabyte long. In addition I have files fmmod.mod and fmzm_{n}.mod where n = 1..10. 

On your system, please locate FMZM.MOD, and check if its path is part of the environment variable INCLUDE (if building from the command line) or it is listed in the Visual Studio box for Include Directories in the project properties.

0 Kudos
Alexey_M_
Beginner
1,247 Views

Thank you.

I'll try to do it.

I located FMZM.MOD. I compile from the VS environtment.

I did not find Include directories in the project settings (VS2012). Should I add these files to porject? Will it work?

0 Kudos
mecej4
Honored Contributor III
1,248 Views

Click on the project in the solution explorer tab of VS, then right-click and choose Properties. In the Property Pages pop-up, choose Configuration Properties: Fortran: General. Click on the second box, Additional Include Directories, and enter the directory containing the module files (FMZM.MOD, etc.). Similarly, go to the Configuration Properties: Linker: General: Additional Library Directories, and enter the name of the directory containing the library file; finally, go to Configuration Properties: Linker: Input: Additional Dependencies and enter the name of the library (FMLIB.LIB?). Click OK, and proceed to build your application.

0 Kudos
Alexey_M_
Beginner
1,247 Views

Yes!

It did!

Thank you a lot!
 

0 Kudos
Reply