Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
250 views
in Technique[技术] by (71.8m points)

c++ - Adding object file to cpp code in eclipse

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...