I am trying to execute basic code in C and C++ in Linux environment. I am using eclipse to run it. Current project is created as C project.
All I am trying to do is to call a function from different file in same folder.
I have my main in sample.c
, In main I would like to call function sum(int a, int b)
in A.c
. I was able to run it. But when I rewrite same function sum in A.cpp
(a C++ template file) it throws linker error.
gcc -o "Test" ./sample.o
./sample.o: In function main':/home/idtech/workspace/Test/Debug/../sample.c:19: undefined reference to sum' collect2: ld returned 1 exit status make: * [Test] Error 1
I need help in calling functions in C++ file from C file in same folder. Please help me to solve this linker issue.
Thanks
Harsha