'Random' linker warnings VC++ 2005 Express

This is a discussion on 'Random' linker warnings VC++ 2005 Express within the C++ Programming forums, part of the General Programming Boards category; I'm having a little problem with the VC++ 2005 Express edition IDE. When I try to build a project that ...

  1. #1
    Registered User
    Join Date
    Dec 2006
    Posts
    69

    'Random' linker warnings VC++ 2005 Express

    I'm having a little problem with the VC++ 2005 Express edition IDE. When I try to build a project that uses the RakNet network library I get a bunch of warnings. I don't know what causes them and the strange thing is that they seem to apear and disapear randomly. When I add a line of code they may disapear and come back when I add another one. The exact same code sometimes gives warnings and sometimes doesn't.

    LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library

    RakNetLibStatic.lib(BitStream.obj) : warning LNK4099: PDB 'raknetlibstatic.pdb' was not found with 'C:\GameDesign\RakNet\Lib\RakNetLibStatic.lib' or at 'c:\gamedesign\adminserver\debug\raknetlibstatic.p db'; linking object as if no debug info
    The first warning (4098) apears only once, the second one (4099) is shown 37 times for different .obj files.

  2. #2
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    1. are the functions in that library C or C++? it makes a difference.
    2. do you have UNICODE turned on? It is turned on by default.
    3. If the functions are C and your program is probably C++, does the header file that contains function prototypes contain something like this
    Code:
    #ifdef __cplusplus
    extern "C" {
    #endif
    < function/class declarations here
    #ifdef __cplusplus
    }
    #endif

  3. #3
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,383
    Do as it suggests and add /NODEFAULTLIB:LIBCMT to your linker options. See what happens.

    However I suspect you are adding /DEAFULTLIB:LIBCMT to your linker options. If that is the case try and remove it, don't add /NODEFAULTLIB, but link with RakNetLibStatic.lib as a dependency. http://msdn2.microsoft.com/en-us/lib...22(VS.80).aspx
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  4. #4
    Registered User
    Join Date
    Dec 2006
    Posts
    69
    Thanks both,

    I have been able to solve the first warning ("LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library"). The problem was that I was mixing release and debug libraries in the same project. Linking with RakNetLibStaticDebug.lib fixed that problem.

    For the other errors:
    1. are the functions in that library C or C++? it makes a difference.
    They are in C++.

    2. do you have UNICODE turned on? It is turned on by default.
    Yes it was turned on. Setting it to 'not set' or 'multibyte' did not fix the problem. What is UNICODE and how could it cause these warnings?

    3. If the functions are C and your program is probably C++, does the header file that contains function prototypes contain something like this
    Code:
    #ifdef __cplusplus
    extern "C" {
    #endif
    < function/class declarations here
    #ifdef __cplusplus
    }
    #endif
    The functions are in C++ and (logically) I have not been able to find any such code.

    Do as it suggests and add /NODEFAULTLIB:LIBCMT to your linker options. See what happens.

    However I suspect you are adding /DEAFULTLIB:LIBCMT to your linker options. If that is the case try and remove it, don't add /NODEFAULTLIB, but link with RakNetLibStatic.lib as a dependency. http://msdn2.microsoft.com/en-us/lib...22(VS.80).aspx
    Thanks, this problem is fixed. But not by ignoring LIBCMT(that causes unresolved external symbol errors) , but by using the debug build of the RakNet lib. I was already linking RakNetLibStatic.lib as a dependency (I think).

    BTW, do you have any idea what would cause the 'randomness'? It still only happens every few builds..

  5. #5
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,424
    I think you have incremental build on... in this case some warnings can dissapear on the next build just because some portion of the code is not rebuild... you can use clean and rebuild all to see all the warnings if you suppose that this can be the case of "missing" warning
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  6. #6
    Registered User
    Join Date
    Dec 2006
    Posts
    69
    Ok that clears up the apparent randomness. If I use clean and rebuild, I get the warnings every time.. I have much to learn..

    I'm still stuck with the "RakNetLibStatic.lib(BitStream.obj) : warning LNK4099: PDB 'raknetlibstatic.pdb' was not found with 'C:\GameDesign\RakNet\Lib\RakNetLibStatic.lib' or at 'c:\gamedesign\adminserver\debug\raknetlibstatic.p db'; linking object as if no debug info" warnings. Any help is apreciated.
    Last edited by C+/-; 01-12-2007 at 12:33 PM.

  7. #7
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,383
    > Thanks, this problem is fixed. But not by ignoring LIBCMT(that causes unresolved external symbol errors) , but by using the debug build of the RakNet lib. I was already linking RakNetLibStatic.lib as a dependency (I think).

    That is fine... but what then when the time comes to use the release build? Will the problem reemerge? Chances are, yes.

    > BTW, do you have any idea what would cause the 'randomness'? It still only happens every few builds..

    I don't know the library, sorry. But randomness is something I'm not familiar in the way compilers and linkers operate. So it may only seem random to you... but something else may be affecting the linking operation. You will probably experience much less apparent randomness if you click 'rebuild', instead of 'build', for instance.

    Anyways, I don't think the problem is solved at all. First, I really doubt you need /DEFAULTLIB. I cannot seem to remember how exactly you get into the linker options in VC++... But inside there you will have an option called something like "external dependencies". That's where you should put the lib files... I suggest you add it (or them) with a full path specification. Then remove the /DEFAULTLIB option. And try it that way. If you get similar or different errors, you may need to use a different lib file (check the library documentation) or add others.

    Second, I did a quick skimming around the website and I noticed the library is multithreaded. So I also suggest you change the compiler options on something called "runtime library" to multi-threaded library or multi-threaded code generation... whatever you see there.

    I'm sorry but I don't use VC++ for some time now, so I can't remember the exact names. But the important thing to keep in mind is that /LIBDEFAULT is an option rarely needed and all it does really is bypass the usual reference searching order. I don't see a reason why RakNet would need to do this.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  8. #8
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,424
    Quote Originally Posted by C+/-
    Ok that clears up the randomness. If I use clean and rebuild, I get the warnings every time.. I have much to learn..

    I'm still stuck with the "RakNetLibStatic.lib(BitStream.obj) : warning LNK4099: PDB 'raknetlibstatic.pdb' was not found with 'C:\GameDesign\RakNet\Lib\RakNetLibStatic.lib' or at 'c:\gamedesign\adminserver\debug\raknetlibstatic.p db'; linking object as if no debug info" warnings. Any help is apreciated.
    pdb file stores the debug info. linker searches this file when using the debug build.
    I know two ways of solwing the problem (actually 3 - the 3rd just ignore the warning - you will not be able to debug into the library code, but will have no problem with debugging your own code)
    1. provide the pdb file that was created during compiling the debug version of the library
    2. recompile the library with different options: if I remember correctly
    Project options/ C++/General/Debug info

    if set to C7 compatible the debug info is stored inside the lib-file and pdb-file is not created
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  9. #9
    Registered User
    Join Date
    Dec 2006
    Posts
    69
    Anyways, I don't think the problem is solved at all. First, I really doubt you need /DEFAULTLIB. I cannot seem to remember how exactly you get into the linker options in VC++... But inside there you will have an option called something like "external dependencies". That's where you should put the lib files... I suggest you add it (or them) with a full path specification. Then remove the /DEFAULTLIB option. And try it that way. If you get similar or different errors, you may need to use a different lib file (check the library documentation) or add others.
    When I look at the generated command line, there is no /DEFAULTLIB, so I conclude I am not using this option. I have linked the library by specifying it under "linker/Input/Additional Dependencies". I can now build both release and debug builds without the first warning, so I do think this problem is solved. The problem was that I linked the wrong library (the release lib of RakNet) when compiling the debug build which uses a debug version of the (multithreaded) runtime library.

    Second, I did a quick skimming around the website and I noticed the library is multithreaded. So I also suggest you change the compiler options on something called "runtime library" to multi-threaded library or multi-threaded code generation... whatever you see there.
    Yes, I had already done this (it was in the instructions, didn't figure that out myself ). Could you tell me, though: what exactly does the runtime library do? Does it provide functionality for threaded programming?

    1. provide the pdb file that was created during compiling the debug version of the library
    How should I 'provide' the pdb file and to what should I provide it? (the linker?) I'm sorry but I don't really understand this, I'm very new to C++ programming and compilers in general (I've only used scripting languages so far..)

    2. recompile the library with different options: if I remember correctly
    Project options/ C++/General/Debug info

    if set to C7 compatible the debug info is stored inside the lib-file and pdb-file is not created
    It is indeed located at "Project options/ C++/General/Debug info". So should I set it to C7 or not? I've tried all options, but none seem to solve the warnings.

  10. #10
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,424
    Could you tell me, though: what exactly does the runtime library do? Does it provide functionality for threaded programming?
    It stores all the library functions you can call in your code like printf, exp or strlen

    the multithreading and singlethreading libraries differ not only in the existense of the functions like beginthread, but also in the internal structure of each function whose original code can be not thread safe. For example each standard function that sets the errno value should be rewritten for the multithreaded environment.

    How should I 'provide' the pdb file and to what should I provide it?
    if you have it or could download from the server where you got the debug version of the library - just put it into the direcrtory where the debug version of the lib is located.

    It is indeed located at "Project options/ C++/General/Debug info". So should I set it to C7 or not?
    I'm not talking about your project, I'm talking about project that is used to compile the library itself.
    If you have the source code of the library - you can do it.
    If you don't have the source code - this path is unavailable for you.
    Last edited by vart; 01-12-2007 at 01:16 PM.
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  11. #11
    Registered User
    Join Date
    Dec 2006
    Posts
    69
    I've gotten it to work, thanks!

    I also understand it now.. The pdb file for the library should be created when the library is built, not when my program is built. I have the source code so I just built it and the pdb file was created. I also found a comment from the author saying he didn't include the pdb files in the distro because of filesize.

    Thanks again

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Task list in VC 2005
    By VirtualAce in forum Tech Board
    Replies: 0
    Last Post: 05-13-2008, 08:59 PM
  2. Linker errors in VC++ 2005
    By C+/- in forum C++ Programming
    Replies: 0
    Last Post: 05-18-2007, 07:42 AM
  3. Linker errors with 2005 Express
    By thetinman in forum Windows Programming
    Replies: 4
    Last Post: 12-30-2006, 08:04 AM
  4. Help: Microsoft Visual Basic 2005 Express Editon
    By karlawarla in forum Windows Programming
    Replies: 5
    Last Post: 11-22-2006, 01:46 PM
  5. Another brain block... Random Numbers
    By DanFraser in forum C# Programming
    Replies: 2
    Last Post: 01-23-2005, 04:51 PM

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