Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
101 Views

crazy problems with a lot of LNK2001 errors (external symbol not resolved)

Hi to everybody and thank in advance for your help!

I'm trying to compile a Fortran program with a 64-bit compiler. First, The program is written and 32-bit compiled with Compaq Visual Fortran and it is made by a lot of files and some home made static libraries. I have installed Visual Studio 2017 and Intel Parallel Studio XE 2018 with the necessary Fortran part. Now, after a lot of unsuccessful test, I'm in the situation when I haven't home made libraries because all files have been inserted into the project. The problem is the presence of a lot of LNK2001 errors about external symbols: some times are related to symbols inside .obj files related to the fortran files, other times to libraries like: libifcoremt.lib, libifport.lib, libirc.lib, libmmt.lib, mkl_core.lib, mkl_sequential.lib, libcmtd.lib. For the reported libraries, I have tryed to link them without changes and now I have added them directly into the project.

This is my config about the Fortran section inside the project properties:

/nologo /O2 /module:"x64\Debug\\" /object:"x64\Debug\\" /Fd"x64\Debug\vc150.pdb" /check:bounds /libs:static /threads /dbglibs /Qmkl:sequential /c

This is my config about the Linker section inside the project properties:

/OUT:"x64\Debug\EFIE_3D.exe" /INCREMENTAL:NO /NOLOGO /MANIFEST /MANIFESTFILE:"x64\Debug\EFIE_3D.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG /PDB:"C:\Users\ING01\source\repos\EFIE_3D\EFIE_3D\x64\Debug\EFIE_3D.pdb" /SUBSYSTEM:WINDOWS /ENTRY:"EFIE_3D_main"

I'm becoming crazy because I have tryed a lot of combination without succes and my activity is blocked!

0 Kudos
12 Replies
Highlighted
101 Views

My favorite kind of problem is a crazy one ...  ( I heard that, Steve!)

However, it's not possible to help here without a little bit more information.

Can you post the build.htm from your unsuccessful build?  I don't care about the source files (at least, not yet :-) ) but I do want to see the command line options used to build, and I want to see the exact missing names.   These things usually give a clue.

That said, I have a working theory based on knowing that the sources are being moved from 32-bit CVF to 64-bit IVF, I just need to confirm it.

           thanks -

                                --Lorri

0 Kudos
Highlighted
101 Views

Thank a lot for you comment! here you can find my build.htm (saved in txt format). Howewer, I have compiled with success some parts in order to recreate the 64-bit version of the previous 32-bit home made libraries; but, also with the new libraries the situation has not changed.

0 Kudos
Highlighted
101 Views

You said you'd moved a few files; where did you get libcmtd.lib?   Was that from the CVF installation?  Or somewhere else?

The missing externals - for the most part - are C intrinsics, and should be found in libcmt.lib (or libcmtd.lib if you really need the debug version) so I'm most suspicious about that library.

Also - I find these two linker options interesting:

/ENTRY:"EFIE_3D_main" /IMPLIB:"C:\Users\ING01\source\repos\EFIE_3D\EFIE_3D\x64\Debug\EFIE_3D.lib"

I don't think you should be listing EFIE_3D_main as your entry point; you shouldn't need to specify anything.

And, it's interesting you have an import library designated, even though you're creating an executable.

        --Lorri

0 Kudos
Highlighted
101 Views

Lorri Menard (Intel) wrote:

You said you'd moved a few files; where did you get libcmtd.lib?   Was that from the CVF installation?  Or somewhere else?

The missing externals - for the most part - are C intrinsics, and should be found in libcmt.lib (or libcmtd.lib if you really need the debug version) so I'm most suspicious about that library.

I found the libcmtd.lib library inside the Visual Studio Installation folder because I have installed also the C and C++ components.

Lorri Menard (Intel) wrote:

Also - I find these two linker options interesting:

/ENTRY:"EFIE_3D_main" /IMPLIB:"C:\Users\ING01\source\repos\EFIE_3D\EFIE_3D\x64\Debug\EFIE_3D.lib"

I don't think you should be listing EFIE_3D_main as your entry point; you shouldn't need to specify anything.

I have defined EFIE_3D_main as entry point because, without it, I had an error due to the fact that the main file is not called "main".

Lorri Menard (Intel) wrote:

And, it's interesting you have an import library designated, even though you're creating an executable.

        --Lorri

I don't understand it: the linker option /IMPLIB:"C:\Users\ING01\source\repos\EFIE_3D\EFIE_3D\x64\Debug\EFIE_3D.lib" is a VS default option.

0 Kudos
Highlighted
101 Views

Another strange behaviour is that, with the option "/debug:full" into Fortran->General->Debug Information Format, all the old errors disappear and 6 new errors appear without the possibilities to understand why:

Compilation Aborted (code 1)        F:\Google Drive\Lavoro Scientifico\EFIE_3D\EFIE_3D sorgenti\test\MIELIBRERIE\mielibrerie.src\generali\scrivo.f    1    

Compilation Aborted (code 1)        F:\Google Drive\Lavoro Scientifico\EFIE_3D\EFIE_3D sorgenti\test\EFIE_3D.src\01 in-out\scrivo.f    1    
Compilation Aborted (code 1)        F:\Google Drive\Lavoro Scientifico\EFIE_3D\EFIE_3D sorgenti\test\EFIE_3D.src\02 gestione_memoria\alloc_cpu_info.f    1    
Compilation Aborted (code 1)        F:\Google Drive\Lavoro Scientifico\EFIE_3D\EFIE_3D sorgenti\test\MIELIBRERIE\mielibrerie.src\generali\dparametri.f    1    
Compilation Aborted (code 1)        F:\Google Drive\Lavoro Scientifico\EFIE_3D\EFIE_3D sorgenti\test\MIELIBRERIE\mielibrerie.src\generali\iparametri.f    1    

 

0 Kudos
Highlighted
101 Views

Ok, let's do the easy one first.   The /debug:full is probably turning on /debug_parameters:full, and there is a known issue where that causes the compiler to get an internal compiler error.

If there is an internal compiler error, the processing does not continue to the "link" step, and that's where your other messages were appearing.

Please go to Project->Settings->Fortran->Debugging  and set "Information for PARAMETER constants" to be "None".

re: I have defined EFIE_3D_main as entry point because, without it, I had an error due to the fact that the main file is not called "main".

The *name* of the file doesn't make a difference, it has to do with the routine name that will be the primary entry point.    What error did you get  before?  If this is a Windows application then it would be looking for a routine named "WinMain" to be the entry point.   Do you have that in the file efie_3d_main.f?

 

0 Kudos
Highlighted
101 Views

Lorri Menard (Intel) wrote:

Ok, let's do the easy one first.   The /debug:full is probably turning on /debug_parameters:full, and there is a known issue where that causes the compiler to get an internal compiler error.

If there is an internal compiler error, the processing does not continue to the "link" step, and that's where your other messages were appearing.

Please go to Project->Settings->Fortran->Debugging  and set "Information for PARAMETER constants" to be "None".

The 6 errors reported above are obtained with "Debug Information Format: Full (/debug:full)" and "Information for PARAMETER Constants: None"; but this is not a fully important point.

Lorri Menard (Intel) wrote:

re: I have defined EFIE_3D_main as entry point because, without it, I had an error due to the fact that the main file is not called "main".

The *name* of the file doesn't make a difference, it has to do with the routine name that will be the primary entry point.    What error did you get  before?  If this is a Windows application then it would be looking for a routine named "WinMain" to be the entry point.   Do you have that in the file efie_3d_main.f?

Without defining the entry point, the error is:
error LNK2019: unresolved external symbol WinMain referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)        LIBCMTD.lib(exe_winmain.obj)       
fatal error LNK1120: 1 unresolved externals        x64\Debug\EFIE_3D.exe       

Originally, into CVF, the executable was a console one, so an application which open a command prompt. Here, as SubSystem, I can't indicate Console because I red that is dedicated to 32-bit applications. So, I have selected Windows. For this motivation, inside EFIE_3D_main.f there is not a WinMain routine.

0 Kudos
Highlighted
101 Views

I have renamed the EFIE_3D_main.f as WinMain.f and inside the "program EFIE_3D_main" has been modified as "program WinMain"; also, I have removed the entry point inside the properties. But the result is the same:

 error LNK2019: unresolved external symbol WinMain referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)        LIBCMTD.lib(exe_winmain.obj)        
 fatal error LNK1120: 1 unresolved externals        x64\Debug\EFIE_3D.exe        

 

0 Kudos
Highlighted
Black Belt Retired Employee
101 Views

Console is fine for a 64-bit application. By selecting Windows, you're telling the linker that the entry point is a function named WinMain with four arguments. Don't try to fudge this with renaming.

0 Kudos
Highlighted
101 Views

Steve Lionel (Ret.) wrote:

Console is fine for a 64-bit application. By selecting Windows, you're telling the linker that the entry point is a function named WinMain with four arguments. Don't try to fudge this with renaming.

Thank you so much for your help!! Actually, I have an exe!!!!!!! but I don't understand how I have obtained it. By selecting Windows, renaming the main file with winmain.f and also the program inside, the situation was the same. By selecting Console, with the main file named EFIE_3D_main.f, the program inside EFIE_3D_main, the situation was the same with or without the indication of the entry point. I have obtained the exe by selecting Console, file named winmain.f, the program winmain, without entry point... Tomorrow I will try it.

0 Kudos
Highlighted
101 Views

ah.  More of this is coming clear.

A console application CAN be 64-bit without any problems.

Can you try recreating your project (sorry, yes, it needs to be recreated) as a CONSOLE application?   That will resolve the entry point problem, since you have a console-main entry point.

It might also resolve the C-library issue (at least, I'm hopeful)

                      Please, keep me posted --

                                          --Lorri

 

0 Kudos
Highlighted
101 Views

Lorri Menard (Intel) wrote:

ah.  More of this is coming clear.

A console application CAN be 64-bit without any problems.

Can you try recreating your project (sorry, yes, it needs to be recreated) as a CONSOLE application?   That will resolve the entry point problem, since you have a console-main entry point.

It might also resolve the C-library issue (at least, I'm hopeful)

                      Please, keep me posted --

                                          --Lorri

An update: the exe is obtainable also by using EFIE_3D_main.f and without entry point. Really thank a lot to everyone!!!!!

0 Kudos