1. 这是因为工程link不到network的库,因此除了要包含头文件
    #include 
之外,还需要在.pro文件中加入:
    QT += network

2. 对于CMake,需添加Network相关package

#"/home/Qt5.1.0/5.1.0/gcc"  QT5目录

set(CMAKE_PREFIX_PATH "/home/Qt5.1.0/5.1.0/gcc")

find_package(Qt5Network REQUIRED)

set(QT_INCLUDE_DIRS ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS})
set(QT_LIBRARIES Qt5::Gui Qt5::Widgets Qt5::Network)
add_definitions(${Qt5Gui_DEFINITIONS} ${Qt5Widgets_DEFINITIONS} ${Qt5Network_DEFINITIONS})

在QT5目录下搜寻cmake文件:

find . -name "*.cmake"

Qt5.1.0/5.1.0/gcc/lib/cmake/Qt5Network/Qt5NetworkConfig.cmake

Qt5NetworkConfig.cmake定义了cmake相关规则,Qt5Network_INCLUDE_DIRS等定义均可在这个文件中找到

CMake undefined reference to `QTcpServer::QTcpServer(QObject*)'的解决的更多相关文章

  1. Linux+CLion+树莓派远程编译时,Cmake编译出现undefined reference to `vtable for MainWindow'的解决办法

    在win+CLion上进行远程qt开发时碰到以下错误: 错误提示: undefined reference to `vtable for MainWindow' 原因:源文件的目录结构有问题?? 解决 ...

  2. 关于undefined reference to `WSASocketA@24'问题的解决

    关于 Eclipse 开发C++ Socket  ,在开发的过程中 用WinGW 平台编译, 示例server端: #include <winsock2.h> #include <m ...

  3. [CentOS]CentOS下编译CPP文件时报错[undefined reference to `__gxx_personality_v0' collect2: ld]的解决办法

    在CentOS环境下编译CPP时报出 undefined reference to `__gxx_personality_v0' collect2: ld 以上错误,调查了一下,加上参数[-lstdc ...

  4. GCC编译uboot出现(.ARM.exidx+0x0): undefined reference to `__aeabi_unwind_cpp_pr0&#39;错误的解决的方法

    /opt/arm-2010.09/bin/../lib/gcc/arm-none-linux-gnueabi/4.5.1/armv4t/libgcc.a(_bswapsi2.o):(.ARM.exid ...

  5. cmake : undefined reference to dlopen, dlclose, dlsym and dlerror

    链接出了问题 添加头文件 #include <dlfcn.h> 添加库 target_link_libraries(PROJECT_NAME ${CMAKE_DL_LIBS})

  6. 编译nginx时提示undefined reference to 'pcre_free_study' 的问题及解决

    ./configure --add-module=../ngx_devel_kit-0.2.19/ --add-module=../lua-nginx-module-0.9.19/  --with-l ...

  7. undefined reference to `clock_gettime'编译错误的解决办法

    解决办法如下

  8. 利用gcc编译链接时出现 ‘undefined reference to `std::ios_base::Init::Init()’ 解决

    一般编译链接c++程序最好使用g++,若有如上的报错信息,需要在gcc后加上 -lstdc++ eg: gcc test.c -lstdc++ gcc和g++都是GNU的一个编译器. g++:后缀.c ...

  9. cmake 出现undefined reference to xxx 解决办法

    cmake没怎么用,主要觉得Clion很好用,但是默认clion使用的是cmake.再说一句clion是linux平台上很好用,个人强推. 当你使用clion的时候,如果使用了thread cstl等 ...

随机推荐

  1. 51nod1079(中国剩余定理)

    题目链接: http://www.51nod.com/onlineJudge/user.html#!userId=21687 题意: 中文题诶~ 思路: 本题就是个中国剩余定理模板题,不过模拟也可以过 ...

  2. 这两年在QQGame写过的游戏(2012.7.15-2014.8.25)

    [雷电]  Gamebryo         http://qqgamecdnimg.qq.com/help/rule177.html [英雄杀]          http://yxs.qq.com ...

  3. codeforces Round#381 div2

    第一题: 按余数分类,1,2,3分别由哪些基数组成 1->[1][2+3][3+3+3] 2->[1+1][2][3+3] 3->[1+1+1][1+2][3] #include&l ...

  4. IOC装配Bean(注解方式)

    Spring的注解装配Bean Spring2.5 引入使用注解去定义Bean @Component 描述Spring框架中Bean Spring的框架中提供了与@Component注解等效的三个注解 ...

  5. javascript数组去重的两个方法

    方法一: 创建一个临时数组,判断目标数组中每个元素是否在临时数组中,如果不在就添加进临时数组,最后return临时数组 <script> var arr=[1,2,3,4,5,1,2,3, ...

  6. js 无缝滚动效果学习

    <!DOCTYPE html> <html> <head> <title>无缝滚动测试</title> <meta http-equi ...

  7. VB下对HTML元素的操作

    <!DOCTYPE html> <html> <head> <title>test</title> </head> <bo ...

  8. C#对图片的操作

    1.根据图片路径返回字节 public static byte[] getImageByte(string imagePath) { FileStream files = new FileStream ...

  9. websocket 实现聊天功能

    <html> <head> <base href="<%=basePath%>"> <title>webscoket t ...

  10. ZK 页面间参数传递

    1.execution.sendRedirect(url) 当使用方法execution.sendRedirect(url)进行页面跳转时,在url中添加参数:url?test=5: 跳转页面获取参数 ...