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. Import a class from .DLL

Import a class from .DLL

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
5 Posts 4 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.
  • C Offline
    C Offline
    CND
    wrote on last edited by
    #1

    Hi, I'm exporting this class form a dll: #ifndef _DLL_H_ #define _DLL_H_ #if BUILDING_DLL # define DLLIMPORT __declspec (dllexport) #else /* Not BUILDING_DLL */ # define DLLIMPORT __declspec (dllimport) #endif /* Not BUILDING_DLL */ class DLLIMPORT AES { public: AES(); virtual ~AES(void); private: }; #endif /* _DLL_H_ */ and this is the programm, that uses this dll: #include #include #include "..\AES\dll.h" using namespace std; int main(int argc, char *argv[]) { // Load Libary HMODULE AESLibary = LoadLibrary("../AES/AES.dll"); if (AESLibary) printf("AES.DLL found!\r\n"); else printf("AES.DLL not found!\r\n"); AES myAES; system("PAUSE"); return 0; } but everytime I compile this program I get these errors: [Linker error] undefined reference to `AES::AES()' [Linker error] undefined reference to `AES::~AES()' (generating the .dll file is no problem...) can anybody tell me why? thx CND

    J 1 Reply Last reply
    0
    • C CND

      Hi, I'm exporting this class form a dll: #ifndef _DLL_H_ #define _DLL_H_ #if BUILDING_DLL # define DLLIMPORT __declspec (dllexport) #else /* Not BUILDING_DLL */ # define DLLIMPORT __declspec (dllimport) #endif /* Not BUILDING_DLL */ class DLLIMPORT AES { public: AES(); virtual ~AES(void); private: }; #endif /* _DLL_H_ */ and this is the programm, that uses this dll: #include #include #include "..\AES\dll.h" using namespace std; int main(int argc, char *argv[]) { // Load Libary HMODULE AESLibary = LoadLibrary("../AES/AES.dll"); if (AESLibary) printf("AES.DLL found!\r\n"); else printf("AES.DLL not found!\r\n"); AES myAES; system("PAUSE"); return 0; } but everytime I compile this program I get these errors: [Linker error] undefined reference to `AES::AES()' [Linker error] undefined reference to `AES::~AES()' (generating the .dll file is no problem...) can anybody tell me why? thx CND

      J Offline
      J Offline
      John M Drescher
      wrote on last edited by
      #2

      You can not use dynamic loading (LoadLibrary) in this manner. For this statement

      AES myAES;

      to work you must statically link with the .lib file that is produced with the DLL. John

      C 1 Reply Last reply
      0
      • J John M Drescher

        You can not use dynamic loading (LoadLibrary) in this manner. For this statement

        AES myAES;

        to work you must statically link with the .lib file that is produced with the DLL. John

        C Offline
        C Offline
        CND
        wrote on last edited by
        #3

        ok, but so I which manner can I use DLLs? Is it possible to load dynamicly a class. so to use IDEA.DLL if the user selects this DLL and AES.DLL if he selects this one. This I important for me, because, I want to add crypto algorithms step by step, like plugins...

        I 1 Reply Last reply
        0
        • C CND

          ok, but so I which manner can I use DLLs? Is it possible to load dynamicly a class. so to use IDEA.DLL if the user selects this DLL and AES.DLL if he selects this one. This I important for me, because, I want to add crypto algorithms step by step, like plugins...

          I Offline
          I Offline
          igor1960
          wrote on last edited by
          #4

          Check DelayLoad if want to do that... "...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..." Me

          A 1 Reply Last reply
          0
          • I igor1960

            Check DelayLoad if want to do that... "...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..." Me

            A Offline
            A Offline
            Anonymous
            wrote on last edited by
            #5

            Or use COM, with a standardised Interface.

            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