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

error LNK2019: Problems with external libraries

madsplinter
Beginner
2,098 Views
Hi there, here is my problem:

I'm trying to compile some fortran files using an external library. The Dislin graphic library, if you know it.
I set up the required windows environment variables and paths, then in Visual Studio I added the paths for the modules and libraries in Options>Fortran>General.
But now, when I try to generate the solution, I get some errors, here is the log:

Link: executing 'link'
Console1.obj : error LNK2019: unresolved external symbol _DISINI referenced in function _MAIN__
Console1.obj : error LNK2019: unresolved external symbol _MESSAG referenced in function _MAIN__
Console1.obj : error LNK2019: unresolved external symbol _DISFIN referenced in function _MAIN__
Debug/Console1.exe : fatal error LNK1120: 3 unresolved external


Console1 build failed.

Pratically, I get one error for every call I make to the external library.
Can you help me?

Thanks in advance,
Adriano


0 Kudos
5 Replies
Steven_L_Intel1
Employee
2,098 Views
It is not enough to add the paths - you have to name the library. There are several ways to do that:

1. Add the library name under "Additional dependencies" in the Linker Input property page
2. Add the .lib to your project as if it were a source file
3. Add a "!DEC$ OBJCOMMENT 'lib:libname.lib' " directive to one of your source files

Also, make sure that the library you have is built to assume Intel Fortran defaults (uppercase routine names, CDECL interface.)
0 Kudos
madsplinter
Beginner
2,098 Views
I chose the easiest way, i.e. I added the library to the source files.
But now I get another error:

Fatal error cannot open "LIBC"
Link: error: problem during multi-file optimization compilation (code 1)
Link: error: problem during multi-file optimization compilation (code 1)


Of course it can't find that file, I don't have it! Do I have to download that file to make it works? Can you tell me where to get it? Or there is a way to bypass this step? I saw in another thread with a similar issue that building with /MT should solve the problem. I tried, but without success...



0 Kudos
Steven_L_Intel1
Employee
2,098 Views
I'm guessing that you have Visual Studio 2005 and that the library you obtained was not built with an option to prevent embedding library directives. I can't guarantee this will work, but you can try adding libc.lib to the list of libraries to be ignored on the Linker property page.

Visual Studio 2005 does not provide libc.lib any more, and Intel Fortran defaults to use the threaded library (LIBCMT) when it knows you are using VS2005. See the Release Notes for more information.
0 Kudos
madsplinter
Beginner
2,098 Views
Your guess was right.
Unfortunately adding the library to the ignore list, or using the other methods specified in the release notes didn't work.
I'll try to get a newer version of the library.

By the way, I would like to thank you for your suggestions, I really appreciate them.
Hope this thread may be useful to other users
0 Kudos
gjcamann
Beginner
2,098 Views

I've struggled through a similar problem and made a tutorial that may be of use to others that come across this problem too. Here

Hope it helps.

0 Kudos
Reply