看板 C_and_CPP 關於我們 聯絡資訊
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) DevC++ 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) 另外設置的.h標頭檔 問題(Question): 前些日子研讀了此篇https://www.ptt.cc/bbs/C_and_CPP/M.1316515713.A.567.html 因為作業上也需要利用cmd指令一步步將cpp檔轉成exe檔 不過額外的要求是加入.h標頭檔一起執行成為exe檔 我一直以為是在linker時加入 指令如下 C:\Dev-Cpp\MinGW64\bin\ld.exe "D:\104_1\demo.o" "D:\104_1\demo.h" -o "D:\104_1\demo.exe" 不過並沒有成功 希望版上的各位大大可以協助解決>< 餵入的資料(Input): C:\Dev-Cpp\MinGW64\bin\ld.exe "D:\104_1\demo.o" "D:\104_1\demo.h" -o "D:\104_1\demo.exe" 預期的正確結果(Expected Output): exe檔製作成功 錯誤結果(Wrong Output): D:\104_1\demo.h: file not recognized: File format not recognized 程式碼(Code):(請善用置底文網頁, 記得排版) 參考此篇的code http://pydoing.blogspot.tw/2013/02/cpp-header-file.html 補充說明(Supplement): 謝謝大家>< -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 163.25.118.40 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1445527034.A.1AD.html
LPH66: 你應該知道 #include 這個東西吧? 10/22 23:28
bdvstg: 好可愛XDDD 10/22 23:34
machia045413: 我知道>< 這邊的include是指include .h檔嗎? 10/22 23:34
machia045413: 如果沒有沒有管.h檔 直接弄成exe檔執行 沒辦法耶>< 10/22 23:36
LPH66: 既然是作業, 找個同學問吧; 看起來你不太清楚 .h 檔的用途 10/22 23:38
bdvstg: .h是編譯時用的 不是連結時用的 10/22 23:41
bdvstg: 而且我用時gcc也沒加入過.h檔 只在include時加過 10/22 23:42
bdvstg: 所以我也不確定餵.h給gcc會發生啥事 10/22 23:44
bdvstg: 你可能也需要了解一下 編譯、連結、載入是怎回事 10/22 23:46
bdvstg: 我們那時候是有先教這個 不過那時候其實不理解 只是硬背XD 10/22 23:47
x000032001: 如果不用gcc 用cpp,cc1,ld...那要在cpp的時候加.h 10/23 00:02
LPH66: 就算是這樣也不是在指令行上加, 所以我才問他 #include 10/23 00:09
LPH66: (雖然確實是有參數指示先引入這個檔再編譯就是) 10/23 00:10
bdvstg: 我剛剛查了一下gcc跟cpp的男人 發現他們都會吃.h檔耶!! 10/23 00:39
TobyH4cker: ㄈㄓ 10/27 14:47