This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: G++ 2.9.5 undefined reference to stdlibfunction problem.


Ross Nicoll <rnicoll@lostics.demon.co.uk> writes:
> This is probably just me being stupid, but I'm all out of ideas to fix
> this.
> 
> I have some C++ code that uses the function fdopen(). Although I have
> verified that the correct include is included, and even read the include
> by hand, g++ still claims:
> 
> log.cpp: In method `void Log::Write(char *, ...)':
> log.cpp:96: implicit declaration of function `int fdopen(...)'
> log.cpp:96: assignment to `FILE *' from `int' lacks a cast

You really need to provide some system/OS info. What system are you
running on?

Note that fdopen is NOT ANSI, but rather specified by POSIX, and some
system may require defining a preprocessor macro to access the POSIX
interfaces (eg., -D_POSIX_SOURCE).

See http://gcc.gnu.org/faq.html#bugreport for what you need to send. 

> 
> 
> If I kludge this by putting the declaration into the file by hand, it
> accepts it, until compile time, when it complains (log.cpp is part of
> libe++commerce.a BTW):
> 
> g++  -L../lib -le++commerce test.o -o test.cgi
> ../lib/libe++commerce.a: In function `Log::Write(char *,...)':
> /home/rnicoll/development/e++commerce/lib/log.cpp:96: undefined reference
> to `fdopen(int, char const *)'
> collect2: ld returned 1 exit status

You forgot to specify "C" linkpage for fdopen.
  
  extern "C" int fdopen (int, const char*);

Perhaps you ought to look at the docs for your C runtime library.

Regards,
Mumit


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]