Re: undefined reference to "..."
- From: William Pursell <bill.pursell@xxxxxxxxx>
- Date: Fri, 26 Sep 2008 21:45:48 -0700 (PDT)
On 27 Sep, 04:08, zqiang320 <zqiang...@xxxxxxxxx> wrote:
I execute make ,then get error:<snip>
libsbml/src/.libs/libsbml.so: undefined reference to `safe_strdup'<snip>
Why system can not find these function ,they are system file
<stdlib.h> <new> <cmath>
which has been included in my app.c.
What should I do?
Your questions are not about the C language, and you will
get better answers if you ask elsewhere. However, this
question indicates a fundamental misunderstanding about
header files and libraries. If a function is declared
in the header and you include that header, then the
compiler has a declaration of the function, but
the linker does not necessarily have a definition
of the function. Consider this example:
/* BROKEN CODE */
extern int foo( int );
int main( void )
{
return foo( 5 );
}
Would you expect this to build? Chances are good you'll
get an error something like:
Undefined symbols:
"_foo", referenced from:
_main in cc46tCIn.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
The situation is the same if foo is declared in foo.h and
you write:
#include <foo.h>
int main( void ) { return foo(); }
Declarations appearing in the header files have (almost)
absolutely nothing to do with the error you are seeing.
.
- References:
- undefined reference to "..."
- From: zqiang320
- undefined reference to "..."
- Prev by Date: Re: compiler could not find include *.h file
- Next by Date: Re: Highly efficient string reversal code
- Previous by thread: Re: undefined reference to "..."
- Next by thread: compiler could not find include *.h file
- Index(es):
Relevant Pages
|