Comipling Code from VC 4.2 to VC 6.0

I am compiling code written for VC++ 4.2 in VC++ 6.0.  I am getting the LINK errors:
Linking...
nafxcw.lib(cmdtarg.obj) : error LNK2001: unresolved external symbol _IID_IDispatch
nafxcw.lib(filecore.obj) : error LNK2001: unresolved external symbol _IID_IClassFactory
nafxcw.lib(filecore.obj) : error LNK2001: unresolved external symbol _IID_IPersistFile
.\Release/program.exe : fatal error LNK1120: 3 unresolved externals
Error executing link.exe.

dpprint.exe - 4 error(s), 0 warning(s)

Any ideas on what I have to do to get this to work?  Thanks.
paulcaAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
jkrConnect With a Mentor Commented:
Simply add

#pragma comment( lib, "uuid.lib")

to your code. This import library is needed to resolve the IIDs that are missing.
0
 
paulcaAuthor Commented:
I added this line to my C++ file before all the #include and tried to compile it but I got the same errors again.
0
 
jkrCommented:
Aahh, now I think I see your problem...

Make sure that the '#include' directives look like this:

#ifndef INITGUID
      #pragma data_seg(".text")
      #define INITGUID
      #include <objbase.h>
      #include <initguid.h>
      #include <shlguid.h>
      #pragma data_seg()
#undef INITGUID
#endif

#pragma comment( lib, "uuid.lib")

0
 
paulcaAuthor Commented:
I placed this code into my C++ program but now I am getting the error:

fatal error C1020: unexpected #endif

I went down through the code to make sure that no #if's were missing their #endif.

I can't see why it is giving me this error.
0
 
jkrCommented:
Hmm, that's strange (copyied the above from a working project) - try to remove the #ifdef INITGUID/#endif pair...
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.