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. Add .c file

Add .c file

Scheduled Pinned Locked Moved C / C++ / MFC
c++help
8 Posts 6 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
    john5632
    wrote on last edited by
    #1

    Hi Experts, I have 2 files ( .h and .c) I added in MFC dialog based application but I am getting linker error. Is there any special thing to add .c file.

    M D J 3 Replies Last reply
    0
    • J john5632

      Hi Experts, I have 2 files ( .h and .c) I added in MFC dialog based application but I am getting linker error. Is there any special thing to add .c file.

      M Offline
      M Offline
      Maximilien
      wrote on last edited by
      #2

      john5632 wrote:

      but I am getting linker error.

      Are you certain the file is compiled as C++ ? What link errors ? Are you referencing an external library ?

      Watched code never compiles.

      J 1 Reply Last reply
      0
      • J john5632

        Hi Experts, I have 2 files ( .h and .c) I added in MFC dialog based application but I am getting linker error. Is there any special thing to add .c file.

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        john5632 wrote:

        ...but I am getting linker error.

        Care to share?

        "One man's wage rise is another man's price increase." - Harold Wilson

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        "Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather

        1 Reply Last reply
        0
        • M Maximilien

          john5632 wrote:

          but I am getting linker error.

          Are you certain the file is compiled as C++ ? What link errors ? Are you referencing an external library ?

          Watched code never compiles.

          J Offline
          J Offline
          john5632
          wrote on last edited by
          #4

          yes, I am getting linker error 2019, 2001. error LNK2019: unresolved external symbol "void __cdecl Unload(void)" (?Unload@@YAXXZ) referenced in function "public: void __thiscall CTestDlg::OnBnClickedButton2(void)" (?OnBnClickedButton2@CTestprotDlg@@QAEXXZ) TestprotDlg.obj

          L M _ 3 Replies Last reply
          0
          • J john5632

            yes, I am getting linker error 2019, 2001. error LNK2019: unresolved external symbol "void __cdecl Unload(void)" (?Unload@@YAXXZ) referenced in function "public: void __thiscall CTestDlg::OnBnClickedButton2(void)" (?OnBnClickedButton2@CTestprotDlg@@QAEXXZ) TestprotDlg.obj

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            So, in function CTestDlg::OnBnClickedButton2() you have a call to function Unload(), but the linker cannot find it. Where is function Unload() declared? [edit]I suspect that your source file should have the exctension .cpp rather than .c if this is an MFC project.[/edit]

            Unrequited desire is character building. OriginalGriff

            1 Reply Last reply
            0
            • J john5632

              yes, I am getting linker error 2019, 2001. error LNK2019: unresolved external symbol "void __cdecl Unload(void)" (?Unload@@YAXXZ) referenced in function "public: void __thiscall CTestDlg::OnBnClickedButton2(void)" (?OnBnClickedButton2@CTestprotDlg@@QAEXXZ) TestprotDlg.obj

              M Offline
              M Offline
              Maximilien
              wrote on last edited by
              #6

              Where is the "Unload" function? Is it in the file you added ? are you certain the file is compiled ?

              Watched code never compiles.

              1 Reply Last reply
              0
              • J john5632

                yes, I am getting linker error 2019, 2001. error LNK2019: unresolved external symbol "void __cdecl Unload(void)" (?Unload@@YAXXZ) referenced in function "public: void __thiscall CTestDlg::OnBnClickedButton2(void)" (?OnBnClickedButton2@CTestprotDlg@@QAEXXZ) TestprotDlg.obj

                _ Offline
                _ Offline
                _Superman_
                wrote on last edited by
                #7

                I'm assuming certain things since you're haven't shared any code with us. I assume that the Unload function is written in the .c file and its declaration is available in the corresponding .h file. Now I believe that you're calling the Unload function from a routine in a .cpp file. Since C++ compilers do name mangling, the Unload function name will be internally changed. To prevent this from happening you must include the header file within an extern "C" block.

                extern "C"
                {
                #include "my_c_header.h"
                }

                «_Superman_»  _I love work. It gives me something to do between weekends.

                _Microsoft MVP (Visual C++)

                Polymorphism in C

                1 Reply Last reply
                0
                • J john5632

                  Hi Experts, I have 2 files ( .h and .c) I added in MFC dialog based application but I am getting linker error. Is there any special thing to add .c file.

                  J Offline
                  J Offline
                  JohnNawrocki
                  wrote on last edited by
                  #8

                  Post the code.

                  John Nawrocki Chief Technical Advisor Custom Molded Products

                  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