如CTypedPtrList,CMutex,CSingleLock拜谢,我很急

解决方案 »

  1.   

    把你要用的类的头文件加上:#include <afxmt.h>
    #include <afxtempl.h>
      

  2.   

    我还要说明一下,我的VC下面选定了Ignore All Libraries这个选项
      

  3.   

    加上类的头文件,需要那个在MSDN里查一下就可以知道是那个文件了。
      

  4.   

    已经加上该类的头文件,主要是我选择了Ignore All Libraries,没法找到响应的库。另外还出现这样的一个错误:
    H:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afxv_w32.h(14) : fatal error C1189: #error :  WINDOWS.H already included.  MFC apps must not #include <windows.h>
      

  5.   

    H:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afxv_w32.h(14) : 
    fatal error C1189: #error :  WINDOWS.H already included.  MFC apps must not #include <windows.h>上面说明Win32 App不能调用MFC。
    如果确实要用MFC的函数,看来只能写DLL调用。
      

  6.   

    我想试试:
    (1)把前面的MFC的类库中CTypedPtrList修改为标准C++库的对应的类,但不知道对应的类是什么。此外不知道此法可行否?
    (2)不知道除了MFC,同步线程应该使用什么类或者API函数
      

  7.   

    进入 Project-->Setting--> C/C++ Page --> Preprocessor definitions 加入 _AFXDLL 并
    修改 Project Options,将 /MT 或者 /ML 改为 /MD#include <afx.h>
    #include <afxwin.h>         // MFC core and standard componentsextern "C" int WINAPI
    _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
           LPTSTR lpCmdLine, int nCmdShow)
    {
           int nRetCode = 0;       if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
           {
                  TRACE0("Fatal Error: MFC initialization failed.\n");
                  nRetCode = 1;
           }
           else
           {
                  // Actual WinMain codes ...              AfxWinTerm();
           }       return nRetCode;
    }
      

  8.   

    先#include <afx.h>
    #include <afxwin.h>         
    再选择rebuild all,输出窗口如下:
    Deleting intermediate files and output files for project 'PushSource - Win32 Debug Unicode'.
    --------------------Configuration: PushSource - Win32 Debug Unicode--------------------
    Compiling...
    DataAdmin.cpp
    FilePack.cpp
    PushSourceBitmapSet.cpp
    setup.cpp
    Linking...
       Creating library Debug_Unicode/PushBmpSet.lib and object Debug_Unicode/PushBmpSet.exp
    DataAdmin.obj : error LNK2001: unresolved external symbol __afxForceEXCLUDE
    PushSourceBitmapSet.obj : error LNK2001: unresolved external symbol __afxForceEXCLUDE
    DataAdmin.obj : error LNK2001: unresolved external symbol __afxForceUSRDLL
    PushSourceBitmapSet.obj : error LNK2001: unresolved external symbol __afxForceUSRDLL
    DataAdmin.obj : error LNK2001: unresolved external symbol "public: static void __stdcall CObject::operator delete(void *)" (??3CObject@@SGXPAX@Z)
    DataAdmin.obj : error LNK2001: unresolved external symbol "public: __thiscall CMutex::CMutex(int,unsigned short const *,struct _SECURITY_ATTRIBUTES *)" (??0CMutex@@QAE@HPBGPAU_SECURITY_ATTRIBUTES@@@Z)
    DataAdmin.obj : error LNK2001: unresolved external symbol "public: static void * __stdcall CObject::operator new(unsigned int)" (??2CObject@@SGPAXI@Z)
    DataAdmin.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall CPtrList::~CPtrList(void)" (??1CPtrList@@UAE@XZ)
    DataAdmin.obj : error LNK2001: unresolved external symbol "public: void __thiscall CPtrList::RemoveAll(void)" (?RemoveAll@CPtrList@@QAEXXZ)
    DataAdmin.obj : error LNK2001: unresolved external symbol "public: struct __POSITION * __thiscall CPtrList::GetHeadPosition(void)const " (?GetHeadPosition@CPtrList@@QBEPAU__POSITION@@XZ)
    DataAdmin.obj : error LNK2001: unresolved external symbol "public: __thiscall CSingleLock::~CSingleLock(void)" (??1CSingleLock@@QAE@XZ)
    DataAdmin.obj : error LNK2001: unresolved external symbol "public: int __thiscall CSingleLock::Unlock(void)" (?Unlock@CSingleLock@@QAEHXZ)
    DataAdmin.obj : error LNK2001: unresolved external symbol "public: int __thiscall CPtrList::IsEmpty(void)const " (?IsEmpty@CPtrList@@QBEHXZ)
    DataAdmin.obj : error LNK2001: unresolved external symbol "public: int __thiscall CSingleLock::IsLocked(void)" (?IsLocked@CSingleLock@@QAEHXZ)
    DataAdmin.obj : error LNK2001: unresolved external symbol "public: int __thiscall CSingleLock::Lock(unsigned long)" (?Lock@CSingleLock@@QAEHK@Z)
    DataAdmin.obj : error LNK2001: unresolved external symbol "public: __thiscall CSingleLock::CSingleLock(class CSyncObject *,int)" (??0CSingleLock@@QAE@PAVCSyncObject@@H@Z)
    DataAdmin.obj : error LNK2001: unresolved external symbol "public: int __thiscall CPtrList::GetCount(void)const " (?GetCount@CPtrList@@QBEHXZ)
    DataAdmin.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CPtrList::Dump(class CDumpContext &)const " (?Dump@CPtrList@@UBEXAAVCDumpContext@@@Z)
    DataAdmin.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CPtrList::AssertValid(void)const " (?AssertValid@CPtrList@@UBEXXZ)
    DataAdmin.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall CObject::Serialize(class CArchive &)" (?Serialize@CObject@@UAEXAAVCArchive@@@Z)
    DataAdmin.obj : error LNK2001: unresolved external symbol "public: virtual struct CRuntimeClass * __thiscall CPtrList::GetRuntimeClass(void)const " (?GetRuntimeClass@CPtrList@@UBEPAUCRuntimeClass@@XZ)
    DataAdmin.obj : error LNK2001: unresolved external symbol "public: struct __POSITION * __thiscall CPtrList::AddTail(void *)" (?AddTail@CPtrList@@QAEPAU__POSITION@@PAX@Z)
    DataAdmin.obj : error LNK2001: unresolved external symbol "public: void * & __thiscall CPtrList::GetHead(void)" (?GetHead@CPtrList@@QAEAAPAXXZ)
    DataAdmin.obj : error LNK2001: unresolved external symbol "public: void * __thiscall CPtrList::RemoveHead(void)" (?RemoveHead@CPtrList@@QAEPAXXZ)
    DataAdmin.obj : error LNK2001: unresolved external symbol "public: void * & __thiscall CPtrList::GetNext(struct __POSITION * &)" (?GetNext@CPtrList@@QAEAAPAXAAPAU__POSITION@@@Z)
    DataAdmin.obj : error LNK2001: unresolved external symbol "public: __thiscall CPtrList::CPtrList(int)" (??0CPtrList@@QAE@H@Z)
    PushSourceBitmapSet.obj : error LNK2001: unresolved external symbol "int __stdcall AfxAssertFailedLine(char const *,int)" (?AfxAssertFailedLine@@YGHPBDH@Z)
    Debug_Unicode/PushBmpSet.ax : fatal error LNK1120: 25 unresolved externals
    Error executing link.exe.PushBmpSet.ax - 28 error(s), 0 warning(s)
    按照常理是缺少库文件,我应该加上什么库才好呢?
      

  9.   

    unresolved external symbol
    这个错误明显是文件没包含进来,建议你查查,例如:CPtrList::GetNext在那个文件定义的,加进去,而且前面缺少cobject的定义
      

  10.   

    仔细研究 <afx.h>,发现应该加入mfc42ud.lib ,mfc42sud.lib ,现在已经下降为2errors,1
    warningDeleting intermediate files and output files for project 'PushSource - Win32 Debug Unicode'.
    --------------------Configuration: PushSource - Win32 Debug Unicode--------------------
    Compiling...
    DataAdmin.cpp
    FilePack.cpp
    PushSourceBitmapSet.cpp
    setup.cpp
    Linking...
    mfcs42ud.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in setup.obj
    mfcs42ud.lib(dllmodul.obj) : warning LNK4006: _DllMain@12 already defined in setup.obj; second definition ignored
       Creating library Debug_Unicode/PushBmpSet.lib and object Debug_Unicode/PushBmpSet.exp
    Debug_Unicode/PushBmpSet.ax : fatal error LNK1169: one or more multiply defined symbols found
    Error executing link.exe.PushBmpSet.ax - 2 error(s), 1 warning(s)
      

  11.   

    http://expert.csdn.net/Expert/topic/1710/1710297.xml?temp=.5333368
      

  12.   


    谢谢上面各位友情跟贴。
    问题已经解决。要点:1、加入相关的头文件,尤其是afx.h   
                       2、确保MFC库在CRT库之前被link,可参考微软的文章ID:KB148652
                          查看afx.h文件中库如何链接的部分,选择合理的preprocessor 
                           definitions 
                       3、多问问题,集思广益to:webber84(***闭关修炼中***) 
        我在写一个directshow filter ,是Win32 DLL类型的
    to:o_racle(璐璐) ( ) 
        既然是link error,首先想到的不该是头文件没有include吧 :)