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

error LNK2001 & error LNK2019

johnwoo
Beginner
1,363 Views
I am trying to use Intel Fortran Compiler v10 and Visual Studio 2005 to build two projects migrated from MSDEV 6 with Compaq Fortran compiler (of course those projects built without any error in MSDEV 6).

However with VS 2005 I got two error:

1. One project linked without any error, the same file used in other project got link error 2019. The project settings are identical.

2. And link error 2001 on Fortran lib when it's using the external symbol defined in C code.

Any help it's very appreciated.

Thanks in advance.....





0 Kudos
11 Replies
Steven_L_Intel1
Employee
1,363 Views
Please show the exact and complete text of all the messages. The numbers alone tell us very little.
0 Kudos
johnwoo
Beginner
1,363 Views
Thanks Steve for your help.

Here is the error:
deli_lib.lib(testv.obj) : error LNK2019: unresolved external symbol _simfx@0 referenced in function testv

For code:
....
CALL simfx
....

C code:
void simfx(void)
....

I checked other post and changed to call in for to:
!dec$ attributes default, stdcall, alias:'simfx' :: simfx

First of all not sure if this is correct, however I got compiling error:

C: est estv.for(1120) : Error: This symbol has multiply declared DEC$ ATTRIBUTES ALIAS attribute. [E0]
: Error: This symbol has multiply declared DEC$ ATTRIBUTES STDCALL attribute. [E0]
C: est estv.for(1120) : Error: This symbol has multiply declared DEC$ ATTRIBUTES DEFAULT attribute. [E0]
compilation aborted for C: est estv.for (code 1)


0 Kudos
TimP
Honored Contributor III
1,363 Views
As you're changing the source code, it might be better to use ISO C binding.
0 Kudos
johnwoo
Beginner
1,363 Views
Steve, is there any way I can avoid to change source code? (my code still need to be compitable with MSDEV 6 and Linux)


0 Kudos
Steven_L_Intel1
Employee
1,363 Views
For simfx, change "stdcall" to "c" and remove the alias. I don't see how this would have worked under CVF. There's something else going on you're not showing us.

Please show us the ATTRIBUTES lines for EO.
0 Kudos
johnwoo
Beginner
1,363 Views
You are right Steve, here is the line (in .for) I corrected and it works:

!DEC$ ATTRIBUTES C :: simfx
!DEC$ ATTRIBUTES C :: simfx1


However if I tried to use 'extern "C" void simfx()' in simfx code, and compile it as C++ I got link error on line: __declspec(dllimport). I had to remove extern "C" and compile it as C then it has no link error.

simfx c code:
void simfx_common()
.....
void simfx () {
simfx_common();
.....}
void simfx1() {
simfx_common();
.....}

However I still have another issue in this code (next link error):
testv.lib(dual.obj) : error LNK2019: unresolved external symbol _dummy_counter@0 referenced in function _visin
testv.lib(dual.obj) : error LNK2019: unresolved external symbol _initlog@0 referenced in function _visin
testv.lib(dual.obj) : error LNK2019: unresolved external symbol _trnl@24 referenced in function _visin

The way it's in .for code:
....
ISTATUS = dummy_counter()
....
ISTATUS = initcaelog()
....
ISTATUS = TRNL('RUN_VISUAL',LOG_LEN,INTERFACE,0)

all declared in a seperate lib which I linked to my C project, I have no control on that lib, how I could get rid of such link errors?

Thanks a million.

0 Kudos
Steven_L_Intel1
Employee
1,363 Views
Not enough information - I'd need to see the actual library and code. If you want to submit an Intel Premier Support issue and attach a ZIP of your projects and ask that it be assigned to me, I'll take a look.
0 Kudos
johnwoo
Beginner
1,363 Views
Steve, I am trying to find a way how to submit the support request as I can't send any code to you guys due to data issues.

However, I did another test and put those modules under another projetc (in same solution) and there is no link errors, what could cause such errors under my current project?
0 Kudos
johnwoo
Beginner
1,363 Views
Problem fixed, automated conversion set /iface:cvf instead of /iface:cref (OK for another project but not for the current one), maybe the bug in automated conversion tool?.....
0 Kudos
Steven_L_Intel1
Employee
1,363 Views
Did you have /iface:cref in the CVF project? If so, then yes, that's a tool bug and please report it.
0 Kudos
shanzy1980
Beginner
1,363 Views
the only reason is: you must link some lib files, while Microsoft change these lib files and they forget to tell you, or you need see some more informations about the changes from vc6 to vs2005!
0 Kudos
Reply