I am trying to install a C software and then make a test program that uses it.
The software consists of three files:
- x-as-func.c
- x-as-func.h
- y.h (this has only define statements)
- the executable x
In the makefile I have a "install" command as:
.PHONY: install
install: all
cp ./include/x-as-func.h /usr/local/include/x.h
cp ./include/y.h /usr/local/include/y.h
cp ./x /usr/local/bin/x
When I do "sudo make install" everything runs fine and the files are copied as expected.
However when I compile the test program that looks like:
test.c
#include "hubo-read-trajectory-as-func.h"
int main(){
char* s ="left_elbow.txt";
someFunctionDefinedInX(s, 0, false, false);
}
I get error:
gcc -o test test.c -include //usr/local/include/x.h
/tmp/cc6ru89m.o: In function `main':
test.c:(.text+0x27): undefined reference to `someFunctionDefinedInX'
collect2: ld returned 1 exit status
Or if I do -ld then I get
gcc -o test random-test.c -ld x.h
gcc: error: x.h: No such file or directory
I believe that the header files and the executables are not getting linked? Am I right? How should I correct this?