LNK2019 when linking against a static library.

This is a discussion on LNK2019 when linking against a static library. within the C++ Programming forums, part of the General Programming Boards category; Hi, dunno if I should post this in C++ or Windows Programming. But here goes. I've got a problem here ...

  1. #1
    In the Land of Diddly-Doo g4j31a5's Avatar
    Join Date
    Jul 2006
    Posts
    476

    LNK2019 when linking against a static library.

    Hi, dunno if I should post this in C++ or Windows Programming. But here goes. I've got a problem here that bugs me. I'm trying to link a static library to my dll / dynamic library (which in turn will be linked to my application). But I've got all these LNK2019 errors all over the place. This usually happens when I didn't include a .lib file or the .lib file doesn't have the exported symbols, right? Well, the problem is I did link the correct .lib file and after I read MSDN, I tried using dumpbin with /EXPORTS and /SYMBOLS and guess what, the symbols are there. I'll show you one of the errors:

    Code:
    1>bullet_pal.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall btCollisionShape::getBoundingSphere(class btVector3 &,float &)const " (?getBoundingSphere@btCollisionShape@@UBEXAAVbtVector3@@AAM@Z)
    And this is from the dumpbin:

    Code:
    272 00000000 UNDEF  notype ()    External     | ?getBoundingSphere@btCollisionShape@@UBEXAAVbtVector3@@AAN@Z (public: virtual void __thiscall btCollisionShape::getBoundingSphere(class btVector3 &,double &)const )
    So, maybe there is another cause for this error. But I can't figure out what it is. Can you guys help me please? I'm so lost right now. Thanks a lot in advance.

    EDIT: The title is slightly wrong. Not just LNK2019 but LNK2001 and LNK2019. My Bad... :P
    Last edited by g4j31a5; 06-28-2010 at 03:46 AM.
    ERROR: Brain not found. Please insert a new brain!

    “Do nothing which is of no use.” - Miyamoto Musashi.

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,029
    Well, one glaring problem is that the exported function takes a double, while the function you're calling takes a float?
    Otherwise it's pretty hard to say anything, except that you must link against the proper library.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,598
    Is any other module or is the main module also attempting to link to the lib that the DLL is linking to? I would guess no since that would cause a duplicate symbol error but I have seen on the odd occasion where this error is the result of double linking and the compiler spitting out the wrong error code.

    My guess is though that you are linking incorrectly or have a mismatch between the header version and the actual library source.

  4. #4
    In the Land of Diddly-Doo g4j31a5's Avatar
    Join Date
    Jul 2006
    Posts
    476
    @Bubba & Elysia: thanks guys. it was my own stupid mistake afterall. the library has this macro:

    Code:
    # if defined BT_DOUBLE_PRECISION
    typedef double btScalar;
    #else
    typedef float btScalar;
    #endif
    And the funny thing is, in the library I used the prerpocessor BT_DOUBLE_PRECISION but didn't in the one that it is linked to. My bad. :P

    Thanks a lot for the pointers guys. Especially Elysia for telling me the double / float difference. I somehow skipped reading that part.
    ERROR: Brain not found. Please insert a new brain!

    “Do nothing which is of no use.” - Miyamoto Musashi.

  5. #5
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,598
    Glad you got it resolved. Linker errors can be nasty beasts at times.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. [C#] Intercept SysListView32 item added
    By Devils Child in forum Windows Programming
    Replies: 9
    Last Post: 03-26-2010, 08:29 AM
  2. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  3. Linking error LNK2019: unresolved external symbol
    By tzakieta in forum C++ Programming
    Replies: 3
    Last Post: 09-19-2008, 08:31 AM
  4. LNK2019 with .net 2003 and standard c++ library
    By Bigbio2002 in forum C++ Programming
    Replies: 7
    Last Post: 10-09-2005, 03:16 PM
  5. Linker errors with simple static library
    By Dang in forum Windows Programming
    Replies: 5
    Last Post: 09-08-2001, 10:38 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21