Calling C++ functions from C project

arang1978's Avatar, Join Date: Jul 2010
Newbie Member
Hello Friends,

I need help to integrate a open source code which is written in C++ (Live555 RTSP source code) into my project which is written in C language.

I have renamed the int main (int argc, char **argv) function which is in C++ to
extern "C" int rtsp_main (int argc, char **argv)
and called it from my main () in my project which is C language.

I get a lot of error like below
playCommon.cpp:(.text+0x25c): undefined reference to `operator*(short, DelayInterval const&)'
playCommon.cpp:(.text+0x260): undefined reference to `DELAY_SECOND'
playCommon.cpp:(.text+0x298): undefined reference to `operator*(short, DelayInterval const&)'
playCommon.cpp:(.text+0x2c0): undefined reference to `operator*(short, DelayInterval const&)'
../lib//libliveMedia.a(playCommon.o): In function `main_RTSPClient':
playCommon.cpp:(.text+0x3144): undefined reference to `BasicTaskScheduler::createNew()'


If any of you let me know the easy way to use the C++ project in C project then it will be easy for me.

My e-mail ID is arang1978@gmail.com

Thanks in advance.

Regards,
Arang



0
jimblumberg's Avatar
Ambitious contributor
The error messages undefined references usually mean that you have not included all of the required
libraries.

Jim
0
arang1978's Avatar, Join Date: Jul 2010
Newbie Member
Hello Mr.Jim,

Thank you for your help. As you told me, I didn't include some libraries. I have included them now. And there is no compilation errors now.

Regards,
Arang.