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. Compiling a Parser Generator generated file causes linker errors

Compiling a Parser Generator generated file causes linker errors

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
10 Posts 3 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.
  • M Offline
    M Offline
    Manfr3d
    wrote on last edited by
    #1

    Hello guys, I'm trying to build a simple lexical analyzer with Parser Generator 2. I wrote a Lex and a Yacc file and built a *.c and a *.h file with them. As I tried to compile this files I got strange linker errors: error LNK2019: unresolved external symbol _yywclex referenced in function _yywgettoken error LNK2019: unresolved external symbol _yywcparse referenced in function _main fatal error LNK1120: 2 unresolved externals What can I do against this errors, or do I have to use another compiler? Thanks and best wishes.

    R B 2 Replies Last reply
    0
    • M Manfr3d

      Hello guys, I'm trying to build a simple lexical analyzer with Parser Generator 2. I wrote a Lex and a Yacc file and built a *.c and a *.h file with them. As I tried to compile this files I got strange linker errors: error LNK2019: unresolved external symbol _yywclex referenced in function _yywgettoken error LNK2019: unresolved external symbol _yywcparse referenced in function _main fatal error LNK1120: 2 unresolved externals What can I do against this errors, or do I have to use another compiler? Thanks and best wishes.

      R Offline
      R Offline
      rp_suman
      wrote on last edited by
      #2

      Hi, Check if your functions are having same data type for the arguments in header file and c file Also see if you are having those functions definitions with declaration in header file or forward declaration in C file. Thanks, Suman

      -- "Programming is an art that fights back!"

      M 1 Reply Last reply
      0
      • R rp_suman

        Hi, Check if your functions are having same data type for the arguments in header file and c file Also see if you are having those functions definitions with declaration in header file or forward declaration in C file. Thanks, Suman

        -- "Programming is an art that fights back!"

        M Offline
        M Offline
        Manfr3d
        wrote on last edited by
        #3

        All the function definitions are in the main file defined with prototypes, so I don't think it's something to do with them.

        R 1 Reply Last reply
        0
        • M Manfr3d

          All the function definitions are in the main file defined with prototypes, so I don't think it's something to do with them.

          R Offline
          R Offline
          rp_suman
          wrote on last edited by
          #4

          You make sure you have included all the headers you needed in c file and any libraries if needed. Also, all the files you have created are added to your project. And check if the path of included headers are correct. Thanks, Suman

          -- "Programming is an art that fights back!"

          M 1 Reply Last reply
          0
          • R rp_suman

            You make sure you have included all the headers you needed in c file and any libraries if needed. Also, all the files you have created are added to your project. And check if the path of included headers are correct. Thanks, Suman

            -- "Programming is an art that fights back!"

            M Offline
            M Offline
            Manfr3d
            wrote on last edited by
            #5

            I don't get any errors about libraries or headers that aren't found. So I think the pathes are correct.

            1 Reply Last reply
            0
            • M Manfr3d

              Hello guys, I'm trying to build a simple lexical analyzer with Parser Generator 2. I wrote a Lex and a Yacc file and built a *.c and a *.h file with them. As I tried to compile this files I got strange linker errors: error LNK2019: unresolved external symbol _yywclex referenced in function _yywgettoken error LNK2019: unresolved external symbol _yywcparse referenced in function _main fatal error LNK1120: 2 unresolved externals What can I do against this errors, or do I have to use another compiler? Thanks and best wishes.

              B Offline
              B Offline
              Bram van Kampen
              wrote on last edited by
              #6

              Hi Without being funny, you have to do something all of us do most of the time, It's called debugging. You wrote the code, You know what's in it. And you Need to know what's in it!! As a Hint, it seems your linker missed a lib. Find out which one, and write: #pragma comment(lib,"MyMissing.Lib");

              Bram van Kampen

              M 1 Reply Last reply
              0
              • B Bram van Kampen

                Hi Without being funny, you have to do something all of us do most of the time, It's called debugging. You wrote the code, You know what's in it. And you Need to know what's in it!! As a Hint, it seems your linker missed a lib. Find out which one, and write: #pragma comment(lib,"MyMissing.Lib");

                Bram van Kampen

                M Offline
                M Offline
                Manfr3d
                wrote on last edited by
                #7

                I already tried debugging the project, but I just got the message that something is wrong with the linker.

                B 1 Reply Last reply
                0
                • M Manfr3d

                  I already tried debugging the project, but I just got the message that something is wrong with the linker.

                  B Offline
                  B Offline
                  Bram van Kampen
                  wrote on last edited by
                  #8

                  Well, The functions yywclex(??) and yywcparse(??) have been declared, are being used in the stated modules, but have not been defined. That's why the linker cannot find them. Do a text search for these functions. If you cannot find a definition for them there may be something wrong with your generator. an other possibility is that you were supposed to write those yourself. Check the documentation for YACC. Thirdly, Is there a bug in your rules script, which results in YACC not generating those functions. It is unlikely that there is something wrong with your linker. Also, because the code is in 'C', errors in type declarations may cause a run time issue, but will not be found by the linker. The functions: 'int f(int)' and 'int f(char,char) are both mangled to '_f' by the compiler. Hope this helps :)

                  Bram van Kampen

                  M 1 Reply Last reply
                  0
                  • B Bram van Kampen

                    Well, The functions yywclex(??) and yywcparse(??) have been declared, are being used in the stated modules, but have not been defined. That's why the linker cannot find them. Do a text search for these functions. If you cannot find a definition for them there may be something wrong with your generator. an other possibility is that you were supposed to write those yourself. Check the documentation for YACC. Thirdly, Is there a bug in your rules script, which results in YACC not generating those functions. It is unlikely that there is something wrong with your linker. Also, because the code is in 'C', errors in type declarations may cause a run time issue, but will not be found by the linker. The functions: 'int f(int)' and 'int f(char,char) are both mangled to '_f' by the compiler. Hope this helps :)

                    Bram van Kampen

                    M Offline
                    M Offline
                    Manfr3d
                    wrote on last edited by
                    #9

                    I solved this problem by rebuilding all the library files which are included. Now there's just one erroe left, but I don't thnk that this one has something to do with VC++, but with the lexer and parser generator I'm using.

                    B 1 Reply Last reply
                    0
                    • M Manfr3d

                      I solved this problem by rebuilding all the library files which are included. Now there's just one erroe left, but I don't thnk that this one has something to do with VC++, but with the lexer and parser generator I'm using.

                      B Offline
                      B Offline
                      Bram van Kampen
                      wrote on last edited by
                      #10

                      Well, at least you're getting a handle on things. Gives a good feeling though, doesn't it. Regards, :) :)

                      Bram van Kampen

                      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