none
What cause compiling error: LNK 1257 : code generation failed?

    Question

  • Hi Everyone,

    I am wondering what cases the error, 'fatal error LNK 1257: code generation failed"? I created a C++ static library using VS2008 and also prepared a main routine to test it. It seems works just fine. So I copied the code to another directory so that I can add other C++ libraries and start building my application based on this code. Strangely, this time this error occured (while I am compiling the same code, not even adding anything yet), I follw a suggestion I found on this Forum: logoff and re-start the system. It did not n=help. Any explanations? suggestions? Thanks for your help.

    Tom Lin 
    Wednesday, November 11, 2009 9:32 PM

All replies

  • Hi Tom,

    Have you installed the Visual Studio SP1? if not you could download it here:
    http://www.microsoft.com/downloads/details.aspx?FamilyID=27673c47-b3b5-4c67-bd99-84e525b5ce61&DisplayLang=en

    Sincerely,
    Wesley
    Please mark the replies as answers if they help and unmark them if they provide no help. Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Friday, November 13, 2009 5:58 AM
  • Hello,

    How are you? Is your problem resolved? May I know whether the above suggestions helped you?

    Thanks,
    Wesley


    Please mark the replies as answers if they help and unmark them if they provide no help. Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Wednesday, November 18, 2009 3:48 AM
  • Thanks Wesley for your suggestion. Sorry for the late reply, I just come back from Chicago yesterday. I can't remember that I download it or not and will certainly do it today. I will let you know. Have a great day.

    Tom Lin

    Wednesday, November 18, 2009 1:54 PM
  • Hi Wesley,

    I just tried it after downloading VS SP1. The problem persists. After the download, I re-started my computer. Do I need to do 'installation'? I was not prompted to  do so. Thanks.

    Tom Lin
    Wednesday, November 18, 2009 2:43 PM
  • I've seen this error when one or more of my static libraries were compiled with an older version of the compiler.  I'm not sure why the version is so dependent, but I've been able to fix it by recompiling all of the libraries I'm using.  My guess, in this case, is it's one of the other libraries you're trying to use since your test program works with just the single library.

    There is also a bug posted in connect on it:

    https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=101576

    I think it may have something to do with how the code is optimized, but I don't know why that would make any difference either.  You could try taking out one lib at a time until it works so you can identify the culprit.

    Tom

    Wednesday, November 18, 2009 11:38 PM
  • I also faced same issue , after installing VS 2005 SP2 , issue resolved. 
    Wednesday, March 07, 2012 9:41 AM