unresolved external symbol due to wrong lib or due to using c in c++ ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I have this code:

#include <pjsua2.hpp>
#include <iostream>
using namespace pj;
// Subclass to extend the Account and get notifications etc.
class MyCall : public Call
{
??? public:
??? ??? MyCall(Account &acc, int call_id = PJSUA_INVALID_ID): Call(acc, call_id){ }
??? ??? ~MyCall(){ }
??? ??? // Notification when call?s state has changed.
??? ??? virtual void onCallState(OnCallStateParam &prm);
??? ??? // Notification when call?s media state has changed.
??? ??? virtual void onCallMediaState(OnCallMediaStateParam &prm);
};
extern "C" class MyAccount : public Account 
{
??? //MyAccount() {}
??? //~MyAccount() {}
??? public:
??? ??? virtual void onRegState(OnRegStateParam &prm) 
??? ??? {
??? ??? ??? AccountInfo ai = getInfo();
??? ??? ??? std::cout << (ai.regIsActive? "*** Register:" : "*** Unregister:")
??? ??? ??? << " code=" << prm.code << std::endl;
??? ??? }
??? ??? virtual void onIncomingCall(OnIncomingCallParam &iprm)
??? ??? {
??? ??? ??? Call *call = new MyCall(*this, iprm.callId);
??? ??? ??? AudioMediaPlayer player;
??? ??? ??? AudioMedia& play_med = Endpoint::instance().audDevManager().getPlaybackDevMedia();
??? ??? ??? try {
??? ??? ??? ??? player.createPlayer("file.wav", PJMEDIA_FILE_NO_LOOP);
??? ??? ??? ??? player.startTransmit(play_med);
??? ??? ??? ????? } 
??? ??? ??? catch(Error& err)
??? ??? ??? ?{
??? ??? ??? ??? std::cout << "Player creation error: " << err.info() << std::endl;
??? ??? ??? ?}
??? ??? ??? pj_thread_sleep(1000);
??? ??? ??? try {
??? ??? ??? ??? player.stopTransmit(play_med);
??? ??? ????????????????????? }
??? ??? ??? ?catch(Error& err)
??? ??? ??? ?{
??? ??? ??? ??? std::cout << "Error in Stoping Play Transmit: " << err.info() << std::endl;
??? ??? ??? }
??? ??? ??? // Just hangup for now
??? ??? ??? CallOpParam op;
??? ??? ??? op.statusCode = PJSIP_SC_DECLINE;
??? ??? ??? call->hangup(op);
??? ??? ??? delete call;
??? ??? }
};
int main()
{

??? Endpoint ep;
??? ep.libCreate();
??? // Initialize endpoint
??? EpConfig ep_cfg;
??? ep.libInit( ep_cfg );

??? // Create SIP transport. Error handling sample is shown
??? TransportConfig tcfg;
??? tcfg.port = 5060;
??? try 
??? {
??? ??? ep.transportCreate(PJSIP_TRANSPORT_UDP, tcfg);
??? } 
??? catch (Error &err) 
??? {
??? ??? std::cout << err.info() << std::endl;
??? ??? return 1;
??? }
??? // Start the library (worker threads etc)
??? ep.libStart();
??? std::cout << "*** PJSUA2 STARTED ***" << std::endl;
??? // Configure an AccountConfig
??? AccountConfig acfg;
??? acfg.idUri = "sip:test at pjsip.org";
??? acfg.regConfig.registrarUri = "sip:pjsip.org";
??? AuthCredInfo cred("digest", "*", "test", 0, "secret");
??? acfg.sipConfig.authCreds.push_back( cred );
??? // Create the account
??? MyAccount *acc = new MyAccount;
??? try
??? {
??? ??? acc->create(acfg);
??? }
??? catch(Error& err) 
??? {
??? ??? std::cout << "Account creation error: " << err.info() << std::endl;
??? }
??? // Here we don?t have anything else to do..
??? pj_thread_sleep(10000);
??? // Delete the account. This will unregister from server
??? delete acc;
??? // This will implicitly shutdown the library
??? return 0;
}


This is from the c++ example explained in http://www.pjsip.org/docs/book-latest/PJSUA2Doc.pdf


I add the include the libs , but I could not add the references seen in the Image uploaded



but I compling I get the following? errors :


1>MAIN.obj : error LNK2001: unresolved external symbol "public: __thiscall pj::TransportConfig::TransportConfig(void)" (??0TransportConfig at pj@@QAE at XZ)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall pj::EpConfig::writeObject(class pj::ContainerNode &)const " (?writeObject at EpConfig@pj@@UBEXAAVContainerNode at 2@@Z)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall pj::EpConfig::readObject(class pj::ContainerNode const &)" (?readObject at EpConfig@pj@@UAEXABVContainerNode at 2@@Z)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: __thiscall pj::MediaConfig::MediaConfig(void)" (??0MediaConfig at pj@@QAE at XZ)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: __thiscall pj::AccountConfig::AccountConfig(void)" (??0AccountConfig at pj@@QAE at XZ)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: __thiscall pj::CallOpParam::CallOpParam(bool)" (??0CallOpParam at pj@@QAE at _N@Z)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: class pj::AudDevManager & __thiscall pj::Endpoint::audDevManager(void)" (?audDevManager at Endpoint@pj@@QAEAAVAudDevManager at 2@XZ)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: int __thiscall pj::Endpoint::transportCreate(enum pjsip_transport_type_e,struct pj::TransportConfig const &)" (?transportCreate at Endpoint@pj@@QAEHW4pjsip_transport_type_e@@ABUTransportConfig at 2@@Z)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: void __thiscall pj::Endpoint::libStart(void)" (?libStart at Endpoint@pj@@QAEXXZ)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: void __thiscall pj::Endpoint::libInit(struct pj::EpConfig const &)" (?libInit at Endpoint@pj@@QAEXABUEpConfig at 2@@Z)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: void __thiscall pj::Endpoint::libCreate(void)" (?libCreate at Endpoint@pj@@QAEXXZ)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall pj::Endpoint::~Endpoint(void)" (??1Endpoint at pj@@UAE at XZ)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: __thiscall pj::Endpoint::Endpoint(void)" (??0Endpoint at pj@@QAE at XZ)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: static class pj::Endpoint & __cdecl pj::Endpoint::instance(void)" (?instance at Endpoint@pj@@SAAAV12 at XZ)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall pj::AuthCredInfo::writeObject(class pj::ContainerNode &)const " (?writeObject at AuthCredInfo@pj@@UBEXAAVContainerNode at 2@@Z)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall pj::AuthCredInfo::readObject(class pj::ContainerNode const &)" (?readObject at AuthCredInfo@pj@@UAEXABVContainerNode at 2@@Z)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: __thiscall pj::AuthCredInfo::AuthCredInfo(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,int,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (??0AuthCredInfo at pj@@QAE at ABV?$basic_string at DU?$char_traits at D@std@@V?$allocator at D@2@@std@@00HV23@@Z)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: __thiscall pj::LogConfig::LogConfig(void)" (??0LogConfig at pj@@QAE at XZ)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __thiscall pj::Error::info(bool)const " (?info at Error@pj@@QBE?AV?$basic_string at DU?$char_traits at D@std@@V?$allocator at D@2@@std@@_N at Z)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall pj::AudioMediaPlayer::~AudioMediaPlayer(void)" (??1AudioMediaPlayer at pj@@UAE at XZ)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: void __thiscall pj::AudioMediaPlayer::createPlayer(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,unsigned int)" (?createPlayer at AudioMediaPlayer@pj@@QAEXABV?$basic_string at DU?$char_traits at D@std@@V?$allocator at D@2@@std@@I at Z)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: __thiscall pj::AudioMediaPlayer::AudioMediaPlayer(void)" (??0AudioMediaPlayer at pj@@QAE at XZ)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: class pj::AudioMedia & __thiscall pj::AudDevManager::getPlaybackDevMedia(void)" (?getPlaybackDevMedia at AudDevManager@pj@@QAEAAVAudioMedia at 2@XZ)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: __thiscall pj::UaConfig::UaConfig(void)" (??0UaConfig at pj@@QAE at XZ)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: void __thiscall pj::Call::hangup(struct pj::CallOpParam const &)" (?hangup at Call@pj@@QAEXABUCallOpParam at 2@@Z)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall pj::Call::~Call(void)" (??1Call at pj@@UAE at XZ)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: __thiscall pj::Call::Call(class pj::Account &,int)" (??0Call at pj@@QAE at AAVAccount@1 at H@Z)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: struct pj::AccountInfo __thiscall pj::Account::getInfo(void)const " (?getInfo at Account@pj@@QBE?AUAccountInfo at 2@XZ)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: void __thiscall pj::Account::create(struct pj::AccountConfig const &,bool)" (?create at Account@pj@@QAEXABUAccountConfig at 2@_N at Z)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall pj::Account::~Account(void)" (??1Account at pj@@UAE at XZ)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: __thiscall pj::Account::Account(void)" (??0Account at pj@@QAE at XZ)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: void __thiscall pj::AudioMedia::stopTransmit(class pj::AudioMedia const &)const " (?stopTransmit at AudioMedia@pj@@QBEXABV12@@Z)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: void __thiscall pj::AudioMedia::startTransmit(class pj::AudioMedia const &)const " (?startTransmit at AudioMedia@pj@@QBEXABV12@@Z)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall MyCall::onCallMediaState(struct pj::OnCallMediaStateParam &)" (?onCallMediaState at MyCall@@UAEXAAUOnCallMediaStateParam at pj@@@Z)
1>MAIN.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall MyCall::onCallState(struct pj::OnCallStateParam &)" (?onCallState at MyCall@@UAEXAAUOnCallStateParam at pj@@@Z)
1>MAIN.obj : error LNK2001: unresolved external symbol _pj_thread_sleep

is due to using wrong reference or because of using c library in c++ code ?


My email is : marwan.idriss at gmail.com

Regards

Marwan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20140417/31021cf0/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: References2.png
Type: image/png
Size: 21981 bytes
Desc: not available
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20140417/31021cf0/attachment.png>


[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux