# calling functions in C



## saaba (Jul 6, 2005)

I need to call a function from a differenct C program
I have made a header file which includes the function declartion
but still when i compile i get undefined symbol error...
ru supposed to compile it in a specific way to make sure the symbol is recognized

***I am calling a clientfunc function in client****

HEADERFILE:
void extern start_client(char *);

CLIENTFUNC:
#include "clientfuncexterns.h"
void start_client(char*){
.......}

CLIENT:
#include "clientfuncexterns.h"
start_client(char *)

MAKEFILE:
clientfunc: clientfunc.o
cc -o clientfunc clientfunc.c -lnsl -lsocket
client: client.o
cc -o client client.c -lnsl -lsocket


----------



## ricer333 (Sep 17, 2004)

*Missing Parameters*

Well, I'm no C expert (Java kinda guy) but if what you've put up is pretty much copied from your code, then you have no PARAMETERS defined in your files (both .h and .c).

Your Post:
HEADERFILE:
void extern start_client(char *);

CLIENTFUNC:
#include "clientfuncexterns.h"
void start_client(char*){
.......}

CLIENT:
#include "clientfuncexterns.h"
start_client(char *)

@@@@@@@@@@@@@@@@@@@@

HEADERFILE:
void extern start_client(char * PARAM);

CLIENTFUNC:
#include "clientfuncexterns.h"
void start_client(char* PARAM){
.......}

CLIENT:
#include "clientfuncexterns.h"
start_client(char * PARAM)

@@@@@@@@@@@@@@@@@@@@

where you would use the PARAM in the {....}. Now maybe you already have this and just didn't post it. Let me know.


----------



## LoneWolf071 (Nov 10, 2004)

he's right, you can't just have the variable undefined when calling it...

HEADERFILE:
void extern start_client(char *);

CLIENTFUNC:
#include "clientfuncexterns.h"
void start_client(char*){
.......}

CLIENT:
#include "clientfuncexterns.h"
start_client(char <Variable>)

You Have To Have The Variale DEfined in the actual function...


----------



## saaba (Jul 6, 2005)

i had the vars defined..just didn't post them here..
actually i wasn't linking the files properly into one exec...
anywayz thanks for ur help got rid of the prob.


----------

