CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 14 of 14

Thread: DLL file error

  1. #1
    Join Date
    Aug 2005
    Posts
    70

    Question DLL file error

    Dear all

    I'm learning about dll in MFC from my workplace. This dll was created by senior programmer. I try learn this dll and write it back into the new one.

    But, when I compile 1 file. I have a lot of error even it is same as original.

    this is header file
    Code:
    // Book.h : interface of the CBook class
    
    #pragma once
    
    #include "MawarCore\MawarFlit\FBSocket.h"
    #include "MawarCore\MawarCtrl\DataBitmap.h"
    #include "MawarCore\MawarFlit\Card.h"
    #include "AkmalDataDefs.h"
    
    class AKMAL_DATA_API CBook : public CCard
    {
    public:
    	int		m_PictureID;
    	int		m_BookAttr;
    	int		m_Reserved[20];
    
    public:
    	// function
    	CBitmapBin* GetBitmap(CFBSocket* pEmpSock, CRecordHnd* phBuff);
    	bool DeleteBitmap(CFBSocket* pEmpSock);
    
    public:
    	CBook(void);
    	~CBook(void);
    };
    and this is .cpp file

    Code:
    // Book.cpp : implementation of the CBook class
    
    #include "StdAfx.h"
    #include "Book.h"
    
    /////////////////////////////////////////////////////////////////////////////////
    #ifdef _DEBUG
    #undef THIS_FILE
    static char THIS_FILE[]=__FILE__;
    #define new DEBUG_NEW
    #endif
    
    /////////////////////////////////////////////////////////////////////////////////
    // construction/destruction
    /////////////////////////////////////////////////////////////////////////////////
    
    CBook::CBook(void)
    {
    }
    
    CBook::~CBook(void)
    {
    }
    
    CBitmapBin* CBook::GetBitmap(CFBSocket* pEmpSock, CRecordHnd* phBuff)
    {
    	if(m_PictureID != 0)
    	{
    		CBitmapBin* pBin = (CBitmapBin*)pEmpSock->ReadRecord(phBuff, MRT_PICTDATA, m_PictureID);
    		if(pBin != NULL)
    			return pBin;
    		LogError("Missing picture........");
    	}
    	return NULL;
    }
    
    bool CBook::DeleteBitmap(CFBSocket *pEmpSock)
    {
    	if(m_PictureID != 0)
    	{
    		pEmpSock->ReadRecord(MRT_PICTDATA, m_PictureID);
    		m_PictureID = 0;
    	}
    	return true;
    }
    The error is

    1. error C2332: 'class' : missing tag name
    2. error C2011: '__unnamed' : 'enum' type redefinition
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\ShlObj.h(4476) : see declaration of '__unnamed'
    3. error C2470: 'CBook' : looks like a function definition, but there is no formal parameter list; skipping apparent body
    4. error C2059: syntax error : 'public'
    5. error C2653: 'CBook' : is not a class or namespace name
    6. warning C4508: 'CBook' : function should return a value; 'void' return type assumed
    7. error C2653: 'CBook' : is not a class or namespace name
    8. error C2084: function 'int CBook(void)' already has a body
    c:\Documents and Settings\Rokman\My Documents\Visual Studio Projects\Akmal Project Suite\Library\Akmal-Data\Book.cpp(17) : see previous definition of 'CBook'
    9. error C2653: 'CBook' : is not a class or namespace name


    and a few more like the class never declare......

    Can anybody explain to me what all of this error mean????

    ps : I really appreciate who can explain this to me..... tq
    MFC & VC++ newbie

  2. #2
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234

    Re: DLL file error

    Is AKMAL_DATA_API somewhere defined?
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  3. #3
    Join Date
    Aug 2005
    Posts
    70

    Re: DLL file error

    I think defined it already... is it we define it in Definition file right.

    this is the file AkmalDataDefs.def

    Code:
    #pragma once
    
    #ifdef _AKMAL_DATA_EXP
    #define AKMAL_DATA_API __declspec(dllexport);
    #else
    #define AKMAL_DATA_API __declspec(dllimport);
    #endif
    Is it right???
    MFC & VC++ newbie

  4. #4
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: DLL file error

    this is the file AkmalDataDefs.def
    Did you mean AkmalDataDefs.h?
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  5. #5
    Join Date
    Jun 2005
    Location
    Tirunelveli-Tamil Nadu-India
    Posts
    354

    Smile Re: DLL file error

    Code:
    #pragma once
    
    #ifdef _AKMAL_DATA_EXP
    #define AKMAL_DATA_API __declspec(dllexport);
    #else
    #define AKMAL_DATA_API __declspec(dllimport);
    #endif
    have u include AKMAL_DATA_API header file ? try it.
    If I Helped You, "Rate This Post"

    Thanks
    Guna

  6. #6
    Join Date
    Aug 2005
    Posts
    70

    Re: DLL file error

    Quote Originally Posted by cilu
    Did you mean AkmalDataDefs.h?
    Oppss Sorry. It's not .def

    Yes, It's AkmalDataDefs.h <---Defines the entry point for the DLL application.

    Even I have put this header into .cpp also cannot. You can see it in my 1st post above.
    MFC & VC++ newbie

  7. #7
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652

    Re: DLL file error

    It looks like there is something wrong before the class definition...in other words...in one of the included files...
    Code:
    #include "MawarCore\MawarFlit\FBSocket.h"
    #include "MawarCore\MawarCtrl\DataBitmap.h"
    #include "MawarCore\MawarFlit\Card.h"

  8. #8
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Re: DLL file error

    This error might be significant....

    Quote Originally Posted by pusak82
    2. error C2011: '__unnamed' : 'enum' type redefinition
    c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\ShlObj.h(4476) : see declaration of '__unnamed'
    The code you posted doesn't contain any symbol called __unnamed - therefore it's most likely to be getting included by one (or probably, more than one) of the included headers.

    Check that you haven't got 2 header files that mutually include each other. For example, if DataBitmap.h includes Card.h, then Card.h shouldn't include DataBitmap.h
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  9. #9
    Join Date
    Aug 2005
    Posts
    70

    Re: DLL file error

    Until now I still cannot solve this prob....

    Code:
    class AKMAL_DATA_API CBook : public CCard
    {
    public:
    	int		m_PictureID;
    	int		m_BookAttr;
    	int		m_Reserved[20];
    
    public:
    	// function
    	CBitmapBin* GetBitmap(CFBSocket* pEmpSock, CRecordHnd* phBuff);
    	bool DeleteBitmap(CFBSocket* pEmpSock);
    
    public:
    	CBook(void);
    	~CBook(void);
    };
    the error is :

    c:\Documents and Settings\Rokman\My Documents\Visual Studio Projects\Akmal Project Suite\Library\Akmal-Data\Book.h(10): error C2332: 'class' : missing tag name


    Can any body solve this prob, I think compiler cannot read the declaration class type....

    I don't what to do right now...
    MFC & VC++ newbie

  10. #10
    Join Date
    Jun 2005
    Location
    Tirunelveli-Tamil Nadu-India
    Posts
    354

    Smile Re: DLL file error

    If I Helped You, "Rate This Post"

    Thanks
    Guna

  11. #11
    Join Date
    Aug 2005
    Posts
    70

    Re: DLL file error

    After I study the code...

    I detect the error starts is on AKMAL_DATA_API on declaration class in header file...

    Any one know how to make AKMAL_DATA_API validate to use....

    it's the definition file right...

    ps : Sorry I just now a little about DLL file...still on a route to understand it..
    MFC & VC++ newbie

  12. #12
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Re: DLL file error

    Code:
    #ifdef _AKMAL_DATA_EXP
    #define AKMAL_DATA_API __declspec(dllexport);
    #else
    #define AKMAL_DATA_API __declspec(dllimport);
    #endif
    I don't know if that was your error or somebody else's - but you shouldn't be using semi-colons here. The correct syntax is:-

    Code:
    #ifdef _AKMAL_DATA_EXP
    #define AKMAL_DATA_API __declspec(dllexport)
    #else
    #define AKMAL_DATA_API __declspec(dllimport)
    #endif
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  13. #13
    Join Date
    Aug 2005
    Posts
    70

    Re: DLL file error

    Tq very much John E, ur correction make my code compile successfully...

    After that, there was no error anymore....

    Why I not aware of this semi colons...

    Tq very much John E

    ps : Next time I need to be careful write a code...
    MFC & VC++ newbie

  14. #14
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,835

    Re: DLL file error

    Glad to be of help....
    "A problem well stated is a problem half solved.” - Charles F. Kettering

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured