Changing to multi-threaded debug

This is a discussion on Changing to multi-threaded debug within the C++ Programming forums, part of the General Programming Boards category; Hi everyone, I have written a program which works OK when I build and run it as a multi-threaded debug ...

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    128

    Changing to multi-threaded debug

    Hi everyone,

    I have written a program which works OK when I build and run it as a multi-threaded debug DLL, but when I try and change the option in the 'code generation' menu to multi-threaded debug, I get some error messages and the project will not build. Here is my code - what am I doing wrong?

    Code:
    #include <iostream>
    #include <cmath>
    #include <conio.h>
    
    using namespace std;
    
    int main (){
    
    float a;
    float b;
    float c;
    float xone;
    float xtwo;
    int roots;
    float discriminant;
    float topline1;
    float topline2;
    float bottomline;
    char name[50];
    char ch;
    
    cout << "\nWelcome to the quadratic equation solver. Please enter your name:" << endl;
    cin.getline(name, 50);
    start:
    system("cls");
    cout << "\nHello " << name << ". Please enter the X-squared coefficient (a):" << endl;
    cin >> a;
    system("cls");
    cout << "\nEnter the X coefficient (b):" << endl;
    cin >> b;
    system("cls");
    cout << "\nEnter the final constant (c):" << endl;
    cin >> c;
    system("cls");
    
    discriminant = (pow(b, 2))-(4*a*c);
    topline1 = (b*-1) + (sqrt(discriminant));
    topline2 = (b*-1) - (sqrt(discriminant));
    bottomline = (2*a);
    xone = (topline1/bottomline);
    xtwo = (topline2/bottomline);
    
    if (discriminant < 0)
    roots = 0;
    
    else if (discriminant > 0)
    roots = 2;
    
    else if (discriminant == 0)
    roots = 1;
     
    cout << "\nYour two X values are  " << xone << "  and  " << xtwo << "  ." << endl;
    cout << "\nYour discriminant is  " << discriminant << "  meaning that your number of roots is  " << roots << "  ." << endl;
    cout << "\nPress enter to return to the start, or any other key to close.\n" << endl;
    
    ch = _getch();
    if (ch == 13)
    goto start;
    
    return 0;
    }

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,659
    You're not posting your error messages.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Feb 2010
    Posts
    128
    Sorry - I thought there may have been a straight-forward explanation because it works fine as a DLL, and I have never experienced this before...

    Anyway, this is what I get in the output form of VC++ 2008 when I try to build the previously errorless code as a multi-threaded debug:

    Code:
    ------ Build started: Project: Quadratic solver, Configuration: Debug Win32 ------
    Compiling...
    main.cpp
    Linking...
    main.obj : error LNK2005: "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl std::endl(class std::basic_ostream<char,struct std::char_traits<char> > &)" (?endl@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@1@AAV21@@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
    main.obj : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::operator<<(class std::basic_ostream<char,struct std::char_traits<char> > & (__cdecl*)(class std::basic_ostream<char,struct std::char_traits<char> > &))" (??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@P6AAAV01@AAV01@@Z@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
    main.obj : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::operator<<(int)" (??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@H@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
    main.obj : error LNK2005: "public: int __thiscall std::ios_base::flags(void)const " (?flags@ios_base@std@@QBEHXZ) already defined in msvcprtd.lib(MSVCP90D.dll)
    main.obj : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::operator<<(float)" (??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@M@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
    main.obj : error LNK2005: "public: static bool __cdecl std::char_traits<char>::eq_int_type(int const &,int const &)" (?eq_int_type@?$char_traits@D@std@@SA_NABH0@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
    main.obj : error LNK2005: "public: static int __cdecl std::char_traits<char>::eof(void)" (?eof@?$char_traits@D@std@@SAHXZ) already defined in msvcprtd.lib(MSVCP90D.dll)
    main.obj : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > & __thiscall std::basic_ostream<char,struct std::char_traits<char> >::flush(void)" (?flush@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV12@XZ) already defined in msvcprtd.lib(MSVCP90D.dll)
    main.obj : error LNK2005: "public: void __thiscall std::basic_ios<char,struct std::char_traits<char> >::setstate(int,bool)" (?setstate@?$basic_ios@DU?$char_traits@D@std@@@std@@QAEXH_N@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
    main.obj : error LNK2005: "public: class std::basic_streambuf<char,struct std::char_traits<char> > * __thiscall std::basic_ios<char,struct std::char_traits<char> >::rdbuf(void)const " (?rdbuf@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@XZ) already defined in msvcprtd.lib(MSVCP90D.dll)
    main.obj : error LNK2005: "public: class std::basic_istream<char,struct std::char_traits<char> > & __thiscall std::basic_istream<char,struct std::char_traits<char> >::operator>>(float &)" (??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAM@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
    main.obj : error LNK2005: "public: class std::basic_istream<char,struct std::char_traits<char> > & __thiscall std::basic_istream<char,struct std::char_traits<char> >::getline(char *,int)" (?getline@?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV12@PADH@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
    main.obj : error LNK2005: "public: static unsigned int __cdecl std::char_traits<char>::length(char const *)" (?length@?$char_traits@D@std@@SAIPBD@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
    main.obj : error LNK2005: "public: char __thiscall std::basic_ios<char,struct std::char_traits<char> >::fill(void)const " (?fill@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEDXZ) already defined in msvcprtd.lib(MSVCP90D.dll)
    main.obj : error LNK2005: "public: bool __thiscall std::ios_base::good(void)const " (?good@ios_base@std@@QBE_NXZ) already defined in msvcprtd.lib(MSVCP90D.dll)
    main.obj : error LNK2005: "public: int __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::sputc(char)" (?sputc@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHD@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
    main.obj : error LNK2005: "public: void __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::_Unlock(void)" (?_Unlock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ) already defined in msvcprtd.lib(MSVCP90D.dll)
    main.obj : error LNK2005: "public: void __thiscall std::basic_ostream<char,struct std::char_traits<char> >::_Osfx(void)" (?_Osfx@?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEXXZ) already defined in msvcprtd.lib(MSVCP90D.dll)
    main.obj : error LNK2005: "public: class std::basic_ostream<char,struct std::char_traits<char> > * __thiscall std::basic_ios<char,struct std::char_traits<char> >::tie(void)const " (?tie@?$basic_ios@DU?$char_traits@D@std@@@std@@QBEPAV?$basic_ostream@DU?$char_traits@D@std@@@2@XZ) already defined in msvcprtd.lib(MSVCP90D.dll)
    main.obj : error LNK2005: "public: void __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::_Lock(void)" (?_Lock@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEXXZ) already defined in msvcprtd.lib(MSVCP90D.dll)
    main.obj : error LNK2005: "public: int __thiscall std::ios_base::width(void)const " (?width@ios_base@std@@QBEHXZ) already defined in msvcprtd.lib(MSVCP90D.dll)
    main.obj : error LNK2005: "public: int __thiscall std::ios_base::width(int)" (?width@ios_base@std@@QAEHH@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
    main.obj : error LNK2005: "public: int __thiscall std::basic_streambuf<char,struct std::char_traits<char> >::sputn(char const *,int)" (?sputn@?$basic_streambuf@DU?$char_traits@D@std@@@std@@QAEHPBDH@Z) already defined in msvcprtd.lib(MSVCP90D.dll)
    Build log was saved at "file://c:\Documents and Settings\XP\My Documents\Quadratic solver\Quadratic solver\Debug\BuildLog.htm"
    Quadratic solver - 23 error(s), 0 warning(s)
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

  4. #4
    Registered User
    Join Date
    Feb 2010
    Posts
    128
    I did a clean on the project and it now works for multi-threaded debug, but I still get some error messages when I build it as a multi-threaded. Never mind.

  5. #5
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,768
    You should indent your code next time you post code.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Multi Threaded Web server question
    By webznz in forum C Programming
    Replies: 5
    Last Post: 08-07-2010, 05:20 AM
  2. Replies: 2
    Last Post: 04-12-2010, 12:57 PM
  3. Binary was not built with debug information.
    By studentffm in forum C++ Programming
    Replies: 2
    Last Post: 01-25-2010, 11:13 AM
  4. multi threaded program
    By Dash_Riprock in forum C++ Programming
    Replies: 6
    Last Post: 08-27-2006, 08:38 AM
  5. Signals in multi threaded application
    By HelpMe in forum C Programming
    Replies: 0
    Last Post: 09-12-2001, 09:15 PM

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