locked
Linking error when linking to a .lib file, which is created from other .lib files RRS feed

  • Question

  • Hi

    I have a problem getting the linking to work on a project I'm doing. Basically, I am building a library which is using some functions from the intel MKL library. So the structure is this

    myWinProgram links to -> myMathLib links to -> Intel MKL

    The myMathLib is building just fine, but calls different routines in the Intel MKL library, e.g. vmlSetMode( VML_HA );

    As I understand, all the code necessary should be contained in my library, as this function is only used internally by the class I have implemented. But when I use myMathLib to link in myWinProgram, I get :

    Code Block

    myMathLib error LNK2019: unresolved external symbol _vmlSetMode@4 referenced in function "public: __thiscall CFBFTCore::CFBFTCore(void)" (??0CFBFTCore@@QAE@XZ)



    Wednesday, October 17, 2007 5:18 PM

Answers

  • Hi Henrik,

     

    I think you forget to put Intel MKL library to where myWinProgram reside in, though you've wrapped it with myMathLib, but actuall implementation for functions like vmlSetMode(VML_HA) is in original MKL library. A lib file usually refer to either a import library of a DLL file or a statically linked library, the confusion here (if any) is whether these lib files you mentioned a static library or not.

    Monday, October 22, 2007 1:40 PM

All replies

  • I think that the lib code is not inserted until a binary pe file is built. ie.until the linker gets to do its work.

    A lib file is not linked. It is just a bunch of object code put together in 1 big file that can be linked at a later time.

    Your winprogram needs to link to both libraries.

     

    Btw, That intel lib you are linking to, is it a static lib, or is it the import lib for a dll?
    Thursday, October 18, 2007 8:19 AM
  • Check the calling convention first of all. The symbol above is stdcall. So check if the function in the library has been compiled with stdcall or another and then correct it if necessary.

    Thursday, October 18, 2007 12:21 PM
  • Hmm, ok.

    Is there any other way of making sure that the library I have implementet will work the same way in both instances? Maybe applying some flags to the compiler/linker or making another program altogether?

    The Intel package I am linking to have different .lib files, one called mkl_c.lib and one called mkl_c_dll.lib, where I am using the first one. Assuming that it is the library and the second is the import library for the dll.

    Thursday, October 18, 2007 2:02 PM
  • Hi, sry for making 2 posts btw.

    I can change a flag to change the calling convention to cdecl and the the linking error disappears. But then I get a run-time error which causes my program to crash whenever the program reaches those functions. So it seems that something is still not being linked/compiled correctly.

    Thanks

    Henrik
    Thursday, October 18, 2007 2:05 PM
  • Hi Henrik,

     

    I think you forget to put Intel MKL library to where myWinProgram reside in, though you've wrapped it with myMathLib, but actuall implementation for functions like vmlSetMode(VML_HA) is in original MKL library. A lib file usually refer to either a import library of a DLL file or a statically linked library, the confusion here (if any) is whether these lib files you mentioned a static library or not.

    Monday, October 22, 2007 1:40 PM
  • Hi, sry for making 2 posts btw.

    Threads merged, since both threads already contain useful replies.

    Monday, October 22, 2007 1:58 PM