線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1801
推到 Plurk!
推到 Facebook!

請問如何用console模式編譯win32 api程式??

尚未結案
Flame
一般會員


發表:15
回覆:16
積分:6
註冊:2003-05-23

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-10-27 13:10:04 IP:203.67.xxx.xxx 未訂閱
我想用console mode編譯win32 api程式,卻會發生錯誤 請問是不是要做什麼設定? 編譯c/c 程式都可正常執行 程式確定沒有錯誤,因為可用vc ide編譯成功且執行 執行結果如下 E:\Temp\2003_10>cl sample01.cpp Microsoft (R) 32-bit C/C Optimizing Compiler Version 12.00.8804 for 80x86 Copyright (C) Microsoft Corp 1984-1998. All rights reserved. sample01.cpp Microsoft (R) Incremental Linker Version 6.00.8447 Copyright (C) Microsoft Corp 1992-1998. All rights reserved. /out:sample01.exe sample01.obj sample01.obj : error LNK2001: unresolved external symbol __imp__DispatchMessageA @4 sample01.obj : error LNK2001: unresolved external symbol __imp__TranslateMessage @4 sample01.obj : error LNK2001: unresolved external symbol __imp__GetMessageA@16 sample01.obj : error LNK2001: unresolved external symbol __imp__RegisterClassExA @4 sample01.obj : error LNK2001: unresolved external symbol __imp__GetStockObject@4 sample01.obj : error LNK2001: unresolved external symbol __imp__GetMessageA@16 sample01.obj : error LNK2001: unresolved external symbol __imp__RegisterClassExA sample01.obj : error LNK2001: unresolved external symbol __imp__GetStockObject@4 sample01.obj : error LNK2001: unresolved external symbol __imp__LoadImageA@24 sample01.obj : error LNK2001: unresolved external symbol __imp__UpdateWindow@4 sample01.obj : error LNK2001: unresolved external symbol __imp__ShowWindow@8 sample01.obj : error LNK2001: unresolved external symbol __imp__CreateWindowExA@ 48 48 sample01.obj : error LNK2001: unresolved external symbol __imp__DefWindowProcA@1 6 sample01.obj : error LNK2001: unresolved external symbol __imp__PostQuitMessage@ 4 sample01.exe : fatal error LNK1120: 11 unresolved externals 請問如何解決這個問題?謝謝 (用bcb/vc皆可)
------
~人世變成了一場夢,夢境成為真實~
richtop
資深會員


發表:122
回覆:646
積分:468
註冊:2003-06-10

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-11-13 23:49:59 IP:211.76.xxx.xxx 未訂閱
Flame 您好:    因手邊沒有VC,所以以BCB為例。 可能在編譯時您忘了指定適當的參數,如底下的'-W'參數才能編譯成Windows執行檔: >bcc32 -W  YourProgram.cpp    不過如果您有使用resource時,那就必須在編譯時也將resource包括進來,但是這部分我也沒做過,建議參考VC的make檔,或許可以知道在編譯時,VC使用哪些參數或指令與如何引入資源檔。    底下列出bcc32的編譯參數: C:\Dev-Cpp\Examples\WinMenu>bcc32 -h  Borland C++ 5.6 for Win32 Copyright (c) 1993, 2002 Borland Available options (* = default setting, xxx = has sub-options: use -h -X): (Note: -X- or -w-XXX will usually undo whatever was set or unset by -X)   -3      Generate 80386 protected-mode compatible instructions   -4      Generate 80386/80486 protected-mode compatible instructions   -5      Generate Pentium instructions   -6      Generate Pentium Pro instructions   -Axxx   Use ANSI keywords and extensions   -B      Compile to .ASM (-S), then assemble to .OBJ   -C      Enable nested comments   -CP     Enable code paging (for MBCS)   -D      -D defines 'name' as a null string, or use -D= -E Specify which assembler to use -G Optimize for size/speed; use -O1 and -O2 instead -Hxxx Generate and use precompiled headers -I Set the include file search path -Jxxx Template generation options -K Set default character type to unsigned -L Library file search path -M Create a linker map file -O Optimize jumps -P Perform C compile regardless of source extension -Q Extended compiler error information -R Include browser information in generated .OBJ files * -RT Enable runtime type information -S Compile to assembly -T Specify assembler option, e.g. -Tx -U Undefine any previous definitions of name -Vxxx Compatibility options -Wxxx Target is a Windows application -X Disable compiler autodependency output -axxx Set data alignment boundary. Default is -a8; -a- means -a1 * -b Make enums integer-sized (-b- makes them short as possible) -c Compile to object file only, do not link -d Merge duplicate strings -dc Put strings into the read-only data segment -dw Put strings into the (writeable) data segment -e Specify target executable pathname * -ff Fast floating point -fp Correct Pentium FDIV flaw -g Stop batch compilation after n warnings (Default = 255) -h Request help ('-h -' shows all help). Can be specific: -h -V -i Set maximum significant identifier length (Default = 250) -j Stop batch compilation after n errors (Default = None) * -k Generate standard stack frames -l Pass options to the linker; example: -ls -l-x -m Generate makefile dependency information -md Put dependency info in .d files, not in the object file -mm Ignore system header files while generating dependency info -mo Specify the output file for dependency info -n Set output directory for object files -o Set output filename (-o or -o supported) -pxxx Use Pascal calling convention -q Suppress compiler identification banner -r Use register variables -rd Use register variables only when register keyword is employed -s Link using the system's non-incremental linker -txxx An alternate name for the -Wxxx switches; there is no difference * -u Generate underscores on symbol names -vxxx Turn on source debugging -w Display all warnings -w! Return non-zero from compiler on warnings -xxxx Enable exception handling -y Debug line numbers on
jcjroc
高階會員


發表:21
回覆:279
積分:115
註冊:2002-09-18

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-11-14 09:24:39 IP:211.75.xxx.xxx 未訂閱
先生,你的原因是未連結Lib檔,找不到Funtion 一般來說是你沒有#include "windows.h"所致
系統時間:2024-05-04 8:43:56
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!