QT,socket.io和boost集成未定义引用错误

时间:2016-06-11 01:30:52

标签: c++ qt boost socket.io

我是Boost的新手,也是QT的新手,所以我不知道包装系统在QT,Boost和CPP中的运作方式。

我尝试在this教程之后的QT中使用Socket.IO集成Boost。我试图在没有CMake的情况下这样做,因为它看起来对我来说更容易理解。 我收到的错误和警告在这张图片中: Errors

到目前为止我所做的一切都是这样的:
- 下载和解压缩Boost
- 命令历史:

254  ./bootstrap.sh
255  ./b2 --help
256  ./b2
257  ./bjam install --prefix="./" --with-system --with-date_time --with-random link=static runtime-link=shared threading=multi
258  git clone --recurse-submodules https://github.com/socketio/socket.io-client-cpp.git

将github repo中src文件夹的内容复制到文件夹名siosrc下的项目中 - 更新了pro文件,这是它的内容:

TEMPLATE = app

QT += qml quick widgets

CONFIG += c++11

SOURCES += main.cpp \
            siosrc/sio_client.cpp \
            siosrc/sio_socket.cpp \
            siosrc/internal/sio_client_impl.cpp \
            siosrc/internal/sio_packet.cpp

RESOURCES += qml.qrc

# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =

# Default rules for deployment.
include(deployment.pri)

INCLUDEPATH += /home/akash/Softwares/Boost/boost_1_61_0/include/ \
                /home/akash/QTProjects/SioCpp/socket.io-client-cpp/lib/websocketpp/ \
                /home/akash/QTProjects/SioCpp/socket.io-client-cpp/lib/rapidjson/include/ \
                /home/akash/Softwares/Boost/boost_1_61_0/lib/

我所执行的所有步骤都是我可以从github自述文件和socket.io's cpp blog中找到的,因为源文件sio_packet.cpp的位置不对,所以这似乎已经过时了。关于文件在github repo中的位置是正确的。

我希望我有足够的描述性,有人可以帮助我!

1 个答案:

答案 0 :(得分:1)

您的构建未链接到boost::system

假设您已根据here指令为boost构建linux(即进入$BOOST_ROOT环境变量的目录),您可以添加boost文件的pro库目录,后跟boost_system lib文件:

# Ensure that the BOOST_ROOT environment variable has been set
BOOST_ROOT = $$(BOOST_ROOT)
isEmpty(BOOST_ROOT) {
  error("Please set BOOST_ROOT to the location of the Boost libraries")
} else {
  message(Using Boost from: $$BOOST_ROOT)
}

LIBS += -L$${BOOST_ROOT}/stage/lib
LIBS += -lboost_system

注意:boostlinux/usr/lib等安装了/usr/lib64 /usr/local/lib个打包的boost个库,因此不要要求定义他们的路径。

我使用了许多pro库,发现列出所需的库更容易,并在BOOST_LIBS = system log_setup log program_options thread LIBS += -L$${BOOST_ROOT}/stage/lib BOOST_LIB_PREFIX = boost_ for(lib, BOOST_LIBS) { message(link: $${BOOST_LIB_PREFIX}$${lib}) LIBS += -l$${BOOST_LIB_PREFIX}$${lib}} } 文件中使用循环来添加链接依赖项,例如:

<?php
    $status_selected = 'A002';
?>
<!-- HTML Select 1 -->
<select id="state" class="l" name="state" onchange="Func()">
<option value="A001" <?php if($status_selected == "A001") echo "selected"; ?> data_item=" , StateA003 One, A003 State Two, A003 State Three">A001</option>
<option value="A002" <?php if($status_selected == "A002") echo "selected"; ?> data_item=" , A003 State One, A003 State Two, A003 State Three">A002</option>
<option value="A003" <?php if($status_selected == "A003") echo "selected"; ?> data_item=" , A003 State One, A003 State Two, A003 State Three">A003</option>
</select>
<!-- HTML Select 2 -->
<label for="city">Item : </label><select id="city" name="item" class="l"  onchange="onSelected()">