When I try t compile my program I have this error
undefined reference to `printfHello'
I make a simple program, with three files hello.c, hello1.c and hello.h
hello1.c:
#include <stdint.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
void printfHello() {
printf("Hello");
}
hello1.h
void printfHello();
hello.c
#include <stdint.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include "hello1.h"
int main() {
int errn=0;
printfHello();
return errn;
}
And I have a Makefile.am
bin_PROGRAMS = client_ev
AM_CPPFLAGS = \
-I$(top_srcdir)/include \
-I$(top_builddir)/include
# $(some_CFLAGS)
EXTRA_DIST = \
autogen.sh
MAINTAINERCLEANFILES = \
configure \
aclocal.m4 \
Makefile.in
client_ev_SOURCES = hello.c hello1.c
If I do ---> cc hello.c -o hello.c hello1.c . It works fine.
I need to define something else in the makefile.am file?
Thanks.
You have not defined the function printfHello() in any of the file. Please first define that function first like
void printfHello()
{
printf("Hello\n");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With