Send SMS with Twilio using Visual Studios

I'm currently trying to send a text message using this example from Twilio:

https://www.twilio.com/docs/sms/tutorials/how-to-send-sms-messages-cpp

I was able to get it running on Linux just fine, but I want to integrate this into my app using Visual Studios. I've made some changes to the code in order to hardcode the number and remove the need for arguments. In order to make it "windows friendly" I am also using a special made unistd.h replacement. It works, so there's no need to worry about that.

Currently, this is the error I'm receiving:

1>twilio.obj : error LNK2001: unresolved external symbol "public: static class std::locale::id std::codecvt<char16_t,char,struct _Mbstatet>::id" (?id@?$codecvt@_SDU_Mbstatet@@@std@@2V0locale@2@A)

I think it has to do with type_conversion.h. If the rest of the code files are needed, I can share it. I'm just trying to spamming the post with too much (there's all the character limit)

type_conversion.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <locale>
#include <codecvt>
#include <string>
#include <iostream>

// Given a UTF-8 encoded string return a new UCS-2 string.

inline std::u16string
utf8_to_ucs2(std::string const& input)
{
        std::wstring_convert<std::codecvt_utf8<char16_t>, char16_t> convert;
        try {
            return convert.from_bytes(input);
        }
        catch (const std::range_error&) {
            throw std::range_error(
                "Failed UCS-2 conversion of message body.  Check all "
                "characters are valid GSM-7, GSM 8-bit text, or UCS-2 "
                "characters."
            );
        }
}

inline std::string
ucs2_to_utf8(std::u16string const& input)
{
        std::wstring_convert<std::codecvt_utf8<char16_t>, char16_t> convert;
        return convert.to_bytes(input);
}


Does anyone know a potential fix for this? Thanks!
Last edited on
How old is your visual studio?

https://en.cppreference.com/w/cpp/locale/codecvt_utf8

It looks like you need a C++11 compiler, or at least tell your compiler that you're compiling C++11 code.
I am using Visual Studio 2017 version 15.9.8. Compile as is set on "Default". There's options for all C and all C++. I'm not sure how to ensure that it's using C++11 specifically...
Last edited on
Topic archived. No new replies allowed.