Thread: Compiling error (need help)

  1. #1
    Registered User
    Join Date
    Apr 2003

    Question Compiling error (need help)

    I am using Microsoft VC++ 6.0. When I try using 'afx.h' and 'iostream.h' at the same time. Nothing goes wrong unless I use either 'cin' or 'cout'. When I compile I get the following:

    nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
    nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
    Debug/Text1.exe : fatal error LNK1120: 2 unresolved externals
    Error executing link.exe.
    Text1.exe - 3 error(s), 0 warning(s)
    Here is the sample piece of code that generated the output above, although anything I have tried that has all of these statements in it also genorates the same error.

    #include <afx.h>
    #include <iostream.h>
    int main()
    	CString the_text = "Hello World!";
    	cout << the_text;
    	return 0;
    I would like some help on this, and any information would be usefull.


  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Ontario, Canada
    What does afx.h do? If you're just using it for the CString, why not use STL's <string> and the string class? Also, you should always use <iostream>, and the std namespace, instead of <iostream.h>.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    Registered User
    Join Date
    Jan 2003
    cout << the_text << endl;
    endl flushes the buffer.

  4. #4
    Registered User
    Join Date
    Nov 2002
    Yeah, I would just use the STL string. But if you really want to use CString, then I think the problem is that you aren't linking some needed libraries for the afx.h stuff. Are you using MSVC, and if so, did you specify that you want to create an MFC project? If you didn't, then you'll probably have to add the needed libraries(I don't really know what they are) to the project manually.

    Come to think of it, should you really be including the afx and iostream(notice how there's no .h on iostream, heh) headers in the same project?
    Last edited by PorkyChop; 04-14-2003 at 08:34 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie Compiling Problem
    By Deronius in forum C++ Programming
    Replies: 3
    Last Post: 06-15-2008, 11:23 AM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. Problem Compiling
    By Flakster in forum C++ Programming
    Replies: 4
    Last Post: 06-13-2006, 01:09 AM
  4. compiling and executing issue with lcc win32
    By GanglyLamb in forum C Programming
    Replies: 10
    Last Post: 12-22-2004, 02:24 PM
  5. Compiling syntax
    By Jez_Master in forum C++ Programming
    Replies: 3
    Last Post: 04-01-2002, 09:46 PM