0

On an ubuntu 15.10 VM I've installed pjsip so that I can work to create a very small soft phone for testing a virtual voip network.

The package includes some sample code in pjproject-2.4.5/pjsip-apps/src/samples.

When trying to compile the code using g++ or gcc I get screen full of undefined reference (sample below after running g++ pjsua2_demo.cpp -o pjsua2_demo).

Maybe a path issue?

@witsend Thanks.

/tmp/ccsTUqc5.o: In function \`MyCall::onCallState(pj::OnCallStateParam&)':
pjsua2_demo.cpp:(.text+0x3e): undefined reference to \`pj::Call::getInfo() const'
/tmp/ccsTUqc5.o: In function \`mainProg1(pj::Endpoint&)':
pjsua2_demo.cpp:(.text+0x19c): undefined reference to \`pj::Endpoint::libInit(pj::EpConfig const&)'
pjsua2_demo.cpp:(.text+0x1ab): undefined reference to \`pj::TransportConfig::TransportConfig()'
pjsua2_demo.cpp:(.text+0x1d0): undefined reference to \`pj::Endpoint::transportCreate(pjsip_transport_type_e, pj::TransportConfig const&)'
pjsua2_demo.cpp:(.text+0x1df): undefined reference to \`pj::Endpoint::libStart()'
pjsua2_demo.cpp:(.text+0x20a): undefined reference to \`pj::AccountConfig::AccountConfig()'

...

2 Answers 2

3

Your g++ command line does not actually link any of the libraries that you just installed: try

g++ pjsua2_demo.cpp -o pjsua2_demo `pkg-config --cflags --libs libpjproject`

See Building Application using PJSIP with GNU Tools

3
  • Thanks for replying. Wouldn't that happen on its own based on the #includes <*.h>?
    – J-a-n-u-s
    Dec 17, 2015 at 23:28
  • Header files just provide declarations of the objects for the compiler: to actually link the objects to form an executable program, you need to tell the linker where to find the libraries themselves: see Compiling and Linking for example Dec 17, 2015 at 23:51
  • Alright so that worked. I used the same thing to compile some of their samples in C and that worked as well (using gcc instead of g++). I'm still kind of baffled though. I understand the concept of linking from the link you gave me, but all through my software engineering degree, I don't remember ever explicitly having to tell the compiler to do that. Is it possible that gcc and g++ need that specified, and some other compilers will do it automatically?
    – J-a-n-u-s
    Dec 18, 2015 at 15:51
0

thank you very much pilot6 in my case I solve it as the following "g++ op.cpp pkg-config --cflags --libs /usr/local/lib/pkgconfig/libpjproject.pc"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .