Results 1 to 6 of 6

Thread: error LNK2019: unresolved external symbol with IMSL function call

  1. #1
    Junior Member
    Join Date
    Sep 2018
    Posts
    4

    error LNK2019: unresolved external symbol with IMSL function call

    Hi All,

    I've an Intel Visual Fortran (IVF) static library that uses an IMSL function: BCNLS for non-linear curvefit. I use a subroutine FCN as an argument for this IMSL function call and follow the IMSL's instruction to declare FNC as External.

    ~~~~~~~~~~~~~~~~~~~~~~~~~

    Module MyStaticLib

    Function Call_IMSL_BCNLS

    External FCN

    . CALL BCNLS (FCN,....)

    End Function

    Subroutine FNC

    End subroutine

    End Sub

    End Module

    ~~~~~~~~~~~~~~~~~~~~~~~~~

    Then, I've another IVF DLL that links to this static lib. When it compiles, it is fine. But when building it, it causes "error LNK2019: unresolved external symbol".

    The following is the error message:

    ~~~~~~~~~~~~~~~~~~~~~
    1>------ Build started: Project: TGF_IC, Configuration: Debug Win32 ------
    1>Compiling manifest to resources...
    1>Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
    1>Copyright (C) Microsoft Corporation. All rights reserved.
    1>Linking...
    1>Creating library C:\1_TechCodeVSS\TGF_IC_DLL\TGF_IC\Debug\TGF_IC.li b and object C:\1_TechCodeVSS\TGF_IC_DLL\TGF_IC\Debug\TGF_IC.ex p
    1>tgf_math.lib(ttf_math.obj) : error LNK2019: unresolved external symbol _FCN_EXPO referenced in function _TGF_MATH_mp_MODELFIT_EXPO
    1>tgf_math.lib(ttf_math.obj) : error LNK2019: unresolved external symbol _FCN_POWER referenced in function _TGF_MATH_mp_MODELFIT_ALL
    1>Debug\TGF_IC.dll : fatal error LNK1120: 2 unresolved externals
    1>
    1>Build log written to "file://C:\1_TechCodeVSS\TGF_IC_DLL\TGF_IC\Debug\BuildLog. htm"
    1>TGF_IC - 3 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


    Please advise.

    TIA,

    George

  2. #2
    Senior Member mecej4's Avatar
    Join Date
    Dec 2009
    Posts
    129
    I assume that FCN and FNC are not two separate functions (typo?)

    There are several aspects of usage that you may have not grasped.

    1. The first argument to BCNLS is the name of a subroutine with the specified interface, not a function.

    2. You cannot use a contained module procedure interchangeably with an external procedure.

    3. It would be best for you if you start with the example program that is provided in the IMSL manual for BCNLS. Once you have it working, you can modify it and integrated the code into your larger computational code.

  3. #3
    Junior Member
    Join Date
    Sep 2018
    Posts
    4
    Thanks a lot for your reply and advise!
    The FCN and FNC should be the same. It's a typo.

    This is one of the several BCNLS function calls that I've been used for more than 10 years.
    Prior to upgrade to IMSL 7, my IVF project with these BCNLS function calls were compiled and executed fine - even without the "external" statement in the calling function within a module.
    After upgrading to IMSL 7, the IVF compiler throws some errors during compiling the above module to a static library. Then, I added the "external" statement in the calling function and the error went away. However, when I linked the static libraries with my other Fortran DLL project, IVF then throws the linking error that reported above.
    Guess I need to find out what changes from IMSL 6 to IMSL 7.
    Any other suggestions? TIA!

  4. #4
    Senior Member mecej4's Avatar
    Join Date
    Dec 2009
    Posts
    129
    Please post the source code, at least the portions where the IMSL routine is called and where the call-back function is declared. Speculation without seeing that will probably not help. Thanks.

  5. #5
    Junior Member
    Join Date
    Sep 2018
    Posts
    4
    Thanks for your advise!
    I've moved the external subroutines outside of the module where contains the calling function. Then, IVF compiles it correctly.
    I'm still puzzled why the previous versions of IVF/IMSL allows my old code be compiled.
    Thanks again!

  6. #6
    Senior Member mecej4's Avatar
    Join Date
    Dec 2009
    Posts
    129
    Your old code probably did not use modules, or did not have the call-back function inside a module.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •