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. Link DLL with Visual C++ not working

Link DLL with Visual C++ not working

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

    I have the following problem: I have a dll compiled with MinGW and a header file that describes the DLL exports. I want to use this DLL in a Visual C++ projects. Since i don't have a LIB file and i don't want to use LoadLibrary function i created a DEF file. The contents of the EXPORTS section of the DEF file i toke from DUMPBIN /EXPORTS [the_dll], so it should be ok. After i created the lib file i included it in my Visual C++ project and the project has compiled successfully. But when i executed it, the application crashed. This application is working when compiled with GCC and the same DLL. So is the problem somewhere in MinGW or what? May be i must pass some special parameters to cl.exe or link.exe Experts please help!

    C 1 Reply Last reply
    0
    • S status

      I have the following problem: I have a dll compiled with MinGW and a header file that describes the DLL exports. I want to use this DLL in a Visual C++ projects. Since i don't have a LIB file and i don't want to use LoadLibrary function i created a DEF file. The contents of the EXPORTS section of the DEF file i toke from DUMPBIN /EXPORTS [the_dll], so it should be ok. After i created the lib file i included it in my Visual C++ project and the project has compiled successfully. But when i executed it, the application crashed. This application is working when compiled with GCC and the same DLL. So is the problem somewhere in MinGW or what? May be i must pass some special parameters to cl.exe or link.exe Experts please help!

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #2

      This has probably nothing to do with the fact that it's a dll. Start your debugger to see where the program crashes.


      Cédric Moonen Software developer
      Charting control

      S 1 Reply Last reply
      0
      • C Cedric Moonen

        This has probably nothing to do with the fact that it's a dll. Start your debugger to see where the program crashes.


        Cédric Moonen Software developer
        Charting control

        S Offline
        S Offline
        status
        wrote on last edited by
        #3

        Ok i will explain in more details: So in the header file i have a definition of an abstract class wich has onlu pure virtual methods. In the DLL i have only one export function which is returning a pointer to an instance of this class or more precisely some class that inherits this abstract class. The program is something like: SomeClass* c = ImportedMethod(); c->someMethod(); **// Here the program crashes** It looke strange i know, the problem is that i don't hava the source of the DLL neither i have any more information about it. Only those header: class SomeClass { public: virtual void someMethod() = 0; } extern "C" __declspec (dllexport) SomeClass * ImportedMethod();

        C 1 Reply Last reply
        0
        • S status

          Ok i will explain in more details: So in the header file i have a definition of an abstract class wich has onlu pure virtual methods. In the DLL i have only one export function which is returning a pointer to an instance of this class or more precisely some class that inherits this abstract class. The program is something like: SomeClass* c = ImportedMethod(); c->someMethod(); **// Here the program crashes** It looke strange i know, the problem is that i don't hava the source of the DLL neither i have any more information about it. Only those header: class SomeClass { public: virtual void someMethod() = 0; } extern "C" __declspec (dllexport) SomeClass * ImportedMethod();

          C Offline
          C Offline
          Cedric Moonen
          wrote on last edited by
          #4

          What is the value of c ? Does it point to a valid memory address ? Otherwise your method could simply return NULL and you didn't check it.


          Cédric Moonen Software developer
          Charting control

          S 1 Reply Last reply
          0
          • C Cedric Moonen

            What is the value of c ? Does it point to a valid memory address ? Otherwise your method could simply return NULL and you didn't check it.


            Cédric Moonen Software developer
            Charting control

            S Offline
            S Offline
            status
            wrote on last edited by
            #5

            c isn't null. c contains a valid memory address and according to the Visual Studio debugger it contains the addresses of virtual functions. The same source is working when compiled with GCC. The difference may be is in the calling conventions or i don't know. But there is no problem in the source. The problem is in the dll that is used i think.

            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