Monday, April 25, 2011

Visual C++: How to disable specific linker warnings?

I'm using a library from CGAL which during the linking stage of my code compilation produces a lot of linking warnings of this form:

warning LNK4099: PDB 'vc80.pdb' was not found with 'gmp-vc80-mt-sgd.lib' or at 'vc80.pdb'; linking object as if no debug info

How do I turn off this specific linker warning under Visual C++/Studio 2008?

Note that I do not have any control on the external (CGAL) library which I am using. I cannot/donot want to get into recompiling the external library. Hence, the need to fix the messages at my end.

From stackoverflow
  • The PDB file is typically used to store debug information. This warning is caused probably because the file vc80.pdb is not found when linking the target object file. Read the MSDN entry on LNK4099 here.

    Alternatively, you can turn off debug information generation from the Project Properties > Linker > Debugging > Generate Debug Info field.

    Ashwin : Turning off debug info solves the linker warnings, but then breakpoints do not work without debug information. That is not very useful for me.
    dirkgently : Turning off warnings is never the right thing to do. Fix them. You need to find the pdb and see to it that it gets copied to the proper location.
    Ashwin : Sigh, that is true! Sadly in this case, I cannot find that pdb.
    Joe Gauterin : @dirk: vc80.pdb is just the default pdb name for vc8. This warning simply means that there is no debug information available for the CGAL library. It is safe to ignore.
  • EDIT: don't use vc80 / Visual Studio 2005, but Visual Studio 2008 / vc90 versions of the CGAL library (maybe from here).

    Linker Tools Warning LNK4099:

    You could also compile with /Z7, so the pdb doesn't need to be used, or remove the /DEBUG linker option if you do not have .pdb files for the objects you are linking.

    Ashwin : Thanks. Compiling with /Z7 still asks for the .pdb file of the CGAL library. /DEBUG solves the linker warnings, but then breakpoints do not work without debug information.
  • Add the following as a additional linker option:

     /ignore:4099
    

    This is in Properties->Linker->Command Line

    Ashwin : Strange, but it does not work! I'm still seeing the errors!
    Nick Desjardins : I don't think /ignore exists. The errors are still listed, and /ignore is not documented in MSDN. I'm trying to disable 4075 for "warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification."
  • I suspect /ignore is a VC6 link.exe option. for VS2005 and VS2008's linker there's no documented /ignore option available, but the linker looks just ignore the "/ignore:XXX" option, no error and no effect.

    Gyuri : In fact, it's enouraged not to ignore linker warnings, so the ignore flag was disabled after VC6: http://bytes.com/topic/net/answers/264543-linker-ignore-option-no-longer-supported
  • According to Geoff Chappell the 4099 warning is too important to ignore, and cannot even be ignored by using /wx (which works for other warnings)

    (/wx makes warnings into errors)

  • For VS2005 /ignore:4099 works fine.

  • /ignore:4099 works fine here with VS2008.

0 comments:

Post a Comment