LNK2022 error using IOSTREAM and FSTREAM (VS C++ 2010)
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: LNK2022 error using IOSTREAM and FSTREAM (VS C++ 2010)

Hybrid View

  1. #1
    Join Date
    Feb 2011
    Posts
    2

    Exclamation LNK2022 error using IOSTREAM and FSTREAM (VS C++ 2010)

    I'm having a major issue using the simple iostream and fstream headers in VS C++ 2010. Before adding any code that uses iosteam and fstream, I was having problems compiling after just adding their headers with the #include<iostream> and #include<fstream> statements. I managed to fix that by changing the CLR support to just standard CLR, but when I try and compile the simple code found below (which is the code for a button on a form), I get several errors stating error LNK2022: metadata operation failed : Custom attributes are not consistent, and I also get several error LNK2034 errors stating : metadata inconsistent with COFF symbol table. Does anyone have any idea of what the problem might be, or what I may need to change to get this to compile!? Thanks

    private: System::Void button1(System::Object^ sender, System::EventArgs^e) {

    ofstream issout("iss_test_out.csv", ios:: out);
    issout << "testing" << "," << "yo" << "," << "12" << endl;
    issout.close();
    }

  2. #2
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,571

    Re: LNK2022 error using IOSTREAM and FSTREAM (VS C++ 2010)

    This is a C++/CLI event handler and you are using a class from the native C++ standard library inthere. This is something you should never do unless you really, really, really have good reasons to do so. The .NET framework has the StreamWriter class to do what you intend to do here.

    BTW, I hate that LNK2022 error from the bottom of my heart. I once had a stubborn case of that one that I couldn't get rid of without doing substantial changes to my code to circumvent the problem rather than solving it. (And I didn't even use any native stuff in that code.) Other posts you can find by simply searching for the error message suggest that problems like that are not really that uncommon.

    As your question is about C++/CLI you should better have posed it in the appropriate forum. The one here is for native C++, mostly involving MFC.

    Please use code tags when posting code.

    Ah, and... Welcome to CodeGuru!
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  3. #3
    Join Date
    Feb 2011
    Posts
    2

    Re: LNK2022 error using IOSTREAM and FSTREAM (VS C++ 2010)

    Sorry, I was in a rush and panicking as this is needed for a major undergraduate senior engineering project!! I really appreciate all of your help, it worked perfectly! Thank you very much!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center