VC编译器的调用 ( 积分: 50 )

  • 主题发起人 主题发起人 tristoneq
  • 开始时间 开始时间
T

tristoneq

Unregistered / Unconfirmed
GUEST, unregistred user!
我想做以用做脚本编译的程序,通过调用VC6的编译器将代码编译生成WIN32的动态链接库,请问该如何实现?
 
我想做以用做脚本编译的程序,通过调用VC6的编译器将代码编译生成WIN32的动态链接库,请问该如何实现?
 
http://www.delphibbs.com/delphibbs/dispq.asp?lid=3191927
 
参考http://czvc.com/down.asp?id=94<br>如何在命令行下编译创建VC程序<br><br>------------------我只贴用到的部分,其他的楼主自己去找,关键是使用CL<br>如何在命令行下编译创建VC程序<br><br>大多数MS Visual C++创建的程序用VC编译器是很容易编译并创建出可执行文件的。但有时,你可能需要从命令提示行运行程序。这个例子将阐述如何用命令行编译创建VC程序。<br><br>VC默认安装成功后,并不具备能从命令行编译创建VC程序这一特征。我们必须做如下3步工作:<br><br>1 打开DOS命令提示符窗口。<br><br>2 在C盘根目录下输入:<br>CD Program Files/Microsoft Visual Studio/VC98/Bin<br>回车进入到如下目录:<br>C:/Program Files/Microsoft Visual Studio/VC98/Bin&gt;<br><br>3 然后输入VCVARS32再回车,你可以看到如下信息:<br>C:/Program Files/Microsoft Visual Studio/VC98/Bin&gt;VCVARS32<br>Setting environment for using Microsoft Visual C++ tools.<br>如图1:<br><br><br>图1<br><br><br>好了,至此相关设置完成,接下来我们将在命令行下编译创建一个VC程序:<br><br>1 打开VC,选择NEW,在工程属性页选择“Win32 Console Application”,这里我把它命名为AConsoleApp,<br>我的工程目录为:D:/MyProgram2/AConsoleApp,然后OK创建一个空的Win32控制台工程。<br><br>2 新建一个C++文档main.cpp,输入如下代码:<br>#include <br>using namespace std;<br><br>int main()<br>{<br>cout &lt;&lt; &quot;/nC++ is Fun!!!/n&quot;;<br>return 0;<br>}<br>保存所有文档,关闭工程。<br><br>3 打开DOS命令提示符窗口,使当前目录为D:/MyProgram2/AConsoleApp&gt;,然后输入CL main.cpp,回车,可以看到如下信息:<br>D:/MyProgram2/AConsoleApp&gt;CL main.cpp<br>Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86<br>Copyright (C) Microsoft Corp 1984-1998. All rights reserved.<br><br>main.cpp<br>C:/Program Files/Microsoft Visual Studio/VC98/include/istream(547) : warning C45<br>30: C++ exception handler used, but unwind semantics are not enabled. Specify -G<br>X<br>C:/Program Files/Microsoft Visual Studio/VC98/include/ostream(234) : warning C45<br>30: C++ exception handler used, but unwind semantics are not enabled. Specify -G<br>X<br>C:/Program Files/Microsoft Visual Studio/VC98/include/ostream(229) : whi<br>le compiling class-template member function 'class std::basic_ostream t std::char_traits &gt; &amp;__thiscall std::basic_ostream traits &gt;::put(char)'<br>C:/Program Files/Microsoft Visual Studio/VC98/include/ostream(234) : warning C45<br>30: C++ exception handler used, but unwind semantics are not enabled. Specify -G<br>X<br>C:/Program Files/Microsoft Visual Studio/VC98/include/ostream(229) : whi<br>le compiling class-template member function 'class std::basic_ostream hort,struct std::char_traits &gt; &amp;__thiscall std::basic_ostream signed short,struct std::char_traits &gt;::put(unsigned short)'<br>C:/Program Files/Microsoft Visual Studio/VC98/include/istream(46) : warning C453<br>0: C++ exception handler used, but unwind semantics are not enabled. Specify -GX<br><br>C:/Program Files/Microsoft Visual Studio/VC98/include/istream(41) : whil<br>e compiling class-template member function 'bool __thiscall std::basic_istream har,struct std::char_traits &gt;::ipfx(bool)'<br>C:/Program Files/Microsoft Visual Studio/VC98/include/istream(46) : warning C453<br>0: C++ exception handler used, but unwind semantics are not enabled. Specify -GX<br><br>C:/Program Files/Microsoft Visual Studio/VC98/include/istream(41) : whil<br>e compiling class-template member function 'bool __thiscall std::basic_istream nsigned short,struct std::char_traits &gt;::ipfx(bool)'<br>C:/Program Files/Microsoft Visual Studio/VC98/include/xstring(525) : warning C45<br>30: C++ exception handler used, but unwind semantics are not enabled. Specify -G<br>X<br>C:/Program Files/Microsoft Visual Studio/VC98/include/xstring(521) : whi<br>le compiling class-template member function 'void __thiscall std::basic_string har,struct std::char_traits,class std::allocator &gt;::_Copy(unsigned i<br>nt)'<br>C:/Program Files/Microsoft Visual Studio/VC98/include/ostream(296) : warning C45<br>30: C++ exception handler used, but unwind semantics are not enabled. Specify -G<br>X<br>main.cpp(6) : see reference to function template instantiation 'class st<br>d::basic_ostream &gt; &amp;__cdecl std::operator &lt;&lt;(<br>class std::basic_ostream &gt; &amp;,const char *)' b<br>eing compiled<br>Microsoft (R) Incremental Linker Version 6.00.8168<br>Copyright (C) Microsoft Corp 1992-1998. All rights reserved.<br><br>/out:main.exe<br>main.obj<br><br>D:/MyProgram2/AConsoleApp&gt;<br><br><br>此时你可以发现目录D:/MyProgram2/AConsoleApp&gt;下已经生成了可执行文件main.exe,您可以在命令行环境下执行它,输入main并回车,结果如下:<br>D:/MyProgram2/AConsoleApp&gt;main<br>----------------------------<br>另外参考<br><br>http://www.pcvc.net/category/content.asp?sendid=194
 
后退
顶部