Unresolved Externals

Unresolved Externals

Up front, I am a 'newbie' to the Intel Visual Fortran Compiler and am facing the 'learning curve...'

I am trying to compile a simple test code; and get the following errors as a partial example.

I have the file IFORT.CFG in the same subdirectory as IFORT.EXE and my test code.

I am setting the PATH, LIB, INCLUDE in the .CFG using the SET command.

Thanks for advice on resolving this.

Microsoft Incremental Linker Version 10.00.40219.01
Copyright (C) Microsoft Corporation. All rights reserved.

-out:TESTCODE.exe
-subsystem:console
TESTCODE.obj
TESTCODE.obj : error LNK2019: unresolved external symbol ___intel_new_proc_init referenced in function _MAIN__
TESTCODE.obj : error LNK2019: unresolved external symbol _for_set_reentrancy referenced in function _MAIN__
TESTCODE.obj : error LNK2019: unresolved external symbol _for_write_seq_fmt referenced in function _MAIN__
TESTCODE.obj : error LNK2019: unresolved external symbol _for_read_seq_fmt referenced in function _MAIN__
TESTCODE.obj : error LNK2019: unresolved external symbol _for_stop_core referenced in function _MAIN__
LIBCMT.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
LIBCMT.lib(crt0.obj) : error LNK2019: unresolved external symbol __imp__GetCommandLineA@0 referenced in function ___tmainCRTStartup
LIBCMT.lib(crt0.obj) : error LNK2019: unresolved external symbol __imp__HeapSetInformation@16 referenced in function ___tmainCRTStartup
LIBCMT.lib(unhandld.obj) : error LNK2019: unresolved external symbol __imp__SetUnhandledExceptionFilter@4 referenced in function ___CxxSetUnhandledExceptionFilter
LIBCMT.lib(invarg.obj) : error LNK2001: unresolved external symbol __imp__SetUnhandledExceptionFilter@4
LIBCMT.lib(gs_report.obj) : error LNK2001: unresolved external symbol __imp__SetUnhandledExceptionFilter@4
LIBCMT.lib(crt0dat.obj) : error LNK2019: unresolved external symbol __imp__GetProcAddress@8 referenced in function ___crtCorExitProcess
LIBCMT.lib(tidtable.obj) : error LNK2001: unresolved external symbol __imp__GetProcAddress@8

continues on with additional LIBCMT 'unresolved externals....'

25 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

You seem to be trying to do things the hard way. I don't see the ifort command you are using - it looks as if you used an option to prevent the compiler from naming the libraries it should link against. You should not have to do anything with ifort.cfg and you should allow the Intel-provided compilervars.bat script to set up the various paths.

How do you start your command session and what does your ifort command look like? Did you say you made a copy of ifort.exe?

Retired 12/31/2016

Thanks for response Steve.

To directly answer your questions:

I placed a copy of the IFORT.EXE into a subdirectory; along with IFORT.CFG; IFORTVARS.BAT; and also COMPILERVARS.BAT; along with my simple FORTRAN file TESTCODE.FOR

I run the Intel Batch Files; and then type IFORT TESTCODE.FOR and then get the resulting errors posted earlier.

I have these installed: Microsoft Visual Studio 2010 Shell
Intel Visual Fortran

My 'larger picture' is this:

I have been working with some Fortran code which I can successfully compile using the MS Visual Studio shell and Intel Fortran. However, I can not successfully 'link' with a static library developed by another agency (using Intel compiler). This Library is composed of hundreds of subroutines, in both Fortran and C/C++; and since I don't have a C/C++ compiler its not possible for me to compile the code I need from the library directly for my application.

The other agency does not use the above shells; but rather compiles from the Command Line directly. So I have been trying to compile my piece of code from the Command Line and try to link with their library through this process; using the same options that the other agency uses.

However, I can not even create a simple executable using the Command Line procedure.

My 'other option' is to 'link' with the other agency's Library through the Shell; which I have been unsuccessful at.

Any feedback on this situation is appreciated.

I have placed the Library I desire to link with in about every Intel subdirectory which looks logical; as well as in ones I have created myself.

Is there a special procedure to invoke the use of this external static Library??

What about setting all the options the other agency used when developing their library??

Thanks

Please don't make copies of the Intel Fortran files, nor should you add anything to the product folders. Reference them from the installed location. The easiest way to do this is to use one of the shortcuts provided by the product install (under Intel Parallel Studio XE 2011 > Command Line). As for linking to the external library, just add it to the ifort line, such as:

ifort testcode.for mylib.lib

If you need to specify a path to the library, do it on the ifort line.

Retired 12/31/2016

Steve- thanks.

How is the 'linking' to the static library done correctly within the Microsoft Visual Studio shell??

I have placed my desired external static library in several locations on the computer; and can not get the library to link with my code created from within the Microsoft Visual Studio / Intel Fortran shell.

I can not get the library's presence to be known to the shell; and I get 'unresolved externals' during this build process.

If I can do this linking with the static library, I can do away with the need to even compile from the Command Line.

Thanks again.

There are several ways to do it. The easiest is to add the .lib as if it were a source file. You can even drag-and-drop the .lib on the project. Depending on how the .lib was built, you may need to adjust the project property Fortran > Libraries > Use Runtime Library to match the setting used when the .lib was built.

Another way is to add the full path to the .lib to the project property Linker > Input > Additional Dependencies.

Retired 12/31/2016

Thanks Steve, I will work with these suggestions further, tomorrow....

Previous to posting on this forum, I had already added the .LIB to the Project as a 'source file,' as you suggested. No luck with doing this....

I think the issue is related to the 'options' used by the other agency to create the .LIB file.

I will work further tomorrow; and perhaps post an example of the 'command line options' used to create the .LIB by the other agency.

Thanks again....

Below is an example of the Commands used by the third party to create the Library I am trying to link to:

Example of Fortran compile for Library creation:

ifort /c /nologo /MT /names:lowercase /iface:cref /assume:underscore /Ifortran_include /O2 /debug:none /Forelease64\bits.obj dc\bits.f
ifort /c /nologo /MT /names:lowercase /iface:cref /assume:underscore /Ifortran_include /O2 /debug:none /Forelease64\dcdltr.obj dc\dcdltr.f
ifort /c /nologo /MT /names:lowercase /iface:cref /assume:underscore /Ifortran_include /O2 /debug:none /Forelease64\dcinfo.obj dc\dcinfo.f

.... many more similar lines deleted.....

Example of C/C++ compile for Library creation:

cl /nologo /c /O2 /MT /Forelease64\catsort.obj system\catsort.c
cl /nologo /c /O2 /MT /Forelease64\chmodf.obj system\chmodf.c
cl /nologo /c /O2 /MT /Forelease64\closf.obj system\closf.c
cl /nologo /c /O2 /MT /Forelease64\filesort.obj system\filesort.c

..... many more similar lines deleted....

Example of Lib creation:

lib /nologo /out:release64\heclib.lib release64\bits.obj release64\dcdltr.obj release64\dcinfo.obj release64\dcreal.obj release64\dcrept.obj release64\dcsd3r.obj release64\dhchek.obj release64\dhinfo.obj release64\dhinit.obj release64\dmreal.obj release64\dudltr.obj release64\dureal.obj release64\durept.obj release64\dusd3r.obj release64\prtary.obj .....many more similar lines deleted....

Example of Link:

link /nologo /dll /out:release64\heclib.dll User32.lib Gdi32.lib release64\bits.obj release64\dcdltr.obj release64\dcinfo.obj release64\dcreal.obj release64\dcrept.obj release64\dcsd3r.obj release64\dhchek.obj release64\dhinfo.obj release64\dhinit.obj release64\dmreal.obj release64\dudltr.obj release64\dureal.obj release64\durept.obj release64.....many more similar lines deleted......

Note: the result of the above process is the creation of a Static Library;
Made by a 'third party.'

I would like to link my code to this Library but can not get the Library
to be recognized.....

I get 'external errors' when trying to create my .EXE (using the Microsoft/Intel Shell)

I can not get code to compile from the Command Line from my machine; as discussed earlier here....

Thanks in advance for advice/assistance on this.....

I would especially like to learn 'what switches' need to be set in the Microsoft /Intel Shell; and 'exactly where' I should do this.....

Again, I am a 'newbie' to the Microsoft/Intel shell....

You are not having a problem of getting the third-party library to be recognized. Instead, you are missing Intel Fortran and Microsoft Windows API libraries. Perhaps there are other errors regarding the third-party library, but you have not shown any.

You write, "Note: the result of the above process is the creation of a Static Library;". This is not the case - the link line you showed creates a DLL. It should also create a .LIB that is the "import library" for that DLL - this is what you link against.

You've left out a lot here, so it's hard to know exactly what the problem is. Let's start out slow. Go into Visual Studio, create a new Fortran Console application "with sample code". This gets you a "Hello World" program. Build that and run it - does it work?

Are you trying to build your program in a Visual Studio project? Please attach the buildlog.htm from the Debug or Release folder as well as the project's .vfproj file from the project that fails to build. Maybe it will be clearer then what is happening.

Retired 12/31/2016

Steve- attached is the Buildlog.HTM and the VFPROJ file as requested.

I have both a .DLL and a .LIB which were constructed by the third party; I sent the information earlier used for the build of the DLL; my mistake.

Yes, I am building the program in a Visual Studio Project.

The 'missing externals' should be in the two libraries (a DLL and a LIB) which I have included in the Project; but I can't get the libraries to be recognized.

Thanks for comments made.

Attachments: 

AttachmentSize
Downloadtext/html BuildLog.htm4.94 KB
Downloadapplication/octet-stream sumforum.vfproj3.53 KB

Ok - this makes a lot more sense.

You showed the commands used to compile the sources in this library. These included /names:lowercasse and /assume:underscore. Those are conventions for UNIX/Linux and are different from the default conventions for Intel Fortran on Windows. The mismatch results in the routines not being found.

I suppose the simplest approach, though one I don't like, is to add those same options to your compiles. In your Fortran project, go to the External Procedures property page. Change "Name Case Interpretation" to "Lower Case" and "Append Underscore to External Names" to "Yes", then rebuild.

My preference would be to write interface blocks for these routines that specify BIND(C,NAME="name_") for each one, but that is a lot of work.

Retired 12/31/2016

Steve- will try this as suggested and report back tomorrow on what happened......

Thanks!!!

Steve- I did as you suggested above; but more and different'external issues' are now present.

In addition to your suggestions above, I had to change a setting to "Ignore all Default Libraries" to get around some issues between Libraries.

I've attached the latest BUILDLOG and .VFPROJ files.

I think things are improving but still issues are present.

Thanks again for feedback.

Should I 'delete' previous BUILDLOGs and .VFPROJ files before sending a new message??

Attachments: 

AttachmentSize
Downloadapplication/octet-stream sumforum.vfproj3.51 KB
Downloadtext/html BuildLog.htm38.99 KB

You should undo the change to "ignore all default libraries" - that is the cause of the errors you show here. If you show me the errors you get without that option I can better advise you. There is is no need to delete the old files.

Retired 12/31/2016

Steve- attached are my latest BUILDLOG and .VFPROJ file.

Thanks for suggestions for 'next steps' in resolving this....

Attachments: 

AttachmentSize
Downloadapplication/octet-stream sumforum.vfproj3.5 KB
Downloadtext/html BuildLog.htm6.43 KB

It looks like you built C files with default /MD while using ifort default /MT. Making those consistent should help.

Thanks Tim.

I will contact the third party who compiled the Library I am trying to use. It is composed of both FORTRAN and C/C++ constructed items.

I am only working with FORTRAN and trying to link with and use this third party library.....

Thanks again.

This is easy for you to fix. In your Fortran project properties, go to Fortran > Libraries. Change Use Runtime Library to "Multithreaded DLL".

Retired 12/31/2016

Steve- did as suggested; attached are my BUILDLOG and .VFPROJ files generated.

Thanks for thoughts on next steps....

Attachments: 

AttachmentSize
Downloadapplication/octet-stream sumforum.vfproj3.5 KB
Downloadtext/html BuildLog.htm9.73 KB

You are pulling in some object or library that was built without /libs:dll, probably in that heclib64.lib. If you change the Linker > General property "Show progress messages" to "Show all progress messages", one of the things it will tell you is which object module contained the linker directives for various libraries. If you rebuild with that and attach the buildlog.htm, I could tell you which it is.

Retired 12/31/2016

OK, will do that tomorrow AM.

The only piece of code I have done myself is the Sumhydin.f90 Fortran file.

The Library itself was created by a third party; using Intel compiler; the Library was constructed from the 'Command Line' rather than from the Visual Studio Interface (as I understand from the library builder). It contains both Fortran and C/C++ code.

My piece of code calls routines from the Library.

Thanks again.

Steve- attached is the BUILDLOG and .VFPROJ file set; developed as per your suggestions.

Feedback appreciated.

Thanks

Attachments: 

AttachmentSize
Downloadapplication/octet-stream sumforum.vfproj3.53 KB
Downloadtext/html BuildLog.htm205.21 KB

Ok - heclib is built with /MT (static libraries), so choosing /libs:dll is wrong. Please set the Use Runtime Library setting to "Multi-threaded" (not Multithreaded DLL and not a Debug version) and see what you get. Attach the buildlog again if it still has errors.

Retired 12/31/2016

Steve- finally got an EXE !!!!

MANY thanks !!!!

I've still got to do this same process with a 32 bit library but hopefully this will go easier now that I've got the 64 bit version to link with the Library....

Thanks again and Happy Easter.....

Glad to hear it.

By the way, I like to build Fortran libraries with the Libraries > Disable OBJCOMMENT Library Names set to Yes, so that they can be linked with any executable library type, as long as I know the library will be called from Fortran. If it is called from C, then you need to pick the same library setting as C will use.

Retired 12/31/2016

Leave a Comment

Please sign in to add a comment. Not a member? Join today