C++ Problem, again

jmcoreymv

Diamond Member
Oct 9, 1999
4,264
0
0
Im trying to learn to use the CString class is VC++ 6, heres the very basic code that wont compile right, and i dont understand it.

#include "stdafx.h"
#include "afx.h"
#include <iostream.h>

int main(int argc, char* argv[])
{
CString strText = &quot;This is a test text string&quot;;
CString strPart = strText.Left(10);
cout << strPart;
return 0;
}


Here is the debugger output:
Compiling...
test.cpp
Linking...
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
Debug/test.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.

Any idea on how to fix this would be appreciated, thanks.
 

EmperorNero

Golden Member
Jun 2, 2000
1,911
0
0
I haven't used vc++ for a long time but I think you'll have to add stadafx.cpp and afx.cpp to your project.
 

arcain

Senior member
Oct 9, 1999
932
0
0
You shouldn't need to add any files/headers that have 'afx' in them if you're just working on a console application. AFX is really only used with MFC projects.
 

Mark R

Diamond Member
Oct 9, 1999
8,513
16
81
Go to Project->Settings->C/C++->(Category:)Code generation->Multithreaded

Select debug or DLL as appropriate.

 

The Wildcard

Platinum Member
Oct 31, 1999
2,743
0
0
ahh c++,the horrid memories. haha i am taking a class in LISP. nybody know what language that is? It's the second oldest programming language, lol. And i just learned today how to do a link list version with LISP. I definately miss C++, when it comes to linked list.
 

Qwik

Member
Mar 27, 2000
84
0
0
LISP, oh man. Recursion _IS_ the language! Gotta love that. I'm a C++ junkie, but in no way a Visual C++ / MFC junkie. I like high-level abstraction but Microsoft's implementation is proprietary, mono-platform, and &quot;kooky&quot; :p . You could avoid Microsoft crap altogether and use the STL string class instead of Microsoft's CString class.
 

Go to Project|Settings... Under &quot;Microsoft Foundation Classes&quot; choose &quot;Use MFC in a Shared DLL&quot;

Recompile. It should work. You needed to link in the MFC garbage.