none
ni488.2 link error with static run-time lib (/MTd option)

    Question

  • Bulding project linking to National Instruments IEEE-488 Driver v2.7, ni488.h / ni4882.obj. Guessing this is more of a generic issue, not necessarily one with NI.
    Using MSVS2008, project builds successfully when Code Generation Run Time Libarary option "Multi-Thread Debug DLL" /MDd is set. When "Multi-Thread Debug" option /MTd is set, build fails with linker errors:

    1>ni4882.obj : warning LNK4217: locally defined symbol _fclose imported in function _LoadFunction@4

    1>ni4882.obj : error LNK2019: unresolved external symbol __imp__fread referenced in function _LoadFunction@4

    1>ni4882.obj : error LNK2019: unresolved external symbol __imp__fopen referenced in function _LoadFunction@4

    1>ni4882.obj : error LNK2019: unresolved external symbol __imp__rand referenced in function _LoadFunction@4

    1>ni4882.obj : error LNK2019: unresolved external symbol __imp__srand referenced in function _LoadFunction@4

    1>ni4882.obj : error LNK2019: unresolved external symbol __imp__time referenced in function _LoadFunction@4

    In successful build, these functions are in MSVCR90D.dll

    Log section from successful build for same functions;

    1> Found __imp__fclose

    1> Referenced in ni4882.obj

    1> Loaded MSVCRTD.lib(MSVCR90D.dll)

    1> Found __imp__fread

    1> Referenced in ni4882.obj

    1> Loaded MSVCRTD.lib(MSVCR90D.dll)

    1> Found __imp__fopen

    1> Referenced in ni4882.obj

    1> Loaded MSVCRTD.lib(MSVCR90D.dll)

    1> Found __imp__rand

    1> Referenced in ni4882.obj

    1> Loaded MSVCRTD.lib(MSVCR90D.dll)

    1> Found __imp__srand

    1> Referenced in ni4882.obj

    1> Loaded MSVCRTD.lib(MSVCR90D.dll)

    1> Found __imp__time

    1> Referenced in ni4882.obj

    1> Loaded MSVCRTD.lib(time.obj)

    Per Run Time Library documentation made the assumption these should have been in LIBCMTD.LIB, however linking fails.
    Project requires static linking, so /MDd is not possible.

    Thursday, December 03, 2009 1:13 AM

Answers

  • Hi Ewlars,

    Have you tried to add MSVCR90D.dll to your project ? As far as I know, with /MDd switch, it causes the compiler to place the library name MSVCRTD.lib into the .obj file. But with /MTd switch, This option just causes the compiler to place the library name LIBCMTD.lib into the .obj file so that the linker will use LIBCMTD.lib to resolve external symbols. For details, please refer to this MSDN article:

    http://msdn.microsoft.com/en-us/library/2kzt1wy3(VS.71).aspx


    Best Regards,
    Nancy
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Nancy Shao Thursday, December 10, 2009 7:50 AM
    Friday, December 04, 2009 10:20 AM

All replies

  • Hi Ewlars,

    Have you tried to add MSVCR90D.dll to your project ? As far as I know, with /MDd switch, it causes the compiler to place the library name MSVCRTD.lib into the .obj file. But with /MTd switch, This option just causes the compiler to place the library name LIBCMTD.lib into the .obj file so that the linker will use LIBCMTD.lib to resolve external symbols. For details, please refer to this MSDN article:

    http://msdn.microsoft.com/en-us/library/2kzt1wy3(VS.71).aspx


    Best Regards,
    Nancy
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Nancy Shao Thursday, December 10, 2009 7:50 AM
    Friday, December 04, 2009 10:20 AM
  • Hi Ewlars,

    How are you? Have you solved this issue? If not, please update this thread and our community members will help you to solve this issue.

    Best Regards,
    Nancy
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Wednesday, December 09, 2009 7:26 AM
  • I had the same issue.  Your suggestion worked.  I just changed the project settings from "MFC in a static library" to "MFC in a shared DLL" and it compiled fine.
    Wednesday, February 10, 2010 11:32 PM