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. Funny Error

Funny Error

Scheduled Pinned Locked Moved C / C++ / MFC
questiondebugginghelp
11 Posts 3 Posters 2 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    wincap.obj : error LNK2005: "struct HWND__ * ghWndMain" (?ghWndMain@@3PAUHWND__@@A) already defined in dllinit.obj dlgopen.obj : error LNK2001: unresolved external symbol "void * ghInst" (?ghInst@@3PAXA) Debug/asfasasfas.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. Can anyone tell me what is the error above?

    R T 2 Replies Last reply
    0
    • L Lost User

      wincap.obj : error LNK2005: "struct HWND__ * ghWndMain" (?ghWndMain@@3PAUHWND__@@A) already defined in dllinit.obj dlgopen.obj : error LNK2001: unresolved external symbol "void * ghInst" (?ghInst@@3PAXA) Debug/asfasasfas.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. Can anyone tell me what is the error above?

      R Offline
      R Offline
      Rick Benish
      wrote on last edited by
      #2

      The first error indicates that you have two objects that contain the same function definition. The second is an error that is caused by not correclty linking to the .lib file for the dll that contains this function. Hope this helps!!

      R 1 Reply Last reply
      0
      • L Lost User

        wincap.obj : error LNK2005: "struct HWND__ * ghWndMain" (?ghWndMain@@3PAUHWND__@@A) already defined in dllinit.obj dlgopen.obj : error LNK2001: unresolved external symbol "void * ghInst" (?ghInst@@3PAXA) Debug/asfasasfas.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. Can anyone tell me what is the error above?

        T Offline
        T Offline
        Tim Deveaux
        wrote on last edited by
        #3

        Oh ouch... yuck... Well, you'll have to do a bit of searching here. The LNK2005 indicates that you have more than one definition of ghWndMain. See the docs on LNK2005 for ideas. ghWndMain is declared in HOOK.C and should be extern to other modules. BTW sometimes you can use the FORCE switch to override this, but not a great idea. But hey - maybe all of this stems from the fact that you are trying to use the C++ compiler to compile the WINCAP C sample - or at least integrate into your code(?). If you are not using MFC and stuff, you might be better off using C - if there are only C files in your project, you'll see much different results. hmmm... might need an extern HINSTANCE ghInst; in dlgopen.c... BTW with C++, you might also need to use extern "C" HANDLE var; in certain places instead of just extern HANDLE var; - this will turn off the name mangling and might help. Maybe someone else has experience with this sample and using / porting it to C++.

        L 3 Replies Last reply
        0
        • R Rick Benish

          The first error indicates that you have two objects that contain the same function definition. The second is an error that is caused by not correclty linking to the .lib file for the dll that contains this function. Hope this helps!!

          R Offline
          R Offline
          Rick Benish
          wrote on last edited by
          #4

          For the First error try doing a complete "rebuild" this will delete the .obj files from your build directory and rebuild them. Sometimes this works.

          1 Reply Last reply
          0
          • T Tim Deveaux

            Oh ouch... yuck... Well, you'll have to do a bit of searching here. The LNK2005 indicates that you have more than one definition of ghWndMain. See the docs on LNK2005 for ideas. ghWndMain is declared in HOOK.C and should be extern to other modules. BTW sometimes you can use the FORCE switch to override this, but not a great idea. But hey - maybe all of this stems from the fact that you are trying to use the C++ compiler to compile the WINCAP C sample - or at least integrate into your code(?). If you are not using MFC and stuff, you might be better off using C - if there are only C files in your project, you'll see much different results. hmmm... might need an extern HINSTANCE ghInst; in dlgopen.c... BTW with C++, you might also need to use extern "C" HANDLE var; in certain places instead of just extern HANDLE var; - this will turn off the name mangling and might help. Maybe someone else has experience with this sample and using / porting it to C++.

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

            HWND ghWndMain = 0 Is the above statement correct?

            1 Reply Last reply
            0
            • T Tim Deveaux

              Oh ouch... yuck... Well, you'll have to do a bit of searching here. The LNK2005 indicates that you have more than one definition of ghWndMain. See the docs on LNK2005 for ideas. ghWndMain is declared in HOOK.C and should be extern to other modules. BTW sometimes you can use the FORCE switch to override this, but not a great idea. But hey - maybe all of this stems from the fact that you are trying to use the C++ compiler to compile the WINCAP C sample - or at least integrate into your code(?). If you are not using MFC and stuff, you might be better off using C - if there are only C files in your project, you'll see much different results. hmmm... might need an extern HINSTANCE ghInst; in dlgopen.c... BTW with C++, you might also need to use extern "C" HANDLE var; in certain places instead of just extern HANDLE var; - this will turn off the name mangling and might help. Maybe someone else has experience with this sample and using / porting it to C++.

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

              HWND ghWndMain = 0 Is the above statement correct?

              T 1 Reply Last reply
              0
              • T Tim Deveaux

                Oh ouch... yuck... Well, you'll have to do a bit of searching here. The LNK2005 indicates that you have more than one definition of ghWndMain. See the docs on LNK2005 for ideas. ghWndMain is declared in HOOK.C and should be extern to other modules. BTW sometimes you can use the FORCE switch to override this, but not a great idea. But hey - maybe all of this stems from the fact that you are trying to use the C++ compiler to compile the WINCAP C sample - or at least integrate into your code(?). If you are not using MFC and stuff, you might be better off using C - if there are only C files in your project, you'll see much different results. hmmm... might need an extern HINSTANCE ghInst; in dlgopen.c... BTW with C++, you might also need to use extern "C" HANDLE var; in certain places instead of just extern HANDLE var; - this will turn off the name mangling and might help. Maybe someone else has experience with this sample and using / porting it to C++.

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

                I need to enquire whether C complier can complier win32 api source code? If it does , will the resulting .exe ba able to be used in win98 as win98 is win32 ?

                L 2 Replies Last reply
                0
                • L Lost User

                  HWND ghWndMain = 0 Is the above statement correct?

                  T Offline
                  T Offline
                  Tim Deveaux
                  wrote on last edited by
                  #8

                  #pragma data_seg("._WINCAP") HWND ghWndMain = 0; // Handle to main window -- used to post msgs #pragma data_seg() Sure - but looks like 16 bit code with that pragma... not to worry, though, should compile... But the wincap sample is pretty dated - old 16 bit code. There should also be a DIBAPI project or makefile - can you compile that? You'll need it. I think what you're trying to do is use the WINCAP sample source directly in a cpp based project, and thats gonna be a bit of a hack. Even though you're getting close. :) I don't have WINCAP.EXE, so don't know exactly what you're up against, and it makes it tough to help.

                  L 1 Reply Last reply
                  0
                  • L Lost User

                    I need to enquire whether C complier can complier win32 api source code? If it does , will the resulting .exe ba able to be used in win98 as win98 is win32 ?

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

                    I encountered any 'funny' error on viewing the earlier error , i made one change to the code. The change is shown below : #pragma data_seg("._WINCAP") // HWND ghWndMain = 0 ; // Handle to main window -- used to post msgs #pragma data_seg() // IThe change is that i made the statement " HWND ghWndMain = 0 " a comment , therafter i was able to generate an exe . However when i click the exe i see this a windows which only show the background and no menu buttons can be seen.

                    1 Reply Last reply
                    0
                    • L Lost User

                      I need to enquire whether C complier can complier win32 api source code? If it does , will the resulting .exe ba able to be used in win98 as win98 is win32 ?

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

                      I encountered any 'funny' error on viewing the earlier error , i made one change to the code. The change is shown below : #pragma data_seg("._WINCAP") // HWND ghWndMain = 0 ; // Handle to main window -- used to post msgs #pragma data_seg() // IThe change is that i made the statement " HWND ghWndMain = 0 " a comment , therafter i was able to generate an exe . However when i click the exe i see this a windows which only show the background and no menu buttons can be seen.

                      1 Reply Last reply
                      0
                      • T Tim Deveaux

                        #pragma data_seg("._WINCAP") HWND ghWndMain = 0; // Handle to main window -- used to post msgs #pragma data_seg() Sure - but looks like 16 bit code with that pragma... not to worry, though, should compile... But the wincap sample is pretty dated - old 16 bit code. There should also be a DIBAPI project or makefile - can you compile that? You'll need it. I think what you're trying to do is use the WINCAP sample source directly in a cpp based project, and thats gonna be a bit of a hack. Even though you're getting close. :) I don't have WINCAP.EXE, so don't know exactly what you're up against, and it makes it tough to help.

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

                        hi Tim will it be okie if i sent you the whole project because i really dun know how to solve my problems. If it is okie i send it to you to your email account?

                        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