Huge amount of undefined references when compiling pjsip / pjsua samples

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?


/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()'

Asked By: J-a-n-u-s


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

Answered By: steeldriver

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"

Answered By: user1705503
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.