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

linker errors

Deleted_U_Intel
Employee
737 Views
I am unable to link a library of mine to programs. I have a library of subroutines, but when I attempt to link them I consistently get "unresolved external errors". I have attached the library to the workspace via the project/add to project/files route, have identified the right path in the tools/options/library window.
Any suggestions.
John
0 Kudos
6 Replies
Jugoslav_Dujic
Valued Contributor II
737 Views
It's hard to say with so little data. Which linker errors?
In any case, go to [Fortran] command prompt, browse to the library directory and type
dumpbin /symbols thelib.lib > thelib.txt
then, open thelib.txt in a text editor and find the symbol in question (e.g. "Foo"). You should see the linker decoration, like. "_FOO@20" or "_FOO". How does it differ from the symbol listed in LNK2001 error?
Jugoslav
0 Kudos
Jugoslav_Dujic
Valued Contributor II
737 Views

This set of errors comes from checking the "generate debugger information" , "link incrementally", and "ignore all default libraries" boxes whereas when I don't check the "ignor..." box I get 50 such errors.

"Ignore all default libraries" is never a good idea. On to set 2...:

Incidently, I have put the library path under the tools/options/library box and I attach the library to the project via the project/add_to_project/files route

LINK : warning LNK4044: unrecognized option "MYLIB.LIB"; ignored

You should either do

- project/add to project or

- specify directory (not file) it in both Tools/Options/Directories/Library files and file name in Project/Settings/Link/Object-library modules

but not both. It seems the linker is complaining about the latter. Remove it. Further...

libc.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16

What type of .exe are you trying to build? You have specified "Fortran Windows Application", and that doesn't seem to be what you want. Delete the .exe's .dsp file and create it again, but this time specify what you want -- QuickWin? Console? Probably the former:

dfor.lib(for_put.obj) : error LNK2001: unresolved external symbol __QWINWrite

It doesn't look like MyLib.lib has anything to do with your problems.

Jugoslav

P.S. Copying & pasting directly from Word won't work -- you can paste to Notepad first, then copy&paste to Forum.


0 Kudos
Jugoslav_Dujic
Valued Contributor II
737 Views

1. build a library (is it a bad idea to build it in debugger form?)

As with any project -- you can build it in debugger form if you'd want to debug it (you can e.g. step into library code while debugging to check how it works). When you consider it "done", you can build the release version.

2. attach it to the project via the project/add to project/files route

OK.

3. be sure that under tools/options that thepath to the library is specified under the path tab

No. That collides with 2). This is a global setting (affecting all the projects). Only directory names are supposed to go there -- this is a list of "known" library directories. For example, if you have a set of very frequently used code accross many projects, it's convenient to compile it to a foo.lib, put its directory to this list, and thenappend foo.lib in project/settings/link/object-library modulesfor every project that uses it. Method 2) above has relative disadvantage that you cannot move the project folder to another location, as the link with added .lib filewould bebroken. For simple cases, method 2) is ok.

4. What do I need to do under Project settings? Under Fortran, Under linker, under "what"?

If you did 2), then typically nothing.
Jugoslav
0 Kudos
Jugoslav_Dujic
Valued Contributor II
737 Views

You can attach just one file, but you can zip whatever you like and attach the zip file.

Jugoslav

0 Kudos
Jugoslav_Dujic
Valued Contributor II
737 Views
Huh...
I don't know why the oop1 works and fit doesn't. Specifically, I think neither should work, yet the first one does.
For the start, there's a conflict between run-time libraries. You're trying to build a QuickWin application, and it's known to interact with other run-time libraries. This conflict emerges in both cases, yet in the first only as warning(LNK4098) and in the other as error (LNK1169).
I'd suggest the following for the start: if you have the sources of MyLib.lib (you seem to have), go to its Project/Settings/Fortran/Libraries and check "disable default library search rules" (/libdir:noauto), then rebuild it, then re-insert it into projects in question. That setting should have been default for static .libs anyway (see this thread). If you still get linker errors, please re-attach the workspaces here.
Jugoslav
0 Kudos
Jugoslav_Dujic
Valued Contributor II
737 Views

John,

I suggested specifying /libdir:noauto when building the lib, not the .exe. When I do it (only indexx.for is in the library), I get:

Configuration: fit - Win32 Debug--------------------
Linking...

FIT.exe - 0 error(s), 0 warning(s)

Jugoslav

0 Kudos
Reply