help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bison linking error


From: Tim Van Holder
Subject: Re: bison linking error
Date: Wed, 16 Jul 2003 16:15:39 +0200

> am getting a linking error in regards to the mdx_parse 
> function, where mdx is the prefix I used to replace yy. The 

I assume your prefix is actually 'mdx_'; otherwise the parser
would be mdxparse(), not mdx_parse().

> mdxparse.obj : error LNK2001: unresolved external symbol "int 
> __cdecl mdx_parse(void *)" (?mdx_parse@@address@hidden)

This suggests you have not used extern "C" when declaring the
parser function in a C++ source file.
mdx_parse() is a C function from a C source file; the linker is
trying to find a C++ function of the same name (albeit with C
calling convention).  Try using

  extern "C" int mdxparse(void*);

instead of

  int mdxparse(void*);

when declaring the function.
Note: you may want to use the %lex-param/%parse-param directives
to avoid using an ugly void* as param. See the bison manual for
more information.

Note that this is a basic C++ problem, not a bison issue.  What's
more, simply checking your compiler's documentation would have
presented the solution (the fragment below is from the VS.NET 2003
docs, but I assume VC++6 has similar stuff (LNK2001 in topic index)).

Linker Tools Error LNK2001

unresolved external symbol "symbol"

Code references something (such as a function, variable, or label)
that the linker can't find in the libraries and object files.

_Possible causes_

* What the code asks for doesn't exist (the symbol is spelled
  incorrectly or uses the wrong case, for example). 
* The code asks for the wrong thing (you are using mixed versions of
  the libraries, some from one version of the product, others from
  another version).

This error message is followed by fatal error LNK1120.

_Specific causes - Coding Problems_

Calling a C function from a C++ program without using extern "C"
(which causes the compiler to use the C naming convention) can cause
LNK2001.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]