I followed the ways mentioned in Link object file to my project Eclipse CDR
My main function is in cpp code and from that I wish to call a c-function. So for that I created the object file (.o) from the c-code using
gcc -c -fpic mycode.c
This gave me a ".o" file which I wanted to link to the cpp code. I created a header file with reference to http://www.parashift.com/c++-faq/include-c-hdrs-nonsystem.html
Header file was declared as an extern in my cpp code. The header file contains to function from the c-code, that function was declared as an extern in header file.
After doing this when I do make for my entire project I am getting error as "undefined reference" to that c-function name
来源:https://stackoverflow.com/questions/25866628/adding-object-file-to-cpp-code-in-eclipse