[問題] unidentified reference to ...

看板C_and_CPP (C/C++)作者 (罐頭)時間14年前 (2012/02/03 12:18), 編輯推噓0(004)
留言4則, 3人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) Dev C++ 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) <iostream> 還有自訂的 "GradeBook.h" 問題(Question): 現在在自習 C++ How To Progarm (Paul Deitel, Harvey Deitel) 這本書的第3.8節 把自己寫的 class 拆成 interface 和 implementation 兩部分 完全照著課本打 建立了 GradeBook.h GradeBook.cpp 和 test.cpp 三個檔案 不過在執行時都出現了以下3個錯誤訊息 [Linker error] unidentified reference to 'WinMain@16' Id returned 1 exit status [Build Error] [GradeBook.exe] Error 1 是我開啟的檔案類型有誤嗎?還是需要做甚麼設定才能讓他們一起執行呢? 餵入的資料(Input): 預期的正確結果(Expected Output): 錯誤結果(Wrong Output): 程式碼(Code):(請善用置底文網頁, 記得排版) GradeBook.h http://codepad.org/GfKWIgyi GradeBook.cpp http://codepad.org/KcuVf4lP test.cpp http://codepad.org/8teJyKSp 補充說明(Supplement): -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.252.56 ※ 編輯: kennyli 來自: 140.112.4.183 (02/03 12:21) ※ 編輯: kennyli 來自: 140.112.4.183 (02/03 12:22)

02/03 12:27, , 1F
程式本身沒問題,大概是專案開錯或設定錯誤
02/03 12:27, 1F

02/03 12:29, , 2F
所以是建立專案時類型設定錯了嗎?
02/03 12:29, 2F

02/03 12:30, , 3F
可能吧,跟dev-C++不熟
02/03 12:30, 3F
解決了 1. 打開 Dev C++ 開啟 Project 選擇 Console Application 2. 將要一起執行的 .cpp檔加入專案(包括定義 member function 的 .cpp檔也要) 3. 執行含有 main 的檔案就OK了 資料來源:http://www.cplusplus.com/forum/beginner/25188/ ※ 編輯: kennyli 來自: 140.112.252.56 (02/03 14:55)

02/03 14:59, , 4F
所以是因為兩個檔案沒有被加入專案裡面的意思嗎?
02/03 14:59, 4F
文章代碼(AID): #1FAs0JwP (C_and_CPP)
文章代碼(AID): #1FAs0JwP (C_and_CPP)