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. MFC DLL

MFC DLL

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++visual-studio
11 Posts 2 Posters 1 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 bhanu_8509

    Dear All, I have created a MFC DLL in VS 2005. I have included this dll (dll and lib) in the VS 2003. The project compiled and running well. But, when I run the exe in another system (XP with SP3) without VS then the exe throws an error saying that "Application not correctly initialized". I dont know the reason of this problem. Please help me... Regards, Bhanu

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

    You will need to download and install the vc redistributable package on the target computer. You can download it from here[^]. If you have the vc2005 service pack 1 installed, you should download the version for service pack 1 (see the links at the bottom of the page). When executing this on the target machine, it will install the C-runtime libraries and MFC libraries. Another option would be to statically link to the C-runtime library and MFC libraries.

    Cédric Moonen Software developer
    Charting control [v1.5] OpenGL game tutorial in C++

    B 1 Reply Last reply
    0
    • C Cedric Moonen

      You will need to download and install the vc redistributable package on the target computer. You can download it from here[^]. If you have the vc2005 service pack 1 installed, you should download the version for service pack 1 (see the links at the bottom of the page). When executing this on the target machine, it will install the C-runtime libraries and MFC libraries. Another option would be to statically link to the C-runtime library and MFC libraries.

      Cédric Moonen Software developer
      Charting control [v1.5] OpenGL game tutorial in C++

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

      Dear Moonen, Thank you so much for your reply. Installing vcredist_x86.exe solves the problem, but I want my dll to be self sufficient irrespective of the versions. I created a MFC DLL as "Regular DLL with MFC statically linked". The dll is created properly, but if I include in my MFC dialog based project I got linker error (error LNK2019: unresolved external symbol). Please help me... Many thanks in advance. Bhanu

      C 1 Reply Last reply
      0
      • B bhanu_8509

        Dear Moonen, Thank you so much for your reply. Installing vcredist_x86.exe solves the problem, but I want my dll to be self sufficient irrespective of the versions. I created a MFC DLL as "Regular DLL with MFC statically linked". The dll is created properly, but if I include in my MFC dialog based project I got linker error (error LNK2019: unresolved external symbol). Please help me... Many thanks in advance. Bhanu

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

        bhanu_8509 wrote:

        The dll is created properly, but if I include in my MFC dialog based project I got linker error (error LNK2019: unresolved external symbol)

        What is the exact error message ? Your MFC application also needs to statically link to the MFC.

        Cédric Moonen Software developer
        Charting control [v1.5] OpenGL game tutorial in C++

        B 1 Reply Last reply
        0
        • C Cedric Moonen

          bhanu_8509 wrote:

          The dll is created properly, but if I include in my MFC dialog based project I got linker error (error LNK2019: unresolved external symbol)

          What is the exact error message ? Your MFC application also needs to statically link to the MFC.

          Cédric Moonen Software developer
          Charting control [v1.5] OpenGL game tutorial in C++

          B Offline
          B Offline
          bhanu_8509
          wrote on last edited by
          #5

          The exact error message is CSPortDlg.obj : error LNK2019: unresolved external symbol _GetDevice referenced in function "public: void __thiscall CSPortDlg::OnBnClickedButton2(void)" (?OnBnClickedButton2@CSPortDlg@@QAEXXZ)

          Cedric Moonen wrote:

          Your MFC application also needs to statically link to the MFC.

          Can you please tell me how to modify the settings of my MFC application which access the DLL. Many thanks. Bhanu

          C 1 Reply Last reply
          0
          • B bhanu_8509

            The exact error message is CSPortDlg.obj : error LNK2019: unresolved external symbol _GetDevice referenced in function "public: void __thiscall CSPortDlg::OnBnClickedButton2(void)" (?OnBnClickedButton2@CSPortDlg@@QAEXXZ)

            Cedric Moonen wrote:

            Your MFC application also needs to statically link to the MFC.

            Can you please tell me how to modify the settings of my MFC application which access the DLL. Many thanks. Bhanu

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

            Well, looking at the error message it seems something else. From where is this _GetDevice function coming from ? If it is defined in a library, did you add the library to your project ?

            Cédric Moonen Software developer
            Charting control [v1.5] OpenGL game tutorial in C++

            B 1 Reply Last reply
            0
            • C Cedric Moonen

              Well, looking at the error message it seems something else. From where is this _GetDevice function coming from ? If it is defined in a library, did you add the library to your project ?

              Cédric Moonen Software developer
              Charting control [v1.5] OpenGL game tutorial in C++

              B Offline
              B Offline
              bhanu_8509
              wrote on last edited by
              #7

              Cedric Moonen wrote:

              If it is defined in a library, did you add the library to your project ?

              Yes the method is defined in the library. I included the library and .h file in to the application. But interestingly if I create the MFC DLL as "Regular DLL using shared MFC DLL" and include in the project then this linker error is not coming. The above error is getting when I create the MFC DLL as "Regular DLL with MFC statically linked". Please advice. Many thanks in advance. Bhanu

              C 1 Reply Last reply
              0
              • B bhanu_8509

                Cedric Moonen wrote:

                If it is defined in a library, did you add the library to your project ?

                Yes the method is defined in the library. I included the library and .h file in to the application. But interestingly if I create the MFC DLL as "Regular DLL using shared MFC DLL" and include in the project then this linker error is not coming. The above error is getting when I create the MFC DLL as "Regular DLL with MFC statically linked". Please advice. Many thanks in advance. Bhanu

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

                It's a bit strange... Anyway, you can try to link your project statically to the MFC's but I'm not sure it will solve the problem. For VC2005, open the project properties, go to general, and for "Use of MFC" select "Use MFC in a Static Library".

                Cédric Moonen Software developer
                Charting control [v1.5] OpenGL game tutorial in C++

                B 1 Reply Last reply
                0
                • C Cedric Moonen

                  It's a bit strange... Anyway, you can try to link your project statically to the MFC's but I'm not sure it will solve the problem. For VC2005, open the project properties, go to general, and for "Use of MFC" select "Use MFC in a Static Library".

                  Cédric Moonen Software developer
                  Charting control [v1.5] OpenGL game tutorial in C++

                  B Offline
                  B Offline
                  bhanu_8509
                  wrote on last edited by
                  #9

                  I am sorry. Already my project setting is using "Use MFC in Static Library" Please advice. Many thanks. Bhanu

                  C 1 Reply Last reply
                  0
                  • B bhanu_8509

                    I am sorry. Already my project setting is using "Use MFC in Static Library" Please advice. Many thanks. Bhanu

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

                    The error message means that the problem is at linking time: the compiler is able to find the prototype of the function in one header file but when it needs to link to it, it is unable to find the function body. If this function is defined in your dll code, then you need to be absolutely sure that you added the library to your project. How did you do that ? could you explain how you added the library to your project ?

                    Cédric Moonen Software developer
                    Charting control [v1.5] OpenGL game tutorial in C++

                    B 1 Reply Last reply
                    0
                    • C Cedric Moonen

                      The error message means that the problem is at linking time: the compiler is able to find the prototype of the function in one header file but when it needs to link to it, it is unable to find the function body. If this function is defined in your dll code, then you need to be absolutely sure that you added the library to your project. How did you do that ? could you explain how you added the library to your project ?

                      Cédric Moonen Software developer
                      Charting control [v1.5] OpenGL game tutorial in C++

                      B Offline
                      B Offline
                      bhanu_8509
                      wrote on last edited by
                      #11

                      Project Properties->Linker->Input->Additional Dependencies->mydll.lib

                      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