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. Calling C++ DLL ( not MFC) from another C++ DLL ( not MFC)

Calling C++ DLL ( not MFC) from another C++ DLL ( not MFC)

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestiondebuggingannouncement
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
    chepuri_uk
    wrote on last edited by
    #1

    Hi, I have a C++ DLL ( not MFC )which has a static method say class Test { static GetData(); Static GetParams(); bool TestDatat(); }; I am exporting this class and using in another DLL. I built Test.dll,Test.lib. Now i included in another DLL(say Samp.DLL): Test.dll,Test.lib abd Test.h in Samp.h file i inclued "Test.h" and linkedTest.lib and Placed Test.dll in Release/Debug folder. I am calling Test::GetData() in Samp.DLL. But after compiling Samp.DLL giving error like: "error LNK 2001: unresolved external symbol. _declspec(dllimport) public:static bool _stdcall Test::GetDatta(char const *,bool)(_imp_?GetData@Test@SG_NPBD_N@Z)". while building if i change project setttings "_cdecl*" in calling conventions, DLL is building fine,but failing to call a value from Samp.DLL by passing value to Test.DLL. If i what to build my Samp.DLL by "_stdcall" convention how can i build this ? Any help on this.. Thank you.

    J J 2 Replies Last reply
    0
    • C chepuri_uk

      Hi, I have a C++ DLL ( not MFC )which has a static method say class Test { static GetData(); Static GetParams(); bool TestDatat(); }; I am exporting this class and using in another DLL. I built Test.dll,Test.lib. Now i included in another DLL(say Samp.DLL): Test.dll,Test.lib abd Test.h in Samp.h file i inclued "Test.h" and linkedTest.lib and Placed Test.dll in Release/Debug folder. I am calling Test::GetData() in Samp.DLL. But after compiling Samp.DLL giving error like: "error LNK 2001: unresolved external symbol. _declspec(dllimport) public:static bool _stdcall Test::GetDatta(char const *,bool)(_imp_?GetData@Test@SG_NPBD_N@Z)". while building if i change project setttings "_cdecl*" in calling conventions, DLL is building fine,but failing to call a value from Samp.DLL by passing value to Test.DLL. If i what to build my Samp.DLL by "_stdcall" convention how can i build this ? Any help on this.. Thank you.

      J Offline
      J Offline
      Jaime Stuardo
      wrote on last edited by
      #2

      Have you exported using _declspec(dllexport) and imported using _declspec(dllimport)? Can you show how you are importing and exporting? Jaime

      1 Reply Last reply
      0
      • C chepuri_uk

        Hi, I have a C++ DLL ( not MFC )which has a static method say class Test { static GetData(); Static GetParams(); bool TestDatat(); }; I am exporting this class and using in another DLL. I built Test.dll,Test.lib. Now i included in another DLL(say Samp.DLL): Test.dll,Test.lib abd Test.h in Samp.h file i inclued "Test.h" and linkedTest.lib and Placed Test.dll in Release/Debug folder. I am calling Test::GetData() in Samp.DLL. But after compiling Samp.DLL giving error like: "error LNK 2001: unresolved external symbol. _declspec(dllimport) public:static bool _stdcall Test::GetDatta(char const *,bool)(_imp_?GetData@Test@SG_NPBD_N@Z)". while building if i change project setttings "_cdecl*" in calling conventions, DLL is building fine,but failing to call a value from Samp.DLL by passing value to Test.DLL. If i what to build my Samp.DLL by "_stdcall" convention how can i build this ? Any help on this.. Thank you.

        J Offline
        J Offline
        Jeremy Falcon
        wrote on last edited by
        #3

        [edit] Regular DLLs don't You shouldn't [/edit] expose objects in a regular DLL (only ActiveX or MFC Extension DLLs) if you want the calling code to be something besides C++. You'll need to export a regular C-style function that serves as a wrapper to the method/property you are trying to invoke. Jeremy Falcon

        J 1 Reply Last reply
        0
        • J Jeremy Falcon

          [edit] Regular DLLs don't You shouldn't [/edit] expose objects in a regular DLL (only ActiveX or MFC Extension DLLs) if you want the calling code to be something besides C++. You'll need to export a regular C-style function that serves as a wrapper to the method/property you are trying to invoke. Jeremy Falcon

          J Offline
          J Offline
          Jorgen Sigvardsson
          wrote on last edited by
          #4

          :confused: He's exporting a regular C++ class. Nothing magical about that, and is certainly possible with DLLs. -- Ich bin Joachim von Hassel, und ich bin Pilot der Bundeswehr. Welle: Erdball - F104-G Starfighter

          J 1 Reply Last reply
          0
          • J Jorgen Sigvardsson

            :confused: He's exporting a regular C++ class. Nothing magical about that, and is certainly possible with DLLs. -- Ich bin Joachim von Hassel, und ich bin Pilot der Bundeswehr. Welle: Erdball - F104-G Starfighter

            J Offline
            J Offline
            Jeremy Falcon
            wrote on last edited by
            #5

            Possible, but not practical and in poor practice IMO. Because, if you do that, then your calling language has to be C++. Jeremy Falcon

            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