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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problems with a dll

Problems with a dll

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
3 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.
  • J Offline
    J Offline
    JaVinci
    wrote on last edited by
    #1

    Hi! I'm trying to import a dll in Visual C++ 6. Can anybody help me? When I link to that dll from another project it doesn't work. I'm sure I'm missing something, but I don't know what... Here's how the dll is written (no errors, no warnings): ************** * whatever.h * ************** #ifdef __cplusplus extern "C"{ #endif class __declspec(dllexport) MyClass{ private: char myString[100]; int myInteger; public: MyClass(); void getMyString(char * str); int getMyInteger(void); void setMyString(char * str); void setMyInteger(int); }; __declspec(dllexport) int function(MyClass * mc); **************** * whatever.cpp * **************** Just implementation here... What can I do to import the class and the function from that dll (preferably not using a .def file)??? Please, help me, I'm going mad... :(( Thank you!!!

    G 1 Reply Last reply
    0
    • J JaVinci

      Hi! I'm trying to import a dll in Visual C++ 6. Can anybody help me? When I link to that dll from another project it doesn't work. I'm sure I'm missing something, but I don't know what... Here's how the dll is written (no errors, no warnings): ************** * whatever.h * ************** #ifdef __cplusplus extern "C"{ #endif class __declspec(dllexport) MyClass{ private: char myString[100]; int myInteger; public: MyClass(); void getMyString(char * str); int getMyInteger(void); void setMyString(char * str); void setMyInteger(int); }; __declspec(dllexport) int function(MyClass * mc); **************** * whatever.cpp * **************** Just implementation here... What can I do to import the class and the function from that dll (preferably not using a .def file)??? Please, help me, I'm going mad... :(( Thank you!!!

      G Offline
      G Offline
      GDavy
      wrote on last edited by
      #2

      when importing you need to declare __declspec(dllimport) An often used method when writing dll^s is following: in the header write a statement like #ifdef __MY_DLL_PROJECT__ #define _DECSPEC_ __declspec(dllexport) #else #define _DECSPEC_ __declspec(dllimport) #endif all you need to do is define the symbol _MY_DLL_PROJECT_ in your dll project, and define your class in the header as: class _DECSPEC_ MyClass { ... }; Greetings, Davy

      J 1 Reply Last reply
      0
      • G GDavy

        when importing you need to declare __declspec(dllimport) An often used method when writing dll^s is following: in the header write a statement like #ifdef __MY_DLL_PROJECT__ #define _DECSPEC_ __declspec(dllexport) #else #define _DECSPEC_ __declspec(dllimport) #endif all you need to do is define the symbol _MY_DLL_PROJECT_ in your dll project, and define your class in the header as: class _DECSPEC_ MyClass { ... }; Greetings, Davy

        J Offline
        J Offline
        JaVinci
        wrote on last edited by
        #3

        Yeah, thanks... I had already done that. I nearly kill myself when I realized that I wasn't setting the dependence between both projects. That was all I needed. Thank you very much for your reply!!! :) JaVinci

        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