looking for an example on how to call a function in one program from another program and using makefile to compile them. i just need a simple example.
thank you
banging my head against the computer
looking for an example on how to call a function in one program from another program and using makefile to compile them. i just need a simple example.
thank you
banging my head against the computer
Well:
That isn't the quickest solution, though you may eventually solve it that way, if you direct your head banging to the keyboard: https://en.wikipedia.org/wiki/Infinite_monkey_theorem.
In all seriousness though, you have to be a little more clear. Do you mean calling a function in another source file? If so, that's not too bad. Posting the code and the Makefile for us could help.
If you are actually trying to invoke a function in another program, then you have a much bigger challenge. Two processes (instances of running programs) can't communicate without some OS-specific stuff. The general term for this is IPC or Inter-Process Communication, some examples being pipes, message queues, FIFOs.
EDIT:
If you have some functions that need to be used by two different programs, and you have full control over the source for both programs, you can build a library, and link each program against the one library. That allows two programs to more or less share the same code.
Here's a sample Makefile that I use e'eryday!
Code:MKFILE = Makefile GCC = gcc -g -O3 -W -Wall -Wextra -std=c11 CSOURCE = main.c tetra.c CHEADER = structures.h OBJECTS = ${CSOURCE:.c=.o} EXECBIN = tetra all : ${EXECBIN} ${EXECBIN} : ${OBJECTS} ${GCC} -o $@ ${OBJECTS} -lm %.o : %.c ${GCC} -c $< clean : - rm ${OBJECTS} ${EXECBIN} again : ${MAKE} clean all