Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. a problem about how to use a class in dll

a problem about how to use a class in dll

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    benben
    wrote on last edited by
    #1

    Hi: In my programme,I use some classes in a dll.When I try to compile it, VC give out such errors: error C2487: 'classCWinAppEx' : member of dll interface class may not be declared with dll interface error C2487: 'classCMyMenu' : member of dll interface class may not be declared with dll interface (CWinAppEx and CMyMenu are declare and implemented in the dll) and all these errors are point to the line "DECLARE_DYNAMIC( CWinAppEx )" or "DECLARE_DYNAMIC( CMyMenu )". I look up this error in MSDN, but didn't find the solution.Could anyone give me some idea? Thanks Benben

    A 1 Reply Last reply
    0
    • B benben

      Hi: In my programme,I use some classes in a dll.When I try to compile it, VC give out such errors: error C2487: 'classCWinAppEx' : member of dll interface class may not be declared with dll interface error C2487: 'classCMyMenu' : member of dll interface class may not be declared with dll interface (CWinAppEx and CMyMenu are declare and implemented in the dll) and all these errors are point to the line "DECLARE_DYNAMIC( CWinAppEx )" or "DECLARE_DYNAMIC( CMyMenu )". I look up this error in MSDN, but didn't find the solution.Could anyone give me some idea? Thanks Benben

      A Offline
      A Offline
      ashxly
      wrote on last edited by
      #2

      try to use __declspec(dllexport) while declare class Exa: #define EXT_CLASS __declspec(dllexport) class EXT_CLASS ClassA : public X { ... };

      B 1 Reply Last reply
      0
      • A ashxly

        try to use __declspec(dllexport) while declare class Exa: #define EXT_CLASS __declspec(dllexport) class EXT_CLASS ClassA : public X { ... };

        B Offline
        B Offline
        benben
        wrote on last edited by
        #3

        Thanks.I have used this macro in the dll. And thses errors only occour when I try to compile one certain file(when I compile the other files, VC doesn't give out these errors). Thanks Benben

        B 1 Reply Last reply
        0
        • B benben

          Thanks.I have used this macro in the dll. And thses errors only occour when I try to compile one certain file(when I compile the other files, VC doesn't give out these errors). Thanks Benben

          B Offline
          B Offline
          benben
          wrote on last edited by
          #4

          and I find that these errors only occur when the cpp files in EXE project have such line: #undef AFX_DATA #define AFX_DATA AFX_DATA_EXPORT Maybe it conflict with the static functions or something else in the dll.How to resolve this problem? Could anyone give some idea? Thanks Benben

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups