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

Unresolved external

Myles_Fisher
Beginner
570 Views
When I build my project, the linker fails with the following diagnostic:
MarkSim_v1.2.obj : error LNK2019: unresolved external symbol _CLXGEN referenced in function _MAIN__

CLXGEN is a subroutine in the project and has complied with no problems:

The complete build log is:

Build started: Project: MarkSim_v1.3, Configuration: Debug|Win32

Output
Compiling with Intel Visual Fortran 11.1.067 [IA-32]...
ifort /nologo /debug:full /Od /gen-interfaces /warn:interfaces /module:"Debug\\\\" /object:"Debug\\\\" /traceback /check:bounds /libs:static /threads /dbglibs /c /extfor:f /Qvc9 /Qlocation,link,"C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\bin" "E:\\MarkSim_Source_Code\\fortran source\\freq.f"
ifort /nologo /debug:full /Od /gen-interfaces /warn:interfaces /module:"Debug\\\\" /object:"Debug\\\\" /traceback /check:bounds /libs:static /threads /dbglibs /c /Qvc9 /Qlocation,link,"C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\bin" "E:\\MarkSim_Source_Code\\Rungen\\UPCASE.f90"
ifort /nologo /debug:full /Od /gen-interfaces /warn:interfaces /module:"Debug\\\\" /object:"Debug\\\\" /traceback /check:bounds /libs:static /threads /dbglibs /c /Qvc9 /Qlocation,link,"C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\bin" "E:\\MarkSim_Source_Code\\Rungen\\READS.f90"
ifort /nologo /debug:full /Od /gen-interfaces /warn:interfaces /module:"Debug\\\\" /object:"Debug\\\\" /traceback /check:bounds /libs:static /threads /dbglibs /c /Qvc9 /Qlocation,link,"C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\bin" "E:\\MarkSim_Source_Code\\Rungen\\DSSAT.f90"
ifort /nologo /debug:full /Od /gen-interfaces /warn:interfaces /module:"Debug\\\\" /object:"Debug\\\\" /traceback /check:bounds /libs:static /threads /dbglibs /c /Qvc9 /Qlocation,link,"C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\bin" "E:\\MarkSim_Source_Code\\Rungen\\WGEN.f90"
ifort /nologo /debug:full /Od /gen-interfaces /warn:interfaces /module:"Debug\\\\" /object:"Debug\\\\" /traceback /check:bounds /libs:static /threads /dbglibs /c /extfor:f /Qvc9 /Qlocation,link,"C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\bin" "E:\\MarkSim_Source_Code\\fortran source\\frqinv.f"
ifort /nologo /debug:full /Od /gen-interfaces /warn:interfaces /module:"Debug\\\\" /object:"Debug\\\\" /traceback /check:bounds /libs:static /threads /dbglibs /c /Qvc9 /Qlocation,link,"C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\bin" "E:\\MarkSim_Source_Code\\Rungen\\MARKOV.f90"
ifort /nologo /debug:full /Od /gen-interfaces /warn:interfaces /module:"Debug\\\\" /object:"Debug\\\\" /traceback /check:bounds /libs:static /threads /dbglibs /c /extfor:f /Qvc9 /Qlocation,link,"C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\bin" "E:\\MarkSim_Source_Code\\clxgen\\camdon.f"
ifort /nologo /debug:full /Od /gen-interfaces /warn:interfaces /module:"Debug\\\\" /object:"Debug\\\\" /traceback /check:bounds /libs:static /threads /dbglibs /c /extfor:f /Qvc9 /Qlocation,link,"C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\bin" "E:\\MarkSim_Source_Code\\fortran source\\new.rotate.f"
ifort /nologo /debug:full /Od /gen-interfaces /warn:interfaces /module:"Debug\\\\" /object:"Debug\\\\" /traceback /check:bounds /libs:static /threads /dbglibs /c /Qvc9 /Qlocation,link,"C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\bin" "E:\\MarkSim_Source_Code\\Rungen\\readxbf.f90"
ifort /nologo /debug:full /Od /gen-interfaces /warn:interfaces /module:"Debug\\\\" /object:"Debug\\\\" /traceback /check:bounds /libs:static /threads /dbglibs /c /extfor:f /Qvc9 /Qlocation,link,"C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\bin" "E:\\MarkSim_Source_Code\\fortran source\\encode.f"
ifort /nologo /debug:full /Od /gen-interfaces /warn:interfaces /module:"Debug\\\\" /object:"Debug\\\\" /traceback /check:bounds /libs:static /threads /dbglibs /c /Qvc9 /Qlocation,link,"C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\bin" "E:\\MarkSim_Source_Code\\Rungen\\simmin.f90"
ifort /nologo /debug:full /Od /gen-interfaces /warn:interfaces /module:"Debug\\\\" /object:"Debug\\\\" /traceback /check:bounds /libs:static /threads /dbglibs /c /Qvc9 /Qlocation,link,"C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\bin" "E:\\MarkSim_Source_Code\\Rungen\\RGAMMA.F90"
ifort /nologo /debug:full /Od /gen-interfaces /warn:interfaces /module:"Debug\\\\" /object:"Debug\\\\" /traceback /check:bounds /libs:static /threads /dbglibs /c /Qvc9 /Qlocation,link,"C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\bin" "E:\\MarkSim_Source_Code\\Rungen\\DATES.f90"
ifort /nologo /debug:full /Od /gen-interfaces /warn:interfaces /module:"Debug\\\\" /object:"Debug\\\\" /traceback /check:bounds /libs:static /threads /dbglibs /c /Qvc9 /Qlocation,link,"C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\bin" "E:\\MarkSim_Source_Code\\clxgen\\tlapse.f90"
ifort /nologo /debug:full /Od /gen-interfaces /warn:interfaces /module:"Debug\\\\" /object:"Debug\\\\" /traceback /check:bounds /libs:static /threads /dbglibs /c /Qvc9 /Qlocation,link,"C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\bin" "E:\\MarkSim_Source_Code\\Rungen\\make_cli.f90"
ifort /nologo /debug:full /Od /gen-interfaces /warn:interfaces /module:"Debug\\\\" /object:"Debug\\\\" /traceback /check:bounds /libs:static /threads /dbglibs /c /extfor:f /Qvc9 /Qlocation,link,"C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\bin" "E:\\MarkSim_Source_Code\\fortran source\\angle.f"
ifort /nologo /debug:full /Od /gen-interfaces /warn:interfaces /module:"Debug\\\\" /object:"Debug\\\\" /traceback /check:bounds /libs:static /threads /dbglibs /c /extfor:f /Qvc9 /Qlocation,link,"C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\bin" "E:\\MarkSim_Source_Code\\fortran source\\decode.f"
ifort /nologo /debug:full /Od /gen-interfaces /warn:interfaces /module:"Debug\\\\" /object:"Debug\\\\" /traceback /check:bounds /libs:static /threads /dbglibs /c /Qvc9 /Qlocation,link,"C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\bin" "E:\\MarkSim_Source_Code\\clxgen\\readclus.f90"
ifort /nologo /debug:full /Od /gen-interfaces /warn:interfaces /module:"Debug\\\\" /object:"Debug\\\\" /traceback /check:bounds /libs:static /threads /dbglibs /c /Qvc9 /Qlocation,link,"C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\bin" "E:\\MarkSim_Source_Code\\clxgen\\getgrid.f90"
ifort /nologo /debug:full /Od /gen-interfaces /warn:interfaces /module:"Debug\\\\" /object:"Debug\\\\" /traceback /check:bounds /libs:static /threads /dbglibs /c /Qvc9 /Qlocation,link,"C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\bin" "E:\\MarkSim_Source_Code\\Rungen\\rungen.f90"
ifort /nologo /debug:full /Od /gen-interfaces /warn:interfaces /module:"Debug\\\\" /object:"Debug\\\\" /traceback /check:bounds /libs:static /threads /dbglibs /c /Qvc9 /Qlocation,link,"C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\bin" "E:\\MarkSim_Source_Code\\Rungen\\rsampl.f90"
ifort /nologo /debug:full /Od /gen-interfaces /warn:interfaces /module:"Debug\\\\" /object:"Debug\\\\" /traceback /check:bounds /libs:static /threads /dbglibs /c /Qvc9 /Qlocation,link,"C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\bin" "E:\\MarkSim_Source_Code\\clxgen\\makeclx.f90"
ifort /nologo /debug:full /Od /gen-interfaces /warn:interfaces /module:"Debug\\\\" /object:"Debug\\\\" /traceback /check:bounds /libs:static /threads /dbglibs /c /Qvc9 /Qlocation,link,"C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\bin" "C:\\Users\\TOSHIBA\\Documents\\Visual Studio 2008\\Projects\\MarkSim_v1.2\\MarkSim_v1.2\\MarkSim_v1.2.f90"
ifort /nologo /debug:full /Od /gen-interfaces /warn:interfaces /module:"Debug\\\\" /object:"Debug\\\\" /traceback /check:bounds /libs:static /threads /dbglibs /c /Qvc9 /Qlocation,link,"C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\bin" "E:\\MarkSim_Source_Code\\Rungen\\calendar.f90"
ifort /nologo /debug:full /Od /gen-interfaces /warn:interfaces /module:"Debug\\\\" /object:"Debug\\\\" /traceback /check:bounds /libs:static /threads /dbglibs /c /Qvc9 /Qlocation,link,"C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\bin" "E:\\MarkSim_Source_Code\\Rungen\\rainseq.f90"
ifort /nologo /debug:full /Od /gen-interfaces /warn:interfaces /module:"Debug\\\\" /object:"Debug\\\\" /traceback /check:bounds /libs:static /threads /dbglibs /c /Qvc9 /Qlocation,link,"C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\bin" "E:\\MarkSim_Source_Code\\clxgen\\findclus.f90"
ifort /nologo /debug:full /Od /gen-interfaces /warn:interfaces /module:"Debug\\\\" /object:"Debug\\\\" /traceback /check:bounds /libs:static /threads /dbglibs /c /Qvc9 /Qlocation,link,"C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\bin" "E:\\MarkSim_Source_Code\\Rungen\\markset.f90"
ifort /nologo /debug:full /Od /gen-interfaces /warn:interfaces /module:"Debug\\\\" /object:"Debug\\\\" /traceback /check:bounds /libs:static /threads /dbglibs /c /Qvc9 /Qlocation,link,"C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\bin" "E:\\MarkSim_Source_Code\\clxgen\\CLXGEN.f90"
Linking...
Creating temporary file "RSP1.rsp" with contents
[
 /OUT:"Debug\\MarkSim_v1.3.exe" /INCREMENTAL:NO /NOLOGO /MANIFEST /MANIFESTFILE:"C:\\Users\\TOSHIBA\\Documents\\Visual Studio 2008\\Projects\\MarkSim_v1.2\\MarkSim_v1.2\\Debug\\MarkSim_v1.3.exe.intermediate.manifest" /DEBUG /PDB:"C:\\Users\\TOSHIBA\\Documents\\Visual Studio 2008\\Projects\\MarkSim_v1.2\\MarkSim_v1.2\\Debug\\MarkSim_v1.3.pdb" /SUBSYSTEM:CONSOLE /IMPLIB:"C:\\Users\\TOSHIBA\\Documents\\Visual Studio 2008\\Projects\\MarkSim_v1.2\\MarkSim_v1.2\\Debug\\MarkSim_v1.3.lib" "Debug\\freq.obj" "Debug\\UPCASE.obj" "Debug\\READS.obj" "Debug\\DSSAT.obj" "Debug\\WGEN.obj" "Debug\\frqinv.obj" "Debug\\MARKOV.obj" "Debug\\camdon.obj" "Debug\\new.rotate.obj" "Debug\\readxbf.obj" "Debug\\encode.obj" "Debug\\simmin.obj" "Debug\\RGAMMA.obj" "Debug\\DATES.obj" "Debug\\tlapse.obj" "Debug\\make_cli.obj" "Debug\\angle.obj" "Debug\\decode.obj" "Debug\\readclus.obj" "Debug\\getgrid.obj" "Debug\\rungen.obj" "Debug\\rsampl.obj" "Debug\\makeclx.obj" "Debug\\MarkSim_v1.2.obj" "Debug\\calendar.obj" "Debug\\rainseq.obj" "Debug\\findclus.obj" "Debug\\markset.obj" "Debug\\CLXGEN.obj"
]
Creating command line "Link @"C:\\Users\\TOSHIBA\\Documents\\Visual Studio 2008\\Projects\\MarkSim_v1.2\\MarkSim_v1.2\\Debug\\RSP1.rsp""

Link: executing 'link'
   Creating library C:\\Users\\TOSHIBA\\Documents\\Visual Studio 2008\\Projects\\MarkSim_v1.2\\MarkSim_v1.2\\Debug\\MarkSim_v1.3.lib and object C:\\Users\\TOSHIBA\\Documents\\Visual Studio 2008\\Projects\\MarkSim_v1.2\\MarkSim_v1.2\\Debug\\MarkSim_v1.3.exp
MarkSim_v1.2.obj : error LNK2019: unresolved external symbol _CLXGEN referenced in function _MAIN__
Debug\\MarkSim_v1.3.exe : fatal error LNK1120: 1 unresolved externals


MarkSim_v1.3 - 2 error(s), 0 warning(s)


Operating system is Windows 7 Home Premium 64 bit

Microsoft Visual Studio 2008
Version 9.0.21022.8 RTM
Microsoft .NET Framework
Version 3.5 SP1

Installed Edition: IDE Standard

Intel Visual Fortran Compiler Integration Package ID: w_cprof_p_11.1.067
Intel Visual Fortran Compiler Integration for Microsoft Visual Studio* 2008, 11.1.3471.2008, Copyright (C) 2002-2010 Intel Corporation
* Other names and brands may be claimed as the property of others.

0 Kudos
6 Replies
TimP
Honored Contributor III
570 Views
One would suspect a failure in the initial compilation of clxgen.f90, which might show up more clearly if you would attempt to build clxgen.obj by itself.
0 Kudos
Steven_L_Intel1
Employee
570 Views
clxgen.f90 was compiled and got no errors. I'm going to take a guess and say that the routine CLXGEN is in a module but was declared independently in the caller. What is CLXGEN and how is it defined?
0 Kudos
Myles_Fisher
Beginner
570 Views
Dear Steve,

Thank you for your response. I feel very stupid that I have wasted your time, and I apologise.

By a tedious process of elimination I found that the problem was a compiler directive buried amongst 60 or so lines of comments at the head of subroutine CLXGEN. The original author had made the subroutine and a dozen other modules into a DLL. Because all the text in the comments, and the directive, is in green typeface in VS2008, I completely overlooked it. Indeed, as I eliminated the code section by section, I could not believe that the problem persisted when there was no functional code (as I thought) left. Then the Sherlock Holmes moment, eliminate everything and whatever is left has to be the answer, no matter how impossible.

Moral? Identify compiler directives clearly so that they cannot be overlooked so easily.

Thanks again for your response. I read your responses to others with interest, even though a lot of it is way over my level.

Cheers.

Myles Fisher
0 Kudos
Steven_L_Intel1
Employee
570 Views
No need to apologize or feel "stupid". It was a perfectly reasonable question.

Can you satisfy my curiosity and show me the directive? Was it that the author moved ALL that code to a DLL and that you needed to link to the DLL library? I don't fully understand what went wrong.
0 Kudos
Myles_Fisher
Beginner
570 Views
Of course, and thank you for your interest.

The code in question is part of a weather generator specifically for the tropics. In the 'public' version it is a Delphi shell that calls two FORTRAN DLLs. The problem with the shell is that it is only possible to use it in a quasi batch mode through the shell using control files. If either of the DLLs crash for any reason (and they do), you have manually to modify the control files and try again. We want to use it in an exercise to look at the effects of climate change on beans and maize subsistence farming systems in central America. We use a 2.5-km grid, which gives 18,000+ sites, with input to the weather generator coming from the output of 19 global circulation models, so we want to run it in true batch mode and on our cluster if possible. It is just not feasible to run it from the shell to do this work.

We then found the source code of the DLLs, and since I have my own FORTRAN compiler and I've been programming in it off and on since 1964 (starting on a Control Data 3600!) my colleagues asked me to look at the problem.

I started by trying to make the code into one compiled executable by writing a simple front end that calls, in turn, the main subroutines from each of the DLLs. It worked in debug mode in VS2008, but when I then tried to make a release version, it failed to link with the unresolved external. By chance, I found that the release version would link without error if I set compile time diagnostics to on (/warn:all), which gave 280 warnings because of all the legacy code, but which only served to confuse me more. In desperation, after I made the post yesterday, I finally started on the first subroutine (clxgen.f90) a cycle of prune the code/compile until I had no code left, just the comments and a RETURN. And still the unresolved external. Enter Sherlock Holmes and then I found it!

The segment of the comments (there are 120 lines of comments), with the compiler directives follows:
!
! Expose subroutine CLXGEN to users of this DLL
!
!DEC$ ATTRIBUTES DLLEXPORT::CLXGEN
!DEC$ ATTRIBUTES ALIAS:'CLXGEN'::CLXGEN

! Markov rainfall model interpolation system MARKSIM
and another 103 lines of comments.

Sorry to be so long winded.

Cheers.

Myles

0 Kudos
Steven_L_Intel1
Employee
570 Views
Ah, it's the ALIAS. This removes the default leading underscore decoration of global names. In order to call this, you would need to add the same ATTRIBUTES ALIAS directive to the source of the caller. You could also add a corresponding ATTRIBUTES DLLIMPORT directive, though this is not strictly required.
0 Kudos
Reply