1. 程式人生 > >初次使用Qt Creater網路程式設計,出現error: undefined reference to `

初次使用Qt Creater網路程式設計,出現error: undefined reference to ` 阿新 發佈:2019-02-17

在QT中編寫網路發報端/客戶端,時build時出現
error: undefined reference to `
[email protected]’等,很多網路類似的錯誤
等大約10條error,原因是socket庫的編譯連結問題。

網上的解決辦法:
錯誤原因:因為沒有聯接socket庫ws2_32.lib。因此要連結該庫
總結:所有運用到WinSock2的程式在編譯連線時都要用的該庫

===========================================================

我的解決辦法:
在專案的pro檔案中

QT += core gui

下面新增

LIBS += -lpthread libwsock32 libws2_32

即可。

記得要 #include<windows.h> 或者 #include<winsock2.h> 
並且 #include<winsock2.h>要放到#include<windows.h>前面

相關推薦

初次使用Qt Creater網路程式設計出現error: undefined reference to `<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="441b2d29341b1b131705173

在QT中編寫網路發報端/客戶端,時build時出現 error: undefined reference to `[email protected]’等,很多網路類似的錯誤 等大約10條e

win10 QtCreator5.10 編譯opengl出現 error: undefined reference to `<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="17487e7a6748487

1、在pro檔案中新增:  LIBS += -lopengl32 -lGLU32 -lglut 2、在程式中新增以下3個頭檔案: 3、下載glut32庫,(已上傳到本地),解壓出現以下5個檔案 為簡單起見,複製全部檔案到安裝路徑的三個地方:      

Eclipse c++ 中[Linker error] undefined reference to `<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4314100210372231373633037

今天搭建了一個Eclipse+MinGW的C++開發環境,Eclipse的使用就是方便。 於是,就寫了一個socket程式,MinGW支援winsock2,但到編譯的時候總是報錯:undefined reference to `[email protected]'

opencv errorundefined reference to `<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e7b3aea1a1b5828683a38e9582849388959ea7a

ubuntu16.04,在make opencv3.4.0 的時候,出現以下錯誤 解決方法: 參考:https://blog.csdn.net/wangchuansnnu/article/details/44241199  在 cmake 時,新增 cmake -D

git上傳到一半最後報error:failed to push some refs to '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a4c3cdd0e4c3cdd0ccd1c68ac7cbc9"

今天上傳程式碼到git上,上傳一半卡住了,過了一會兒就報: Counting objects: 52, done. Delta compression using up to 2 threads. Compressing objects: 100% (48/48), don

error LNK2005: "int dir" (<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dae5beb3a89a">[email protected]a>@3HA) alrea

方案一、 程式設計中經常能遇到LNK2005錯誤——重複定義錯誤,其實LNK2005錯誤並不是一個很難解決的錯誤。弄清楚它形成的原因,就可以輕鬆 解決它了。         造成LNK2005錯誤主要有以下幾種情況:     1.重複定義全域性變數。可能存在兩種情況:  

git push 時報錯 error: failed to push some refs to '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a3c4cad7e3dbdbdbdbdbdb">[ema

原因:這是一個新建的一個倉庫,提交到github時,沒有 pull下來,導致 github中的README.md檔案不在原生代碼目錄中 $ git push -u origin master To github.com:Houttuyniae/notes.git ! [

啟動hbase後出現ERROR [<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7a4b4f49484b4d4d4a4c493a0b0e0a574f4d494b4a4842424b5748">[em

2018-11-07 09:28:54,771 INFO [master:16000.activeMasterManager] util.FSUtils: Waiting for dfs to exit safe mode... 2018-11-07 09:29:04,783 INFO [mas

啟動hbase後出現ERROR [<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1e2f2b2d2c2f29292e282d5e6f6a6e332b292d2f2e2c26262f332c">[em

2018-11-07 09:28:54,771 INFO [master:16000.activeMasterManager] util.FSUtils: Waiting for dfs to exit safe mode... 2018-11-07 09:29:04,78

error LNK2019: 無法解析的外部符號 <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="702f031f131b1504304142">[email protected]a>

Reason: 學習使用socket,在stdafx.h檔案加了#include ,編譯 #include "stdafx.h" #include   using namespace std;   int _tmain(int argc

mysql叢集出現:Last_IO_Error: error connecting to master '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="493b2c392509313131">

網上的經驗:網路不同,賬號密碼不對,密碼太長,密碼由 # 字元;檢查MASTER_HOST,MASTER_USER,MASTER_PASSWORD(不知道 MASTER_LOG_FILE 有沒有影響) 但是,對我都沒用,突然想起來用navicat登陸mysql時出現報錯:   client does no

[轉]在vs2008上編譯獲取cpu程式碼出現的錯誤- error LNK2019: 無法解析的外部符號 <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="91ced6f4e5c1e3fef2f4e2e2

1>正在連結...1>LINK : 沒有找到 E:\yy\20110112\cpuproject\cpu\Debug\cpu.exe 或上一個增量連結沒有生成它;正在執行完全連結1>cpu.obj : error LNK2019: 無法解析的外部符號 ,該符號在函式 "void __cde

VS2008 error LNK2019: 無法解析的外部符號 __imp___vsnprintf該符號在函式 <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="712e220503181f162721

新裝了vs2008 sp1,開啟又前的專案竟然出現下面的連結錯誤: odbccp32.lib(dllload.obj) : error LNK2019: 無法解析的外部符號 __imp___vsnprintf,該符號在函式 [email protected] 中被

【原創】叢集搭建報“Error unable to connect to nodes ['<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="96e4f7f4f4ffe2d6e4fbe7bbf8a7

在rabbitmq叢集搭建時,將rmq-n2和rmq-n3兩節點加入rmq-n1時,報如下錯: 解決辦法: rabbitmq叢集是基於erlang叢集的,而erlang叢集中各節點間的通訊是通過4369埠和25672埠來進行通訊的, 所以:防火牆開啟4369埠和25672埠&nbs

無法解析的外部符號 <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1e41497770537f77705e2f28">[email protected]a>該符號在函式 ___tmai

#include using namespace std; int main() { cout <<“This is a C++ program.”; return 0; } 1>------ 已啟動生成: 專案: hello1, 配置: Debug Win32 ---

解決碼雲出現<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3b5c524f7b5c524f5e5e15585456">[email protected]a>: Permission de

很久之前好像改了ssh的一些配置,導致現在對git進行一些操作時,就會出現  當時就去百度,結果很多都是一些不太對應的解決方法,反正也沒有解決,今天偶然看碼雲的文件才突然解決。 官方解決文件:  http://git.mydoc.io/?t=154712 1)、重新生成

[Visual Studio C++] [MFC 除錯錯誤]:error LNK2019: 無法解析的外部符號 <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c09f9fa9adb09f9fb4a9a

1.編譯問題描述:  error LNK2019: 無法解析的外部符號 [email protected],該符號在函式 "public: unsigned int __thiscall CMultimediatimerDlg::CreateTimer(void)" ([em

mfcs100ud.lib(dllmodul.obj) : error LNK2005: <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="da859eb6b697bbb3b49aebe8">[email

今天用VC2010寫一個用了MFC的規則DLL,編譯時報告如題錯誤。 必應後發現這篇文章  error LNK2005: [email protected] 已經在 MSVCRTD.lib(dllmain.obj) 中定義   http://wangl

Makefile有三個非常有用的變數。分別是<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a480e4">[email protected]a>$^$

原文地址:https://blog.csdn.net/u013774102/article/details/79043559 假設我們有下面這樣的一個程式,原始碼如下:  /* main.c */ #include "mytool1.h" #include "mytool2.h" i