So this is a little bit messy, however I have a single .cpp file that I want to be used in two different ways; as a c class called by a java class using JNI, and as a c program standalone. The reason for this is because this code moves around between machines and sometimes I want to just run and compile the c++ code directly as opposed to running java and having java run it. (The c++ code has a main method that is only ever ran in the standalone version).
So anyways I have the file (test.cpp) and the java source code that goes with it (test.java) in /home/user/dev/javajni/. However, I also want to be able to compile it as a standalone in /home/user/dev/standalone/. In the standalone directory I have a make file that only compiles the c program.
Anyways, when I make a hardlink to the file in javajni inside the standalone directory the makefile doesn't see it, or refuses to see the hardlink.
make: *** No rule to make target `test.cpp', needed by `test'. Stop.
And while in the standalone directory I use:
ln /home/user/dev/javajni/test.cpp test.cpp
But when I copy the entire file over it works fine.
What's the big deal? Isn't the original file in the original location technically just a hardlink to the inode as well? I just want to be able to alter the file in one location without having to copy and paste it back and forth.
If at all useful this is what my makefile looks like:
EX=test
all: $(EX)
.cpp.o:
g++ -c -O3 -Wall $<
clean:
rm -f $(EX) *.o *.a
test:test.cpp; g++ -Wall -o $@ $^
(Fyi I did change the name of the file and the directories in this post for simplification)