Boost 1.55与Visual Studio 2013不兼容。

4

我已经正确编译了Boost二进制文件并按照所有说明进行了操作,但是我收到了很多错误信息,而我不知道原因!

这是我的“include”设置: enter image description here

以下是我用来测试Boost的代码:

#include <boost/asio.hpp> // include boost
#include <iostream>
using namespace std;
using namespace boost::asio;  // save tons of typing

// These are the values our port needs to connect
#ifdef _WIN32
// windows uses com ports, this depends on what com port your cable is plugged in to.
const char *PORT = "COM4";
#else
// *nix com ports
const char *PORT = "dev/ttyS3";
#endif
// Note: all the following except BAUD are the exact same as the default values

// what baud rate do we communicate at
serial_port_base::baud_rate BAUD(9600);
// how big is each "packet" of data (default is 8 bits)
serial_port_base::character_size CSIZE(8);
// what flow control is used (default is none)
serial_port_base::flow_control FLOW(serial_port_base::flow_control::none);
// what parity is used (default is none)
serial_port_base::parity PARITY(serial_port_base::parity::none);
// how many stop bits are used (default is one)
serial_port_base::stop_bits STOP(serial_port_base::stop_bits::one);

int main()
{
    // create the I/O service that talks to the serial device
    io_service io;
    // create the serial device, note it takes the io service and the port name
    serial_port port(io, PORT);

    // go through and set all the options as we need them
    // all of them are listed, but the default values work for most cases
    port.set_option(BAUD);
    port.set_option(CSIZE);
    port.set_option(FLOW);
    port.set_option(PARITY);
    port.set_option(STOP);

    // buffer to store commands
    // this device reads 8 bits, meaning an unsigned char, as instructions
    // varies with the device, check the manual first
    unsigned char command[1] = { 0 };

    // read in user value to be sent to device
    int input;
    cin >> input;

    // Simple loop, since the only good values are [0,255]
    //  break when a negative number is entered.
    // The cast will convert too big numbers into range.
    while (input >= 0)
    {
        // convert our read in number into the target data type
        command[0] = static_cast<unsigned char>(input);

        // this is the command that sends the actual bits over the wire
        // note it takes a stream and a asio::buffer
        // the stream is our serial_port
        // the buffer is constructed using our command buffer and
        //  the number of instructions to send
        write(port, buffer(command, 1));

        // read in the next input value
        cin >> input;
    }

    // all done sending commands
    return 0;
}

我的错误(我无法提供任何信息,因为我不知道它们的含义或原因):
1   IntelliSense: identifier "WSA13" is undefined   c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 70  19  Test3
2   IntelliSense: identifier "WSA102" is undefined  c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 73  34  Test3
3   IntelliSense: identifier "WSA100" is undefined  c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 76  20  Test3
4   IntelliSense: identifier "WSA113" is undefined  c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 79  23  Test3
5   IntelliSense: identifier "WSA103" is undefined  c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 82  21  Test3
6   IntelliSense: identifier "WSA106" is undefined  c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 90  24  Test3
7   IntelliSense: identifier "WSA107" is undefined  c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 93  24  Test3
8   IntelliSense: identifier "WSA108" is undefined  c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 96  22  Test3
9   IntelliSense: identifier "WSA9" is undefined    c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 99  20  Test3
10  IntelliSense: identifier "WSA14" is undefined   c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 102 11  Test3
11  IntelliSense: identifier "WSA110" is undefined  c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 105 22  Test3
12  IntelliSense: identifier "WSA112" is undefined  c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 108 17  Test3
13  IntelliSense: identifier "WSA4" is undefined    c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 111 17  Test3
14  IntelliSense: identifier "WSA22" is undefined   c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 114 22  Test3
15  IntelliSense: identifier "WSA115" is undefined  c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 117 18  Test3
16  IntelliSense: identifier "WSA38" is undefined   c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 120 19  Test3
17  IntelliSense: identifier "WSA116" is undefined  c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 123 18  Test3
18  IntelliSense: identifier "WSA117" is undefined  c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 126 19  Test3
19  IntelliSense: identifier "WSA118" is undefined  c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 129 25  Test3
20  IntelliSense: identifier "WSA24" is undefined   c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 132 20  Test3
21  IntelliSense: identifier "WSA119" is undefined  c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 135 21  Test3
22  IntelliSense: identifier "WSA123" is undefined  c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 148 24  Test3
23  IntelliSense: identifier "WSA126" is undefined  c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 151 19  Test3
24  IntelliSense: identifier "WSA128" is undefined  c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 154 16  Test3
25  IntelliSense: identifier "WSA130" is undefined  c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 162 29  Test3
26  IntelliSense: identifier "WSA138" is undefined  c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 168 15  Test3
27  IntelliSense: identifier "WSA140" is undefined  c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 176 17  Test3
28  IntelliSense: identifier "WSA11001L" is undefined   c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 182 20  Test3
29  IntelliSense: identifier "WSA11002L" is undefined   c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 185 30  Test3
30  IntelliSense: identifier "WSA11004L" is undefined   c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 188 13  Test3
31  IntelliSense: identifier "WSA11003L" is undefined   c:\libs\boost\boost_1_55_0\boost\asio\error.hpp 191 17  Test3
32  IntelliSense: identifier "BOOST_ASIO_OS_DEF_0x00000002" is undefined    c:\libs\boost\boost_1_55_0\boost\asio\ip\resolver_query_base.hpp    66  22  Test3
33  IntelliSense: identifier "BOOST_ASIO_OS_DEF_0x00000001" is undefined    c:\libs\boost\boost_1_55_0\boost\asio\ip\resolver_query_base.hpp    67  15  Test3
34  IntelliSense: identifier "BOOST_ASIO_OS_DEF_0x00000004" is undefined    c:\libs\boost\boost_1_55_0\boost\asio\ip\resolver_query_base.hpp    68  20  Test3
35  IntelliSense: identifier "BOOST_ASIO_OS_DEF_0x00000008" is undefined    c:\libs\boost\boost_1_55_0\boost\asio\ip\resolver_query_base.hpp    69  23  Test3
36  IntelliSense: identifier "BOOST_ASIO_OS_DEF_0x00000800" is undefined    c:\libs\boost\boost_1_55_0\boost\asio\ip\resolver_query_base.hpp    70  17  Test3
37  IntelliSense: identifier "BOOST_ASIO_OS_DEF_0x00000100" is undefined    c:\libs\boost\boost_1_55_0\boost\asio\ip\resolver_query_base.hpp    71  20  Test3
38  IntelliSense: identifier "BOOST_ASIO_OS_DEF_0x00000400" is undefined    c:\libs\boost\boost_1_55_0\boost\asio\ip\resolver_query_base.hpp    72  26  Test3
39  IntelliSense: identifier "BOOST_ASIO_OS_DEF_0" is undefined c:\libs\boost\boost_1_55_0\boost\asio\ip\multicast.hpp  51  3   Test3
40  IntelliSense: identifier "BOOST_ASIO_OS_DEF_12" is undefined    c:\libs\boost\boost_1_55_0\boost\asio\ip\multicast.hpp  52  3   Test3
41  IntelliSense: identifier "BOOST_ASIO_OS_DEF_13" is undefined    c:\libs\boost\boost_1_55_0\boost\asio\ip\multicast.hpp  80  3   Test3
42  IntelliSense: identifier "BOOST_ASIO_OS_DEF_9" is undefined c:\libs\boost\boost_1_55_0\boost\asio\ip\multicast.hpp  108 3   Test3
43  IntelliSense: identifier "BOOST_ASIO_OS_DEF_10" is undefined    c:\libs\boost\boost_1_55_0\boost\asio\ip\multicast.hpp  144 3   Test3
44  IntelliSense: identifier "BOOST_ASIO_OS_DEF_11" is undefined    c:\libs\boost\boost_1_55_0\boost\asio\ip\multicast.hpp  181 3   Test3
45  IntelliSense: identifier "BOOST_ASIO_OS_DEF_0x0001" is undefined    c:\libs\boost\boost_1_55_0\boost\asio\ip\tcp.hpp    126 37  Test3
46  IntelliSense: identifier "BOOST_ASIO_OS_DEF_0" is undefined c:\libs\boost\boost_1_55_0\boost\asio\ip\unicast.hpp    59  3   Test3
47  IntelliSense: identifier "BOOST_ASIO_OS_DEF_4" is undefined c:\libs\boost\boost_1_55_0\boost\asio\ip\unicast.hpp    60  3   Test3

文本比图片更受欢迎。文本适用于包含路径、代码和错误。 - chris
1
你是否遇到编译器/链接器错误?上面的错误看起来只是Intellisense在抱怨一些东西,这会在编辑器中创建红色波浪线,但不应该阻止你成功编译。 - Praetorian
我得到了“构建失败”。 - user2705775
请添加编译器或链接器错误。这个问题中没有任何内容表明boost 1.55与Visual Studio 2013不兼容。 - free_coffee
我在问题中发布了错误信息(标识符“WSA13”未定义等)。 - user2705775
正如Praetorian所说,那些只是Intellisense消息,与您的构建成功或失败无关。您需要从编译器或链接器中找到错误。 - free_coffee
2个回答

6
Boost 1.55 发布说明中得知:

Visual Studio 2013/Visual C++ 12 已知问题

由于 Visual Studio 2013 在发布过程中推迟,因此存在一些未解决的问题。 这些问题包括:

- 序列化无法编译,因为缺少 include。

- 使用 Boost.Container 的 allocator_traits 中的 has_member_function_callable_with 会导致编译错误(#9332)。

- 在 Unordered 和 MultiIndex 等库中,使用 initializer 列表调用重载函数可能会导致编译错误,Visual C++ 声称重载不明确。这是 Visual C++ 的一个错误,并且目前不清楚是否有好的解决方法。 这不会影响不使用 initializer 列表的代码,或者使用不需要隐式转换的初始化列表(即与容器的精确值类型相同的初始化列表)。

- Thread: ex_scoped_thread 编译失败 (#9333)。

请注意,VC++ 12 并没有完全支持,即使 Boost 可以编译,也不一定意味着它不会出现运行时错误(这意味着不幸的是,你必须为它们制定解决方案)。 如果您在 Boost 中发现更多错误,请向他们报告


我应该期待什么时候发布新版本来解决这些问题?或者你认为我应该只使用VS2012? - user2705775
@user2705775 就我个人而言,我继续使用VS2013,并远离那些存在问题的库(对于那些没有问题的库,我仍然需要检查运行时错误)。 - Mark Garcia
那我想我得使用VS2012了。我以前从未修改过库,而且我必须尽快完成这个任务。 - user2705775
你能给我指一下一个可行的教程,用于在VS2012中设置boost吗?我尝试过了,但它不允许我更改工具集,而默认似乎是vc12。 - user2705775
@user2705775,所有的内容都在文档中了 :-). - Mark Garcia
显示剩余2条评论

4
我自己在升级到VC++ 2013时遇到了这个问题。请注意,它们不是构建错误,而是IntelliSense错误。似乎IntelliSense在解析一些宏方面没有编译器聪明。考虑到新的VC++ 2013 IntelliSense与2010相比有多好,我对此并不太担心。
无论如何,您可以通过右键单击列表并取消选中“显示IntelliSense错误”来抑制它们。 enter image description here

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接