Serving the Quantitative Finance Community

 
User avatar
king
Topic Author
Posts: 0
Joined: March 24th, 2002, 2:56 pm

C++ problem

August 13th, 2003, 10:24 am

#include <AFX.H>void main() { CTime t; return;}upon build in VC6.0 the following error arisesCompiling...Cpp1.cppLinking...nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadexnafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadexDebug/Cpp1.exe : fatal error LNK1120: 2 unresolved externalsError executing link.exe.Cpp1.exe - 3 error(s), 0 warning(s)does anyone know how to resolve this error?
 
User avatar
monkeyA
Posts: 9
Joined: December 4th, 2002, 10:25 am

C++ problem

August 13th, 2003, 10:44 am

try including atltime.h instead ?
 
User avatar
gc
Posts: 10
Joined: September 21st, 2002, 10:08 pm

C++ problem

August 13th, 2003, 11:13 am

Hi, I guess it is a problem with single/multithreaded sets of libraries that you are using..Try going Project->Settings->C/C++->Code Generation and under "Use- run-time library": select either Debug Multithreaded or Multithreaded.Let us know if it works...gc
 
User avatar
king
Topic Author
Posts: 0
Joined: March 24th, 2002, 2:56 pm

C++ problem

August 13th, 2003, 11:23 am

Thanks for the quick responses.I don't think atltime.h is packaged with vc6.0 - but I know it is with vc7.0Debug multithreaded option resolves the error.What impact does this option have on my code?
 
User avatar
Lorn
Posts: 0
Joined: August 4th, 2003, 10:42 am

C++ problem

August 13th, 2003, 11:52 am

Hi guys! now I remember the other 2pid guys name...Man...he is 2pid.Have a nice day!!!!!thanks!:
 
User avatar
gc
Posts: 10
Joined: September 21st, 2002, 10:08 pm

C++ problem

August 13th, 2003, 11:59 am

Don't worry about atltime.h: from your error messages, the problem looked to be at linker stage, more than compilation....As far as impact on your code, not much, apart that you can compile :-)Basically, when you compile an application you can choose whether you want it to be single-threaded or if you want your code to be thread-safe (so that you can have it multithreaded or generate it in such a way that it can be used by multithreaded applications).If you are using any MFC class, you need to link your code against the multithreaded runtime libraries (not much explanation here, it's the way the libraries have been coded by Microsoft).Doing so does not means that your program will be multithreaded, only that it will use a runtime library that will do an certain number of extra processing to ensure that data is not corrupted if it is accessed at the same time by more than a thread of execution (typically, mutexes, semaphores and similar synchronization information around data).Your code will be a bit slower if it is compiled as multithreaded (because of the additional synchronization going on), but in 99% of cases, the difference is not going to be noticable. Also, if you are using MFC classes, you will already have accepted some overhead...gc
 
User avatar
gc
Posts: 10
Joined: September 21st, 2002, 10:08 pm

C++ problem

August 13th, 2003, 12:26 pm

QuoteOriginally posted by: LornHi guys! now I remember the other 2pid guys name...Man...he is 2pid.Hi Lorn.... I understood only the emoticons in your message... but I am curious.... what is that about? ;-)gc
 
User avatar
DominicConnor
Posts: 41
Joined: July 14th, 2002, 3:00 am

C++ problem

August 13th, 2003, 12:47 pm

As gc says, this isn't a header file problem, it is a library issue. If you use a wizard to create your project, it would ensure that the libraries and header files that it uses are properly matched. Because the MS Wizards connect to so much, most other objects you would normally use are also properly defined and linked.AFX was the orginal name for MFC, (aka Multiply Fucked Classes), so when he says you need to link aginst the right library, you need to know this.__endthreadex and __beginthreadex are part of the C (not C++) run time library. You have thus two paths to resolving this. You can explicitly include LIBCMT.lib, but you'll enter the dread portal of chasing down library dependancies. Occasionally you have to do this if you've been chucked a library that hasn't been built right.A small light to help you curse that darkness is the /VERBOSE option you can set in the linker tab. However, you may be able to get away with adding MFC42D.lib to your libraries. 9/10 that will work for this class of problem