Error linking webrtc-native due to undefined reference to methods having std::string

903 views
Skip to first unread message

yihungbakj hung

unread,
Apr 1, 2018, 9:55:42 PM4/1/18
to discuss-webrtc
Hi All

I am trying to build webrtc version 59 , using the following:

ninja -C out/default CCServiceUnit

I get the the following error:

root@ubuntu-VirtualBox:/home/ubuntu/webrtc-checkout/src# ninja -C out/default CCServiceUnit
ninja: Entering directory `out/default'
[6/6] LINK ./CCServiceUnit
FAILED: CCServiceUnit 
python "../../build/toolchain/gcc_link_wrapper.py" --output="./CCServiceUnit" -- ../../third_party/llvm-build/Release+Asserts/bin/clang++ -Wl,--fatal-warnings -fPIC -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -Wl,-z,defs -Wl,--no-as-needed -lpthread -Wl,--as-needed -fuse-ld=gold -B../../third_party/binutils/Linux_x64/Release/bin -Wl,--threads -Wl,--thread-count=4 -Wl,--icf=all -m64 -pthread -Werror -Wl,--gdb-index -Wl,-rpath-link=. -Wl,--disable-new-dtags -L/usr/local/lib -o "./CCServiceUnit" -Wl,--start-group @"./CCServiceUnit.rsp"  -Wl,--end-group  /usr/local/lib/libjemalloc.a -ldl -lrt -lsocketiopoco -lx264 -lavcodec_fl2 -lavformat_fl2 -lavfilter_fl2 -lswscale_fl2 -lavutil_fl2 -lvo-aacenc -lPocoFoundationd -lPocoJSONd -lPocoNetd -lPocoNetSSLd -lXext -lX11 -lXcomposite -lXrender -lexpat -lm -lconfig++ 
../../webrtc/base/checks.h:176: error: undefined reference to 'std::string* rtc::MakeCheckOpString<unsigned long, unsigned long>(unsigned long const&, unsigned long const&, char const*)'
../../CCServiceUnit/webrtc/PeerConnectionController.cc:496: error: undefined reference to 'webrtc::CreateIceCandidate(std::string const&, int, std::string const&, webrtc::SdpParseError*)'
../../CCServiceUnit/webrtc/PeerConnectionController.cc:535: error: undefined reference to 'webrtc::CreateSessionDescription(std::string const&, std::string const&, webrtc::SdpParseError*)'
../../CCServiceUnit/webrtc/PeerConnectionController.cc:360: error: undefined reference to 'Json::Value::asString() const'
../../CCServiceUnit/webrtc/PeerConnectionController.cc:369: error: undefined reference to 'rtc::GetStringFromJsonObject(Json::Value const&, std::string const&, std::string*)'
../../CCServiceUnit/webrtc/PeerConnectionController.cc:370: error: undefined reference to 'rtc::GetIntFromJsonObject(Json::Value const&, std::string const&, int*)'
../../CCServiceUnit/webrtc/PeerConnectionController.cc:371: error: undefined reference to 'rtc::GetStringFromJsonObject(Json::Value const&, std::string const&, std::string*)'
../../CCServiceUnit/webrtc/PeerConnectionController.cc:387: error: undefined reference to 'rtc::GetStringFromJsonObject(Json::Value const&, std::string const&, std::string*)'
../../CCServiceUnit/webrtc/PeerConnectionController.cc:638: error: undefined reference to 'webrtc::CreateSessionDescription(std::string const&, std::string const&, webrtc::SdpParseError*)'
../../webrtc/base/array_view.h:149: error: undefined reference to 'rtc::FatalMessage::FatalMessage(char const*, int, std::string*)'
../../webrtc/base/array_view.h:150: error: undefined reference to 'rtc::FatalMessage::FatalMessage(char const*, int, std::string*)'
../../webrtc/base/array_view.h:151: error: undefined reference to 'rtc::FatalMessage::FatalMessage(char const*, int, std::string*)'
../../webrtc/base/array_view.h:149: error: undefined reference to 'rtc::FatalMessage::FatalMessage(char const*, int, std::string*)'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.


How to solve the error?

Thank you.

yh


Alexandre GOUAILLARD

unread,
Apr 1, 2018, 10:30:34 PM4/1/18
to discuss...@googlegroups.com
this does not seem to be an original target of libwebrtc.

are you using a modified version?



--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrtc+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/10e92279-b8a5-4581-b219-7509b87e485d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alex. Gouaillard, PhD, PhD, MBA
------------------------------------------------------------------------------------
President - CoSMo Software Consulting, Singapore
------------------------------------------------------------------------------------

yihungbakj hung

unread,
Apr 1, 2018, 11:18:16 PM4/1/18
to discuss-webrtc
Hi Alexandre GOUAILLARD

No,I am not. I am using native webRTC(M59)  API in my program (CCServiceUnit).
Can you help me to check my program? Thank you
yh


Here is my gn file and h, cc file.

conductor.h

#ifndef PEERCONNECTION_SAMPLES_CLIENT_CONDUCTOR_H_
#define PEERCONNECTION_SAMPLES_CLIENT_CONDUCTOR_H_
#pragma once

#include <map>
#include <set>
#include <string>
#include <memory>
#include <Poco/URI.h>
//#include "boost_ipc/IPCServer.h"
//#include "boost_ipc/StreamIPCServer.h"

#include "webrtc/base/thread.h"

#include "webrtc/PeerConnectionSession.h"
#include "webrtc/WebRtcVP8Encoder.h"
#include "channel/SocketIOChannel.h"

namespace CC {

class Conductor:
public rtc::RefCountInterface,
public rtc::MessageHandler,
public SocketIOChannelObserver,
public PeerConnectionSessionObserver,
public fl2::WebRtcVP8EncoderCallback,
public rtc::Runnable
{
public:
enum {
MSG_ON_SIGNALING_JSON,
MSG_ON_SIGNALING_DISCONNECT,
MSG_ON_RAW_VIDEO_FRAME,
MSG_ON_SHARED_ENCODED_VIDEO_FRAME,
MSG_ON_PCM_AUDIO_FRAME,
MSG_ON_REMOVE_USER,
MSG_ON_MAINWINDOW_MESSAGE,
MSG_ON_PC_MESSAGE_CHECK,
MSG_ON_PC_MESSAGE,
MSG_ON_PC_CONNECT,
MSG_ON_PC_DISCONNECT,
MSG_ON_PC_SESSION_EMPTIED,
MSG_ON_CLOSE
};

Conductor(std::string id);
virtual ~Conductor();

void StartLogin(const Poco::URI& uri);

// *** rtc::MessageHandler ***
virtual void OnMessage(rtc::Message* msg);

// *** SocketIOChannelObserver ***
virtual void onSignalingJSON(Object::Ptr& arg);
virtual void onSignalingMessage(std::string& arg);
virtual void onSignalingEvent(int eventid, void* arg);

// *** PeerConnectionSessionObserver ***
virtual void onEncodedVideoFrame(const std::string& clientid, shared_ptr<WrapEncodedFrame>& cf, const std::string& source);
virtual void onRequestKeyEncodedVideoFrame(PeerConnectionSessionInterface::FrameMode mode);
virtual void onSetEncodingRates(const std::string& clientid, PeerConnectionSessionInterface::FrameMode mode, uint32_t newBitRate, uint32_t frameRate);
virtual void onRawVideoFrame(const std::string& clientid, const webrtc::VideoFrame* frame, const std::string& source);
virtual void onPCMAudioFrame(const std::string& clientid, shared_ptr<CaptureFrame>& cf, const std::string& source);
virtual void onPeerConnectionConnect(const std::string& clientid, const std::string& source);
virtual void onPeerConnectionDisconnect(const std::string& clientid, const std::string& source);
virtual void onPeerConnectionSessionEmptied(const std::string& clientid);
virtual void sendPeerConnectionMessage(const std::string& destid, const Object::Ptr& msg);

// *** WebRtcVP8EncoderCallback ***
virtual void onVP8EncodedFrame(shared_ptr<WrapEncodedFrame>& frame, int id);

void DeletePeerConnection();

void quit() { // Post the close msg in another thread to prevent deadlock
quitThread.reset(new rtc::Thread);
quitThread->Start(this);
}

virtual void Run(rtc::Thread* t/*unused*/) {
thread->Post(RTC_FROM_HERE, this, MSG_ON_CLOSE);
}
protected:
rtc::Thread *thread;

std::shared_ptr<CC::SocketIOChannel> channel_client;

std::map<std::string, std::unique_ptr<PeerConnectionSessionInterface> > sessions;

std::unique_ptr<fl2::WebRtcVP8Encoder> vp8Encoders[PeerConnectionSessionInterface::NO_VIDEO_FRAME];

std::unique_ptr<webrtc::VideoFrame> lastFrame;
time64_t lastFrameRtcTime;
time64_t startRtcTime;
time64_t lastAdjustHighestModeTime;

std::string mainClient;
bool mainClientReady;
std::string myid;
bool _runTest;
Poco::URI _uri;

std::string channelId;

std::unique_ptr<rtc::Thread> quitThread;
};

}
#endif  // PEERCONNECTION_SAMPLES_CLIENT_CONDUCTOR_H_

main.cc

#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <Poco/URI.h>
#include <Poco/Logger.h>
#include <Poco/AutoPtr.h>
#include <Poco/ConsoleChannel.h>
#include <Poco/FileChannel.h>
#include <Poco/PatternFormatter.h>
#include <Poco/FormattingChannel.h>
#include <Poco/Net/HTTPRequest.h>
#include <Poco/Net/HTTPResponse.h>

#include "conductor.h"
#include "channel/SocketIOChannel.h"
#include "webrtc/PeerConnectionSessionInterface.h"
#include "webrtc/base/thread.h"
#include "webrtc/base/ssladapter.h"

#include "utils/flags/commonFlagdefs.h"
#include "utils/flags/flagdefs.h"

using Poco::AutoPtr;
using Poco::Logger;
using rtc::FlagList;

rtc::Thread* thread;
rtc::scoped_refptr<CC::Conductor> conductor = NULL;

void my_handler(int s){
printf("Caught signal %d\n",s);
conductor->quit();
}

std::string getRandomString(int length) {
srand(time(0));
std::stringstream s;
char alphanum[] = "0123456789"
// "!@#$%^&*"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz";
int stringLength = sizeof(alphanum) - 1;
for (int i = 0; i < length; i++)
s << alphanum[rand() % stringLength];
return s.str();
}

int main(int argc, char* argv[]) {
struct sigaction sigIntHandler;

sigIntHandler.sa_handler = my_handler;
sigemptyset(&sigIntHandler.sa_mask);
sigIntHandler.sa_flags = 0;

sigaction(SIGINT, &sigIntHandler, NULL);
sigaction(SIGTERM, &sigIntHandler, NULL);

FlagList::SetFlagsFromCommandLine(&argc, argv, true);
if (FLAG_help) {
FlagList::Print(NULL, false);
return 0;
}

std::string id = FLAG_ID;
if(id=="(random generated)") {
id = getRandomString(10);
}

if(FLAG_sioLog) {
AutoPtr<Poco::Formatter> formatter(new Poco::PatternFormatter("%y%m%d-%H%M%S.%i %t"));
formatter->setProperty("times","local");
AutoPtr<Poco::Channel> debugChannel;
if(FLAG_debugLogPath[0]=='\0') {
debugChannel.assign(new Poco::ConsoleChannel());
} else {
debugChannel.assign(new Poco::FileChannel(std::string(FLAG_debugLogPath)+"/su_sio_"+id+".log"));
debugChannel->setProperty("rotation", "2 M");// Write a new file every 2 MBytes
debugChannel->setProperty("archive", "number");// Append a number for archived files
debugChannel->setProperty("compress", "true");// Compress the archived files
}
AutoPtr<Poco::Channel> formattingChannel(new Poco::FormattingChannel(formatter, debugChannel));
Logger::create("SIOClientLog", formattingChannel);
}

Poco::URI temp_uri(FLAG_SERVER);

rtc::InitializeSSL();
rtc::AutoThread auto_thread;
thread = rtc::Thread::Current();

// --- Create debug logger ---
{
AutoPtr<Poco::Formatter> formatter(new Poco::PatternFormatter("%y%m%d-%H%M%S.%i %t"));
formatter->setProperty("times","local");
AutoPtr<Poco::Channel> debugChannel;
if(FLAG_debugLogPath[0]=='\0') {
debugChannel.assign(new Poco::ConsoleChannel());
} else {
debugChannel.assign(new Poco::FileChannel(std::string(FLAG_debugLogPath)+"/su_"+id+".log"));
debugChannel->setProperty("rotation", "2 M");// Write a new file every 10 MBytes
debugChannel->setProperty("archive", "number");// Append a number for archived files
debugChannel->setProperty("compress", "true");// Compress the archived files
}
AutoPtr<Poco::Channel> formattingChannel(new Poco::FormattingChannel(formatter, debugChannel));
Logger::create("DebugLog", formattingChannel);
}
Logger& logger = Logger::get("DebugLog");
logger.information("Debug logger start");
// ------

if(FLAG_statusReportServer[0]!='\0') {
Poco::URI report_uri(FLAG_statusReportServer);
logger.information("status reported to %s", std::string(FLAG_statusReportServer));
HTTPClientSession session(report_uri.getHost(), report_uri.getPort());
Poco::Net::HTTPRequest req(Poco::Net::HTTPRequest::HTTP_POST, report_uri.getPathEtc(),
Poco::Net::HTTPMessage::HTTP_1_1);
req.setContentLength(0);
Poco::Net::HTTPResponse res;
session.sendRequest(req);
session.receiveResponse(res);
logger.information("res: %d, %s", (int)res.getStatus(), res.getReason());
}

conductor = new rtc::RefCountedObject<CC::Conductor>(id);
conductor->StartLogin(temp_uri);

thread->Run();

conductor = NULL;
thread->set_socketserver(NULL);
rtc::CleanupSSL();

logger.information("program exit");
return 0;
}

Alexandre GOUAILLARD於 2018年4月2日星期一 UTC+8上午10時30分34秒寫道:
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
BUILD.gn

Miguel del Amor

unread,
Apr 2, 2018, 6:32:28 AM4/2/18
to discuss-webrtc
I think you're using libgnustl in your program while webrtc is using libc++, have you checked that? I've been on same issue while using Qt or other frameworks.

Hope this helps you!

Regards.

El lunes, 2 de abril de 2018, 5:18:16 (UTC+2), yihungbakj hung escribió:
Hi Alexandre GOUAILLARD

No,I am not. I am using native webRTC(M59)  API in my program (CCServiceUnit).
Can you help me to check my program? Thank you



yihungbakj hung

unread,
Apr 2, 2018, 11:47:20 AM4/2/18
to discuss-webrtc
Thanks for your response. I haven't checked these libraries.

But could you help me with the problem of compiling the project when I try to use these libraries directly in the linux project? 
Can you give me an example? 

Thank you.

yh



Miguel del Amor於 2018年4月2日星期一 UTC+8下午6時32分28秒寫道:

Alexandre GOUAILLARD

unread,
Apr 3, 2018, 2:30:26 AM4/3/18
to discuss...@googlegroups.com
Ok,

So this is not a libwebrtc build, this is a build of your own application, that uses libwebrtc. We usually do not debug all the projects out there, we would spend our life doing only that.

some hints:
- those are linking errors, we don t need to see your code. You are missing some libraries or .obj when you link.
- it is very unlikely that your code will NOT link against libwebrtc eventually because of the additional SSL implementation you are trying to use (pocoNETSSL => openssl)
- the json error you are seeing are because you did not make your GN Target dependant on JSONlib (/third_party) nor rtc_json targets.
- I don t remember the solution for FatalMessage, but grep'ing the corresponding class should help you find the file where the class is defined, and in turn the target to which it belongs.

To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrtc+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/e545ccac-a44d-4f26-8d15-cae5d42ccc71%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Alexandre GOUAILLARD

unread,
Apr 4, 2018, 4:41:52 AM4/4/18
to discuss...@googlegroups.com
is the code open source somewhere so we can attempt to fix it?

To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrtc+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/67f626a9-174e-4387-ab2c-1463131a5818%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages