paullouisageneau / libdatachannel

C/C++ WebRTC network library featuring Data Channels, Media Transport, and WebSockets
https://libdatachannel.org/
Mozilla Public License 2.0
1.82k stars 366 forks source link

Installation trouble #430

Closed jryebread closed 3 years ago

jryebread commented 3 years ago

Hi, having some trouble installing on WSL for windows.

not well versed with makefiles, but I ran make USE_GNUTLS=1 USE_NICE=0 as suggested in BUILD.MD, then i am trying to compile my hello world like so:

g++ -std=c++14 -I/mnt/c/Users/James/Desktop/DemoStream/cpp/libdatachannel/include cpp/test.cpp

test.cpp:

#include <iostream>
#include <rtc/rtc.hpp>

int main ( void )
{
    std::cout << "Hello frendos" << std::endl;
    rtc::Configuration config;
    config.iceServers.emplace_back("mystunserver.org:3478");

    rtc::PeerConection pc(config);
    auto dc = pc.createDataChannel("test");

    dc->onOpen([]() {
        std::cout << "Open" << std::endl;
    });

    dc->onMessage([](std::variant<binary, string> message) {
        if (std::holds_alternative<string>(message)) {
            std::cout << "Received: " << get<string>(message) << std::endl;
        }
    });

    return 0;
}

getting a bunch of errors from within the library

/mnt/c/Users/James/Desktop/DemoStream/cpp/libdatachannel/include/rtc/rtc.hpp:43,
                 from cpp/test.cpp:2:
/mnt/c/Users/James/Desktop/DemoStream/cpp/libdatachannel/include/rtc/rtppacketizationconfig.hpp:58:20: error: ‘optional’ has not been declared
   58 |                    optional<uint32_t> startTimestamp = std::nullopt);
      |                    ^~~~~~~~
/mnt/c/Users/James/Desktop/DemoStream/cpp/libdatachannel/include/rtc/rtppacketizationconfig.hpp:58:28: error: expected ‘,’ or ‘...’ before ‘<’ token
   58 |                    optional<uint32_t> startTimestamp = std::nullopt);
      |                            ^
/mnt/c/Users/James/Desktop/DemoStream/cpp/libdatachannel/include/rtc/rtppacketizationconfig.hpp:69:25: error: ‘optional’ has not been declared
   69 |                         optional<uint16_t> sequenceNumber = 
std::nullopt,
      |                         ^~~~~~~~
/mnt/c/Users/James/Desktop/DemoStream/cpp/libdatachannel/include/rtc/rtppacketizationconfig.hpp:69:33: error: expected ‘,’ or ‘...’ before ‘<’ token
   69 |                         optional<uint16_t> sequenceNumber = 
std::nullopt,
      |                                 ^
In file included from /mnt/c/Users/James/Desktop/DemoStream/cpp/libdatachannel/include/rtc/rtc.hpp:43,
                 from cpp/test.cpp:2:
/mnt/c/Users/James/Desktop/DemoStream/cpp/libdatachannel/include/rtc/rtcpsrreporter.hpp:54:54: error: ‘ChainedMessagesProduct’ has not been declared
   54 | inedOutgoingProduct processOutgoingBinaryMessage(ChainedMessagesProduct messages, message_ptr control) override;
      |                                                  ^~~~~~~~~~~~~~~~~~~~~~

In file included from /mnt/c/Users/James/Desktop/DemoStream/cpp/libdatachannel/include/rtc/h264rtppacketizer.hpp:24,
                 from /mnt/c/Users/James/Desktop/DemoStream/cpp/libdatachannel/include/rtc/h264packetizationhandler.hpp:24,
                 from /mnt/c/Users/James/Desktop/DemoStream/cpp/libdatachannel/include/rtc/rtc.hpp:46,
                 from cpp/test.cpp:2:
/mnt/c/Users/James/Desktop/DemoStream/cpp/libdatachannel/include/rtc/nalunit.hpp:63:40: error: expected class-name before ‘{’ token     
   63 | struct RTC_CPP_EXPORT NalUnit : binary {

just need help with how to set up for the rtc #include. thx.

paullouisageneau commented 3 years ago

Hi, it seems everything is good with your setup. However, libdatachannel requires C++17, therefore you have to change -std=c++14 to -std=c++17 (you can even remove the flag if your g++ is recent enough, C++17 is the default now).

paullouisageneau commented 3 years ago

I'm closing this, please re-open if switching to C++ did not solve the issue.