undefined reference to `Json::Value::asString[abi:cxx11]() const' when using libwebrtc warpper lib

1,654 views
Skip to first unread message

Vincent Bian

unread,
May 2, 2018, 6:16:49 AM5/2/18
to discuss-webrtc
Hi,

I want to add a wrapper to libwebrtc. I add two source  files to BUILD.gn file as below.  The peerconnwrapper.cc file  used jsoncpp lib. When using libwebrtc warpper lib, there is a error "undefined reference to `Json::Value::asString[abi:cxx11]() const'".   

Any point in the right direction would be really appreciated. Thanks!


The make errer:
/tmp/ccDp9YBT.o: In function `(anonymous namespace)::WebrtcChan::handleMessage()':
/home/dengl/project/svcsfu/modules/ywebsocket.cpp:507: undefined reference to `Json::Reader::parse(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Json::Value&, bool)'

nm inquire:
nm -C obj/libwebrtc.a | grep Reader::parse
                 U Json::Reader::parse(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, Json::Value&, bool)
0000000000000c60 T Json::Reader::parse(char const*, char const*, Json::Value&, bool)
00000000000009d0 T Json::Reader::parse(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, Json::Value&, bool)
00000000000010a0 T Json::Reader::parse(std::__1::basic_istream<char, std::__1::char_traits<char> >&, Json::Value&, bool)

I guess, the reason can not link is that,  there are  both  'U' symbol  and  'T' symbol for Reader::parse(). 

modified BUILD.gn file for the wrapper lib:
if (!build_with_chromium) {
  # Target to build all the WebRTC production code.
  rtc_static_library("webrtc") {
    # Only the root target should depend on this.
    visibility = [ "//:default" ]

    # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
    suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]

    sources = [
      "api/peerconnwrapper/peerconnwrapper.cc",  # my wrapper file
      "api/peerconnwrapper/peerconnwrapper.h",
    ]

Niels Moller

unread,
May 2, 2018, 7:47:34 AM5/2/18
to discuss...@googlegroups.com
On Wed, May 2, 2018 at 12:16 PM, Vincent Bian <vince...@gmail.com> wrote:
> The make errer:
> /tmp/ccDp9YBT.o: In function `(anonymous
> namespace)::WebrtcChan::handleMessage()':
> /home/dengl/project/svcsfu/modules/ywebsocket.cpp:507: undefined reference
> to `Json::Reader::parse(std::__cxx11::basic_string<char,
> std::char_traits<char>, std::allocator<char> > const&, Json::Value&, bool)'

Note the std:__cxx11::basic_string in the prototype.

> 00000000000010a0 T Json::Reader::parse(std::__1::basic_istream<char,
> std::__1::char_traits<char> >&, Json::Value&, bool)

This is a symbol definition which looks almost right, but note "__1"
instead of "__cxx11", so it's not the same symbol. You have probably
compiled the jsoncpp lib with g++ and webrtc with clang, or vice
versa.

To repeat: There's no such thing as a standard C++ ABI. Therefore, you
can't mix object files produced by different C++ compilers.

Regards,
/Niels

Angelo Mantellini

unread,
May 2, 2018, 7:50:14 AM5/2/18
to discuss...@googlegroups.com
I think that the problem is about the libstdc++/libc++.
Could you try with use_custom_libcxx = false use_custom_libcxx_for_host = false when you launch the gn command?


Let me know.
Angelo
--

---
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-webrt...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/CAAO0x17kP5B0%3D%2BDnCihVOeLS%2B-e%3DLnsWg3JV1YWqVhHCoSmhFQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.



Alexandre GOUAILLARD

unread,
May 2, 2018, 11:33:42 AM5/2/18
to discuss...@googlegroups.com
the problem is that while third_party/jsoncpp lib is included in rtc_base, rtc_json is not in the libwebrtc dependency tree by default.
the examples are linking against it directly, masking the fact that it is not in libwebrtc. Plus since it's a source_set there is no library created on disk. easy to miss.
add the corresponding dependencies to the target where you put your files, and you should be good.

i.e. add the following just below your source declaration:

deps += ["../rtc_base:rtc_json",]


and it should work.


On Wed, May 2, 2018 at 7:50 PM, Angelo Mantellini <amant...@gmail.com> wrote:
I think that the problem is about the libstdc++/libc++.
Could you try with use_custom_libcxx = false use_custom_libcxx_for_host = false when you launch the gn command?


Let me know.
Angelo

On 5/2/18, 1:47 PM, "Niels Moller" <discuss-webrtc@googlegroups.com on behalf of ni...@webrtc.org> wrote:

    On Wed, May 2, 2018 at 12:16 PM, Vincent Bian <vince...@gmail.com> wrote:
    > The make errer:
    > /tmp/ccDp9YBT.o: In function `(anonymous
    > namespace)::WebrtcChan::handleMessage()':
    > /home/dengl/project/svcsfu/modules/ywebsocket.cpp:507: undefined reference
    > to `Json::Reader::parse(std::__cxx11::basic_string<char,
    > std::char_traits<char>, std::allocator<char> > const&, Json::Value&, bool)'

    Note the std:__cxx11::basic_string in the prototype.

    > 00000000000010a0 T Json::Reader::parse(std::__1::basic_istream<char,
    > std::__1::char_traits<char> >&, Json::Value&, bool)

    This is a symbol definition which looks almost right, but note "__1"
    instead of "__cxx11", so it's not the same symbol. You have probably
    compiled the jsoncpp lib with g++ and webrtc with clang, or vice
    versa.

    To repeat: There's no such thing as a standard C++ ABI. Therefore, you
    can't mix object files produced by different C++ compilers.

    Regards,
    /Niels

    --

    ---
    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.
--

---
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/60CD9033-FA9D-4DC1-B69D-F312BCA06B41%40gmail.com.

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



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

Vincent Bian

unread,
May 2, 2018, 10:12:05 PM5/2/18
to discuss-webrtc
Cool!

The problem is about the libstdc++/libc++.  The problem is solved  with use_custom_libcxx = false use_custom_libcxx_for_host = false when you launch the gn command.

gn gen out/test --args='treat_warnings_as_errors=false use_custom_libcxx = false use_custom_libcxx_for_host = false'

nm -C out/test/obj/libwebrtc.a | grep Reader::parse
                 U Json::Reader::parse(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Json::Value&, bool)
0000000000000340 T Json::Reader::parse(char const*, char const*, Json::Value&, bool)
0000000000000290 T Json::Reader::parse(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Json::Value&, bool)
00000000000005b0 T Json::Reader::parse(std::istream&, Json::Value&, bool)

Alexandre GOUAILLARD

unread,
May 2, 2018, 10:15:21 PM5/2/18
to discuss...@googlegroups.com
I m happy you like my stack overflow answer.

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/dbdd472e-9e97-47ba-b1e8-097e94c5293f%40googlegroups.com.

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

Vincent Bian

unread,
May 2, 2018, 10:17:09 PM5/2/18
to discuss-webrtc
You are right. I did not notice the difference. with "__1"  and  "__cxx11" . I build libwebrtc using default clang and use it in a g++ project.
Reply all
Reply to author
Forward
0 new messages