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

Re: Include files?

OK.  Things are improving.  I added "-D_GNU_SOURCE" and now I only had
problems during link time w/ errno.
I added "#include <errno.h>.  At link time I get the following error:

rs485_io.o: In function `rs485_io::write(unsigned char *, int)':
rs485_io.o(.text+0x2d4): undefined reference to `__errno_location(void)'
collect2: ld returned 1 exit status
make: *** [rs485] Error 1

I had an "extern int errno" which I removed, curing my last error.


Adam Felson
HID Corporation - Engineering
11674 N. Huron Street
Denver, CO 80234-2924
(303) 453-3362

                    Hans-Peter Nilsson                                                                
                    <hans-peter.nilsson        To:     afelson@xxxxxxx.com                               
                    Sent by:                   Subject:     Re: Include files?                        
                    07/02/01 10:36 AM                                                                 

> From: Adam Felson <afelson@xxxxxxx.com>
> Date: Mon, 2 Jul 2001 09:29:50 -0600

> The compile command is:
> g++-cris -mlinux -xc++ -isystem
> -Wall -O2 -DELINUX -Wall -I../include -Wno-ctor-dtor-privacy -ansi -pipe
> -c -o rs485_io.o rs485_io.cc

Lose -ansi *or* add -D_GNU_SOURCE to make the prototypes for
usleep and cfmakeraw visible.

I can't understand why errno is undeclared.  How does your
#include lines look like?  Is there an errno.h in ../include?

I tried this silly example (with #includes as per your earlier
mail), which compiles without warnings or errors with the listed
options (but with /home/felson tweaked for the local setup)
either adding -D_GNU_SOURCE or losing -ansi:

#include <stdio.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <stdlib.h>
#include <termios.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/wait.h>
#include <sys/stat.h>
#include <signal.h>
#include <errno.h>
#include <stdlib.h>

#include <iostream.h>

class rs485_io
  rs485_io::rs485_io(char *, int);
  void doit(struct termios *);

rs485_io::rs485_io(char *x, int y)
  usleep (y);
  cout << x << errno << endl;

void rs485_io::doit(struct termios *x)
  cfmakeraw (x);

int main ()
  rs485_io io("Hello, world!", 42);

  io.doit (NULL);

> This all started with R2.0.0;  there were no compile errors for R1.0.0

Since it's a whole different runtime library, I wouldn't be too
surprised that some re-(or un-)tweaks are needed here and there
for things which were tweaked to work with uclibc.

If your program also works in your host environment, I'd just
try and remove defines and such that you add for devboard_lx.
Perhaps that -DELINUX makes a difference.

brgds, H-P