twintriode
Technical User
Hi All -
Have been trying to get this code running. It is the first example in on this page:
I keep getting the error:
Can anybody tell me what I am doing wrong here??
Thanks
Have been trying to get this code running. It is the first example in on this page:
Code:
#include <stdio.h> /* Standard input/output definitions */
#include <string.h> /* String function definitions */
#include <unistd.h> /* UNIX standard function definitions */
#include <fcntl.h> /* File control definitions */
#include <errno.h> /* Error number definitions */
#include <termios.h> /* POSIX terminal control definitions */
/*
* 'open_port()' - Open serial port 1.
*
* Returns the file descriptor on success or -1 on error.
*/
int
open_port(void)
{
int fd; /* File descriptor for the port */
fd = open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NDELAY);
if (fd == -1)
{
/*
* Could not open the port.
*/
perror("open_port: Unable to open /dev/ttyS0 - ");
}
else
cntl(fd, F_SETFL, 0);
return (fd);
}
I keep getting the error:
Code:
# gcc -o 88 88.c
/usr/lib/gcc/i686-pc-linux-gnu/3.4.6/../../../crt1.o: In function `_start':
init.c:(.text+0x18): undefined reference to `main'
/tmp/ccgPNr2v.o: In function `open_port':
88.c:(.text+0x48): undefined reference to `cntl'
collect2: ld returned 1 exit status
Can anybody tell me what I am doing wrong here??
Thanks