我使用的是C ++ socket.io库在我的C ++项目,我无法包括在我的项目所需要的头文件的头文件。
但是,当我包括我的CPP文件所需的头文件,我能够成功地包括所需的头文件。
采取措施,利用库:
- 编译C ++ websocketpp,OpenSSL的,Boost库,并准备JSON库。
- 链接反对我的VS2015项目中的* .lib文件。
- 包括在C的头文件位置++额外包括依赖关系文件夹。
- 包含在链接的* .lib文件的位置包括依赖关系文件夹。
- 包括我的CPP文件中的三个头文件。
- 建立。 好极了! 有用!
- 尝试封装库功能整合到自己的类/对象。
- 尝试包括三个库在我的头文件的头文件。 注意编译错误的有关初始化过多。
头文件导入
#include <sio_message.h>
#include <sio_socket.h>
#include <sio_client.h>
包括头文件中的头文件时出错:
Severity Code Description Project File Line Suppression State
Error C2440 'initializing': cannot convert from 'nullptr' to 'const int &' c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2838 'function<void __cdecl(sio::message::list const &)>': illegal qualified name in member declaration c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2838 'function<void __cdecl(sio::message::list const &)>': illegal qualified name in member declaration c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2440 'initializing': cannot convert from 'nullptr' to 'const int &' c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2838 'list': illegal qualified name in member declaration c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2838 'list': illegal qualified name in member declaration c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2439 'sio::socket::ack': member could not be initialized c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2439 'sio::socket::ack': member could not be initialized c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2439 'sio::socket::msglist': member could not be initialized c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2439 'sio::socket::msglist': member could not be initialized c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2530 'sio::socket::name': references must be initialized c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 96
Error C2530 'sio::socket::name': references must be initialized c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 96
Error C2838 'string': illegal qualified name in member declaration c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2838 'string': illegal qualified name in member declaration c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C4430 missing type specifier - int assumed. Note: C++ does not support default-int c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2059 syntax error: ')' c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2059 syntax error: ')' c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2143 syntax error: missing ')' before 'const' c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2143 syntax error: missing ')' before 'const' c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2143 syntax error: missing ';' before 'const' c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
Error C2143 syntax error: missing ';' before 'const' c:\root\src\socket.io-client-cpp\build\include\sio_socket.h 75
可能出现的问题:
- 共享命名空间? 也许我传播了不正确的命名空间?
- 循环依赖? 也许我通过在我的类的头文件导致循环依赖,以及其他头文件中的一个,包括相同的文件。