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. can't compile my codes...pls help

can't compile my codes...pls help

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++debuggingquestion
9 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.
  • U Offline
    U Offline
    User 2080501
    wrote on last edited by
    #1

    I have recently tried incorporating someone's codes into my codes in visual c++. However their codes are in C. Anyway I have just added their .C and .H files into my project workspace and called one of their functions in my main program. I am unable to cmpile due to the error below: regis.obj : error LNK2001: unresolved external symbol "struct Coordinates __cdecl findRotationMatrix(struct Coordinates)" (?findRotationMatrix@@YA?AUCoordinates@@U1@@Z) Debug/regis.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. I understand that the compiler is looking for a library file but the problem is the codes i downloaded only came with the .C and .H file. If i am not wrong, the original codes were compiled successfuly in gcc. Is this a compatability problem?

    C K T 3 Replies Last reply
    0
    • U User 2080501

      I have recently tried incorporating someone's codes into my codes in visual c++. However their codes are in C. Anyway I have just added their .C and .H files into my project workspace and called one of their functions in my main program. I am unable to cmpile due to the error below: regis.obj : error LNK2001: unresolved external symbol "struct Coordinates __cdecl findRotationMatrix(struct Coordinates)" (?findRotationMatrix@@YA?AUCoordinates@@U1@@Z) Debug/regis.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. I understand that the compiler is looking for a library file but the problem is the codes i downloaded only came with the .C and .H file. If i am not wrong, the original codes were compiled successfuly in gcc. Is this a compatability problem?

      C Offline
      C Offline
      Cillieacc0rd5o4
      wrote on last edited by
      #2

      findRotationMatrix is this declared in .h ?

      R T 2 Replies Last reply
      0
      • C Cillieacc0rd5o4

        findRotationMatrix is this declared in .h ?

        R Offline
        R Offline
        Ravi Bhavnani
        wrote on last edited by
        #3

        It must be - he didn't encounter any compilation errors. Looks like he's missing a library. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

        T 1 Reply Last reply
        0
        • C Cillieacc0rd5o4

          findRotationMatrix is this declared in .h ?

          T Offline
          T Offline
          ThatsAlok
          wrote on last edited by
          #4

          Cillieacc0rd5o4 wrote: findRotationMatrix is this declared in .h ? Yeap,It's declared in .h File as there is no compiler error i.e. Function was found in Header file while compiling but since linker throw the error, it's seem that it enable to get DEFINATION of findRotationMatix function

          "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

          cheers, Alok Gupta

          1 Reply Last reply
          0
          • R Ravi Bhavnani

            It must be - he didn't encounter any compilation errors. Looks like he's missing a library. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

            T Offline
            T Offline
            ThatsAlok
            wrote on last edited by
            #5

            Ravi Bhavnani wrote: Looks like he's missing a library Oops, you are very FAST :)

            "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

            cheers, Alok Gupta

            1 Reply Last reply
            0
            • U User 2080501

              I have recently tried incorporating someone's codes into my codes in visual c++. However their codes are in C. Anyway I have just added their .C and .H files into my project workspace and called one of their functions in my main program. I am unable to cmpile due to the error below: regis.obj : error LNK2001: unresolved external symbol "struct Coordinates __cdecl findRotationMatrix(struct Coordinates)" (?findRotationMatrix@@YA?AUCoordinates@@U1@@Z) Debug/regis.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. I understand that the compiler is looking for a library file but the problem is the codes i downloaded only came with the .C and .H file. If i am not wrong, the original codes were compiled successfuly in gcc. Is this a compatability problem?

              K Offline
              K Offline
              krmed
              wrote on last edited by
              #6

              I believe your problem is that the function you're trying to use is in the .c file, and you're calling it from the .cpp file. The compiler doesn't decorate names from the .c file, but it does decorate them from the .cpp. That why it appears to be calling: glycemia wrote: findRotationMatrix(struct Coordinates)" (?findRotationMatrix@@YA?AUCoordinates@@U1@@Z) In the header file for the function (the header that goes with the .c file) you should place the following: At the top of the header file #if defined(__cplusplus) extern "C" { #endif Then put the rest of the header file in here. and then at the bottom of the same header file: #if defined(__cplusplus) } #endif That should resolve your problem. Good luck. Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

              U 1 Reply Last reply
              0
              • U User 2080501

                I have recently tried incorporating someone's codes into my codes in visual c++. However their codes are in C. Anyway I have just added their .C and .H files into my project workspace and called one of their functions in my main program. I am unable to cmpile due to the error below: regis.obj : error LNK2001: unresolved external symbol "struct Coordinates __cdecl findRotationMatrix(struct Coordinates)" (?findRotationMatrix@@YA?AUCoordinates@@U1@@Z) Debug/regis.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. I understand that the compiler is looking for a library file but the problem is the codes i downloaded only came with the .C and .H file. If i am not wrong, the original codes were compiled successfuly in gcc. Is this a compatability problem?

                T Offline
                T Offline
                toxcct
                wrote on last edited by
                #7

                but did you think to #include the header whenever you imported them into your project ?


                TOXCCT >>> GEII power
                [toxcct][VisualCalc]

                1 Reply Last reply
                0
                • K krmed

                  I believe your problem is that the function you're trying to use is in the .c file, and you're calling it from the .cpp file. The compiler doesn't decorate names from the .c file, but it does decorate them from the .cpp. That why it appears to be calling: glycemia wrote: findRotationMatrix(struct Coordinates)" (?findRotationMatrix@@YA?AUCoordinates@@U1@@Z) In the header file for the function (the header that goes with the .c file) you should place the following: At the top of the header file #if defined(__cplusplus) extern "C" { #endif Then put the rest of the header file in here. and then at the bottom of the same header file: #if defined(__cplusplus) } #endif That should resolve your problem. Good luck. Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

                  U Offline
                  U Offline
                  User 2080501
                  wrote on last edited by
                  #8

                  Thank you so much for your help....your suggestion has solved my problem.... Does this mean I should convert the .c file into .cpp file in the future? Thanks for all your help guys!!

                  K 1 Reply Last reply
                  0
                  • U User 2080501

                    Thank you so much for your help....your suggestion has solved my problem.... Does this mean I should convert the .c file into .cpp file in the future? Thanks for all your help guys!!

                    K Offline
                    K Offline
                    krmed
                    wrote on last edited by
                    #9

                    Not necessarily. It is your choice, but you may run into other problems by converting it to .cpp. If you're using mfc, you'll need to add the stdafx.h header, a wrapper to prevent multiple inclusions would be a good idea, etc. Unless there's a compelling reason to change it to .cpp, then I'd just leave it like it is. The software I work on (a suite of 38 applications and 18 dlls) has one module that is shared with a unix-based hardware component, and that has to be in c, so we just have the one module in c. Glad I could be of help. Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

                    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