VC++6.0中如何编译运行C语言程序
VC++6.0是Microsoft公司推出的一个基于Windows系统平台、可视化的集成开发环境,它的源程序按C++语言的要求编写,并加入了微软提供的功能强大的MFC(Microsoft Foundation Class)类库。具有高度可视化的应用程序开发工具,不仅适合大型软件的开发,对于初学C语言和C++的朋友来说,也是一个不错的运行工具。
接下来笔者就简单介绍一下VC++6.0如何编译运行C语言程序
1.单个源文件的编译运行
例如下面的源代码
#include void main() { int i,sum=0; for(i=1;i<=10;i++) { sum=sum+i; } printf("sum=%d ",sum); } 打开VC++6.0,如图1所示
(图1)
选择“文件”→“新建”,打开如图2所示
(图2)
选择“文件”项,如图3所示
(图3)
选择“C++ Source File”项,并在“文件名”项目下输入“sum.c”如图4所示
(图4) 单击“确定”,打开如图5所示
(图5)
输入如上源代码,如图6所示
(图6)
选择“组建”→“编译”(或按Ctrl+F7组合键),打开如图7所示
(图7)
在下端的输出窗口会有错误和警告的提示,如果没有错误选择“组建”→“执行”(或按Ctrl+F5组合键)即可出现运行结果,如图8所示
(图8)
2.多个源文件的编译运行
以上是运行单个源文件的情况,但是在程序设计时,往往是由几个人各自独立编写不同的程序,显然这些程序是不能写在一起进行编译的,这时就需要建立项目工作区来完成几个独立程序的编译,具体方法如下。
首先建立两个文本文件,分别命名为“file1.c”和“file.c”,分别在两个文件中输入如下两个源代码,然后保存。 源代码1:
#include void main() {
} void sum(); sum(); 源代码2:
#include void sum() {
} int i,sum=0; for(i=1;i<=10;i++) { } printf("sum=%d ",sum); sum=sum+i; 打开VC++6.0,选择“文件”→“新建”打开如图9所示
(图9)
选择“工作区”项,并在“工作空间名称”项目下输入“sum”如图10所示
(图10) 单击“确定”,打开如图11所示
(图11)
在左侧的“工作区窗口”显示了新建立的工作区
选择“文件”→“新建”打开如图9所示,在“工程”项目下选择“Win32 Console Application”项,并在“工程名称”项目下输入工程名称,如“sum”,选择“添加到当前工作空间”项,如图12所示
(图12)
单击“确定”,打开如图13
(图13)
选择“一个空工程”项,单击“完成”,打开如图14所示
(图14)
单击“确定”,打开如图15所示
(图15)
在左侧的“工作区窗口”显示了新建立的工程
选择“工程”→“添加到工程”→“文件”,打开如图16所示
(图16)
选择刚刚创建的两个文件,单击“确定”,打开如图17所示
(图17)
选择“组建”→“组建”(或按F7键),打开如图18所示
(18)
在下端的输出窗口会有错误和警告的提示,如果没有错误选择“组建”→“执行”(或按Ctrl+F5)即可出现运行结果,如图19所示
(图19)
IAR 6.20编译错误清单
1、 ①错误描述:Tool Internal Error:
Internal Error: [CoreUtil/General]: Access violation (0xc0000005) at 007588A5 (reading from address 0x0)
Internal Error: [CoreUtil/General]: Access violation (0xc0000005) at 007588A5 (reading from address 0x0)
Error while running C/C++ Compiler
②错误原因:High配置设置为Size,应该为Low
2、 ①错误描述:Fatal Error[Pe1696]: cannot open source file "inc/hw_types.h" E:StellarisWareM3_9D92oardsdk-lm3s9b96oot_demo2oot_demo2.c 25②错误原因:C/C++ Complier(Assember)->Preprocessor->Additional include directories: $PROJ_DIR$.$PROJ_DIR$..
$PROJ_DIR$......
3、 ①错误描述:Fatal Error[Pe1696]: cannot open source file
"lwip/opt.h"
E:StellarisWareM3_9D92utilslwiplib.h 4
4②错误原因:C/C++ Complier-(Assember)>Preprocessor->Additional include directories:
$PROJ_DIR$...... hird_partylwip-1.3.2apps
$PROJ_DIR$...... hird_partyget
$PROJ_DIR$...... hird_partylwip-1.3.2portsstellarisinclude
$PROJ_DIR$...... hird_partylwip-1.3.2srcinclude
$PROJ_DIR$...... hird_partylwip-1.3.2srcincludeipv4
$PROJ_DIR$...... hird_partylwip-1.3.2srcincludelwip
$PROJ_DIR$...... hird_party
4、 ①错误描述:Fatal Error[Pe035]: #error directive: Unrecognized COMPILER! E:StellarisWareM3_9D92oardsdk-lm3s9b96driversset_pinout.h 59
Error while running C/C++ Compiler
②错误原因:C/C++ Complier-(Assember)>Preprocessor->Defined symbols: ewarm
5、 ①错误描述:Error[Pe020]: identifier "ROM_pvAESTable" is undefined E:StellarisWareM3_9D92 hird_partyaesaes.c 319
②错误原因:
6、 ①错误描述:Error[Li005]: no definition for "main" [referenced from cmain.o(rt7M_tl.a)]Error while running Linker
②错误原因:定义函数:int main(void) { return (0); }
7、 ①错误描述:Error[Li005]: no definition for "main" [referenced from cmain.o(rt7M_tl.a)]Error while running Linker
②错误原因:如果是库是库函数,在:General Options->Output->Output file:选择: Library项
4、 ①错误描述:Fatal Error[Pe1696]: cannot open source file "uip.h" E:StellarisWareM3_9D92 hird_partyuip-1.0appsdhcpcdhcpc.c 37
②错误原因:
5、 ①错误描述:
②错误原因:
$PROJ_DIR$...... hird_partylwip-1.3.2apps
$PROJ_DIR$...... hird_partyget
$PROJ_DIR$...... hird_partylwip-1.3.2portsstellarisinclude
$PROJ_DIR$...... hird_partylwip-1.3.2srcinclude
$PROJ_DIR$...... hird_partylwip-1.3.2srcincludeipv
4$PROJ_DIR$...... hird_party
$PROJ_DIR$...... hird_partyuip-1.0
$PROJ_DIR$...... hird_partyuip-1.0uip
$PROJ_DIR$...... hird_partyuip-1.0apps
$PROJ_DIR$...... hird_partyspeex-1.2rc1include
$PROJ_DIR$...... hird_partyspeex-1.2rc1includespeex
$PROJ_DIR$...... hird_partyspeex-1.2rc1stellaris
6、 ①错误描述:Fatal Error[Pe035]: #error directive: You now need to define either FIXED_POINT or FLOATING_POINT E:StellarisWareM3_9D92 hird_partyspeex-1.2rc1libspeexarch.h 65②错误原因:
7、 ①错误描述:Fatal Error[Pe035]: #error directive: "Unrecognized/undefined driver for DISK0!"
E:StellarisWareM3_9D92 hird_partyfatfsportdual-disk-driver.c 6
2Error while running C/C++ Compiler
②错误原因:
UART_BUFFERED
DISK0_DK_LM3S9B96
DISK1_USB_MSC
INCLUDE_BGET_STATS
8、 ①错误描述:Error[Pe020]: identifier "ROM_pvAESTable" is undefined E:SWM3_9D92(6.20) hird_partyaesaes.c 359
Error while running C/C++ Compiler
②错误原因:
10、 ①错误描述:Fatal Error[Pe035]: #error directive: You now need to define either FIXED_POINT or FLOATING_POINT E:SWM3_9D92(6.20) hird_partyspeex-1.2rc1libspeexarch.h 6
5Error while running C/C++ Compiler
②错误原因:
11、 ①错误描述:
Error[Li005]: no definition for "ROM_SysCtlClockSet" [referenced from E:SWM3_9D92(6.20)oardsdk-lm3s9b96safertos_demoDebugObjsafertos_demo.o] Error[Li005]: no definition for "ROM_FlashUserGet" [referenced from E:SWM3_9D92(6.20)oardsdk-lm3s9b96safertos_demoDebugObjlwip_task.o]
Error[Li005]: no definition for "ROM_IntPrioritySet" [referenced from E:SWM3_9D92(6.20)oardsdk-lm3s9b96safertos_demoDebugObjlwip_task.o]
Error[Li005]: no definition for "ROM_GPIOPinTypeGPIOOutput" [referenced from E:SWM3_9D92(6.20)oardsdk-lm3s9b96safertos_demoDebugObjled_task.o]
Error[Li005]: no definition for "ROM_GPIOPinWrite" [referenced from E:SWM3_9D92(6.20)oardsdk-lm3s9b96safertos_demoDebugObjled_task.o]
Error[Lp011]: section placement failed: unable to allocate space for sections/blocks with a total estimated minimum size of 0x11e54 bytes
in
<[0x20000000-0x2000ffff]> (total uncommitted space 0x10000).Error while running Linker
②错误原因:
12、 ①错误描述:
Error[Lp011]: section placement failed: unable to allocate space for sections/blocks with a total estimated minimum size of 0x11e54 bytes in <[0x20000000-0x2000ffff]> (total uncommitted space 0x10000).
Error while running Linker
1. make: ***
[out/host/linux-x86/obj/STATIC_LIBRARIES/libMesa_intermediates/src/glsl/linker.o] Error 1 解决方法: vim external/mesa3d/src/glsl/linker.cpp
添加:
#include
2. make: ***
[out/host/linux-x86/obj/EXECUTABLES/test-librsloader_intermediates/test-librsloader] Error 1 解决办法:
vim external/llvm/llvm-host-build.mk
添加:
LOCAL_LDLIBS := -lpthread-ldl
3. make: ***
[out/host/linux-x86/obj/STATIC_LIBRARIES/libgtest_host_intermediates/gtest-all.o] Error 1 解决方法:
vim external/gtest/include/gtest/internal/gtest-param-util.h
添加:
#include
4.
注:本文为网友上传,旨在传播知识,不代表本站观点,与本站立场无关。若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:iwenmi@163.com。举报文章