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

linking with static library created using lf95

Intel_C_Intel
Employee
1,119 Views
Hello,

I have a driver program that I would like to compile and link with a static library that has been created using lahey (lf95) compiler.

However I get unresolved external symbol reference error. kindly help


Here are the outputs of the two compilers -

With LF95:
----------
C:Documents and Settings p.utikar.TSPLDesktopINBOXSLE runk�3-WorkSource-
CodeDelivery02>lf95 driver.f90 Delivery02.lib
Lahey/Fujitsu Fortran 95 Express Release 7.10.02 S/N: UNLICENSED
Copyright (C) 1994-2004 Lahey Computer Systems. All rights reserved.
Copyright (C) 1998-2004 FUJITSU LIMITED. All rights reserved.
Compiling file driver.f90.
Compiling program unit driver_sqmppfo at line 1:
Encountered 0 errors, 0 warnings in file driver.f90.
Microsoft Incremental Linker Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

WARNING -- Days remaining until expiration of Trial: 14.

C:Documents and Settings p.utikar.TSPLDesktopINBOXSLE runk�3-WorkSource-
CodeDelivery02>


with IFORT
-----------

C:Documents and Settings p.utikar.TSPLDesktopINBOXSLE runk�3-WorkSource-
CodeDelivery02>ifort driver.f90 delivery02.lib
Intel Visual Fortran Compiler for applications running on IA-32, Version 10.0
Build 20070613 Package ID: W_FC_C_10.0.026
Copyright (C) 1985-2007 Intel Corporation. All rights reserved.

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

-out:driver.exe
-subsystem:console
driver.obj
delivery02.lib
driver.obj : error LNK2019: unresolved external symbol _PARAMETERS referenced in
function _MAIN__
driver.obj : error LNK2019: unresolved external symbol _LIQUIDACTIVITYCOEFFICIEN
TS referenced in function _MAIN__
driver.obj : error LNK2019: unresolved external symbol _SOLIDDISSOCIATIONEQUILIB
RIUMCONSTANTS referenced in function _MAIN__
driver.obj : error LNK2019: unresolved external symbol _LIQUIDREACTIONEQUILIBRIU
MCONSTANTS referenced in function _MAIN__
driver.obj : error LNK2019: unresolved external symbol _LIQUIDDENSITY referenced
in function _MAIN__
driver.obj : error LNK2019: unresolved external symbol _PURESOLIDDENSITY referen
ced in function _MAIN__
driver.exe : fatal error LNK1120: 6 unresolved externals

C:Documents and Settings p.utikar.TSPLDesktopINBOXSLE runk�3-WorkSource-
CodeDelivery02>
0 Kudos
2 Replies
Intel_C_Intel
Employee
1,119 Views
after searching through forum, i added following code to the driver.f90


!DEC$ATTRIBUTES REFERENCE,ALIAS:"_parameters_" :: parameters
!DEC$ATTRIBUTES REFERENCE,ALIAS:"_liquidactivitycoefficients_" :: liquidactivitycoefficients
!DEC$ATTRIBUTES REFERENCE,ALIAS:"_soliddissociationequilibriumconstants_" :: soliddissociationequilibriumconstants
!DEC$ATTRIBUTES REFERENCE,ALIAS:"_liquidreactionequilibriumconstants_" :: liquidreactionequilibriumconstants
!DEC$ATTRIBUTES REFERENCE,ALIAS:"_liquiddensity_" :: liquiddensity
!DEC$ATTRIBUTES REFERENCE,ALIAS:"_puresoliddensity_" :: puresoliddensity

this gave following link error

Error1 error LNK2019: unresolved external symbol _g_derf referenced in function _derprecipitationsquish_Delivery02.lib
Error2 error LNK2019: unresolved external symbol _jwe_iocf referenced in function _readdata_Delivery02.lib
Error3 error LNK2019: unresolved external symbol _jwe_ilst referenced in function _readdata_Delivery02.lib
Error4 error LNK2019: unresolved external symbol _f_scmov referenced in function _parameters_Delivery02.lib
Error5 error LNK2019: unresolved external symbol _g_adxi referenced in function _soliddissociationindex_Delivery02.lib
Error6 error LNK2019: unresolved external symbol _jwe_xadt referenced in function _der_liquidfugacity_Delivery02.lib
Error7 error LNK2019: unresolved external symbol _jwe_xddt referenced in function _der_liquidfugacity_Delivery02.lib
Error8 error LNK2019: unresolved external symbol _g_dexp referenced in function _liquidactivitycoefficients_Delivery02.lib
Error9 error LNK2019: unresolved external symbol _g_dlog referenced in function _liquidactivitycoefficients_Delivery02.lib
Error10 error LNK2019: unresolved external symbol _g_dsqrt referenced in function _liquidactivitycoefficients_Delivery02.lib
Error11 error LNK2019: unresolved external symbol _f_trans referenced in function _inf_nan_detection@_sisnan_Delivery02.lib
Error12 error LNK2019: unresolved external symbol _jwe_xalc referenced in function _inf_nan_detection@_sisnan_& nbsp;Delivery02.lib
Error13 error LNK2019: unresolved external symbol _jwe_xdal referenced in function _inf_nan_detection@_sisnan_Delivery02.lib
Error14 fatal error LNK1120: 13 unresolved externalsDebugDelivery2.exe

pl. reply,
Best regards, Ranjeet.
0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,119 Views
In general, you cannot mix object code created by 2 different compilers, especially not same-language compilers. Every compiler inserts references to its own run-time library routines (g_derf, jwe_iocf in the case of LF95) and, when linked all together, they might easily clash with the other compiler's RTL calls.

a) Since you possess both compilers, why not simply rebuild the static library sources with ifort and link them to ifort driver code?
b) If that's not feasible for some reason, a better alternative would be to create a DLL using LF95 and call that from Ifort code -- DLLs isolate the dependencies much better than static libraries
c) If that's not feasible for some reason either, you might try to supply LF95's run-time libraries (whatever they're called) to the linker's command line. Like I said above, it might work and will probably get linked, but it's highly likely that you will get some strange run-time behavior.
0 Kudos
Reply