none
hiding LNK warnings

    Question


  • Basically, I want to get rid off all the LNK warning

    For ex, LNK4099, or LNK4204, or any other one. I am linking my debug lib with a third party release lib. That's why I am getting those. Is there some kind of "pragma" for the linking step to hide warnings ?

    There was the undocumented
    #pragma comment(linker, "/ignore:4099")

    but it does not work anymore on Visual Studio 7.1. I is annoying to look at hundreds of these warnings rolling down on my screen.

    Thank you.

    Wednesday, July 12, 2006 2:43 PM

Answers

  • http://msdn2.microsoft.com/en-us/library/2c8f766e.aspx

    Not sure if that works for linker warnings, but I believe it will.

    -Ben
    Wednesday, July 12, 2006 5:22 PM
  • I used to see inconsistencies in whether #pragma comment worked to disable linker warnings, so perhaps that bug is still there.  #pragma warning will not work, since it's for compile warnings only, as you observed.

    Brian

     

    Wednesday, July 12, 2006 9:41 PM
    Moderator

All replies

  • http://msdn2.microsoft.com/en-us/library/2c8f766e.aspx

    Not sure if that works for linker warnings, but I believe it will.

    -Ben
    Wednesday, July 12, 2006 5:22 PM
  • What would be the exact wording then ?? since
    #pragma warning( disable : 4204)
    would be for a compilation warning C4204
    Wednesday, July 12, 2006 9:00 PM
  • I used to see inconsistencies in whether #pragma comment worked to disable linker warnings, so perhaps that bug is still there.  #pragma warning will not work, since it's for compile warnings only, as you observed.

    Brian

     

    Wednesday, July 12, 2006 9:41 PM
    Moderator
  • So
    #pragma comment(linker, "/ignore:4099")
    would be the correct syntax. Actually, I tried /
    ignore:4099 in the additional link options, but it's not taken into account either    :o(
    Thursday, July 13, 2006 1:36 PM
  • Well, good news and bad news.  The good news is that you have the correct syntax.  The bad news is that is no longer supported as of VS 2003. Sorry. :(

    http://www.thescripts.com/forum/thread264543.html

     

    Thursday, July 13, 2006 1:55 PM
    Moderator
  • What about using additional link options ??
    Monday, July 17, 2006 10:19 AM
  • You can add /ignore:4099 directly to the linker settings under project properties->linker->command line.  The only real advantage of #pragma comment (when applicable) is that you can express linker settings at compile time.
    Monday, July 17, 2006 12:03 PM
    Moderator
  • If I add /ignore:4099 to the "additional options" of project properties->linker->command line,
    I still get the warnings LNK4099

    I am using:

    Microsoft Visual C++ .NET  
    MS Development Environment 2003 Version 7.1.3038
    MS .Net Framework 1.1 Version 1.1.4322 SP1

    Sorry for the trouble. Thanks
    Tuesday, July 18, 2006 8:45 AM
  • I don't have 2003 installed anymore, and I can't reproduce the problem under 2005 (i.e. /ignore:4099 works).  Try this reproduction on your machine:

    Get LNK4099 to manifest:
    1. Create new Win32 console project.
    2. Project Properties->C/C++->Code Generation->Runtime Library = Multi-threaded (/MT).
    3. Tools->Command Prompt
    4. Assuming you're here: C:\Program Files\Microsoft Visual Studio 8\vc\bin, do cd ..\lib 
    5. move libcmt.pdb libcmt.pd_
    6. Back in Visual Studio, do a project rebuild.

    LNK4099 should occur multiple times.

    7. Add /ignore:4099 to linker settings

    LNK4099 should go away.  If it doesn't it could be a VS2003 bug, and it's safe to say that this wouldn't meet the bar for a future SP fix.  If it does go away with VS2003, there's something else going on here.  (Try doing these repro steps on your own project, remembering to undo step 2.) 

    Remember to undo the result of step 5 by renaming in the opposite direction!

    Brian



     

    Tuesday, July 18, 2006 3:20 PM
    Moderator
  • I did

    1. Create new Win32 console project. (Debug project)
    2. Project Properties->C/C++->Code Generation->Runtime Library = Multi-threaded (/MTd).

    I linked with my release third party library, and this time I get:

    LNK4204 occuring 293 times

    I added
    Add /ignore:4204 to linker settings. I rebuilt. I am still getting my 293 warnings.

    I f I understand correctly, your step (
    5. move libcmt.pdb libcmt.pd_), is just to have more warnings showing up, isn't it ? It is not a necessary step per say ?
    Tuesday, July 18, 2006 8:27 PM
  • waow, the HTML editor is acting funny
    Tuesday, July 18, 2006 8:28 PM
  • The purpose of my reproduction (which you didn't follow exactly since you used /MTd instead of /MT) is to determine if the ability to ignore warning LNK4099 can be controlled under VS2003 in general, and with your project in particular.  LNK4204 is a different matter altogether.
    Tuesday, July 18, 2006 10:31 PM
    Moderator
  • OK, I did exactly what you said, and adding /ignore:4099 to the additional options of the linker command line does not change anything. I still get:

    LIBCMT.lib(_ctype.obj) : warning LNK4099: PDB 'libcmt.pdb' was not found with 'c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\lib\LIBCMT.lib' or at 'c:\workspace\ltuCore\ltuCoreWinLib\vc71\ttt2\Debug\libcmt.pdb'; linking object as if no debug info


    Thursday, July 20, 2006 9:03 AM
  • I would recommend never to ignore LNK4204!
    Thursday, July 20, 2006 9:24 AM
    Moderator
  • If the LNK4099 still shows up under my original repro steps using VC7.1, then it might be a bug.  If it goes away under my original repro steps, then there's something else going on... other libraries causing the /ignore to be ignored?  I'm at a loss here. Sorry!

    Have you tried troubleshooting LNK4024 by normal means, using the MSDN documentation for that warning?

     

    Thursday, July 20, 2006 1:44 PM
    Moderator

  • the LNK4099 still shows up under your original repro steps using VC7.1.

    It seems my last option (besides switching to Studio 8.0) is to try to correct all the LNK warnings I have. I know why I get these warnings, I am linking with different third party liraries. It is not affecting the execution of my process, that's why I would have prefer to just ignore it, and not spend time fixing it. Thank you for your help anyway, I have an exact diagnostic of the problem now...

    Friday, July 21, 2006 1:08 PM
  • I am having the same issue and the /ignore:4099 also does not resolve the issue in VS 2005. As a matter of fact, the documentation for VS 2005 does not list the /ignore as a linker option.

    Tuesday, December 05, 2006 12:01 PM
  • I've got VS.NET 2005 and the /ignore:4099 does not work.  I believe the reason is that LNK4099 is simply an unignorable linker warning...  http://members.ozemail.com.au/~geoffch/samples/programming/msvc/link/link/options/ignore.htm

    Thursday, December 07, 2006 11:14 PM
  • The lnk4099 errors you get for 3rd party debug builds that lack .pdb files are quite annoying. And as most have pointed out, there's no way to filter those redundant link warnings. This has a more serious result in that most developers completely ignore every warning message that the linker produce even those they shouldn't. Part of human nature I suppose.

    To solve this problem for our developers I just wrote a short c++ linkfilter program and pipe all stdout output from link through this program. Oh the joy and ease of command line based builds.
    I don't really know what you can do with the linker command line options in the project property pages or if the IDE will allow you to redirect output from the build tools but this is a fairly easy way to reduce the linker warning spam.

    I seem to remember a stl error message filter tool from a few years back that would work with IDE compilations so this should be possible. But I've never built anything more complicated then hello world level applications inside the IDE so I don't know.
    Friday, December 08, 2006 8:13 AM