mikelee Posted October 20, 2004 Posted October 20, 2004 I am really having a hard time building a simple c++ program with Nant. If someone could tell me step by step what I need to do, I would GREATLY appreciate it. I have the latest nightly built version of Nant (0.85, 10/20/1004) and built it successfully on my computer. I looked in the example folder and tried to build the example in c:\nant\examples\solutions\cpp\winforms but my build failed. This is what I got: ********************************************************** C:\nant\examples\Solution\cpp\WinForms>nant NAnt 0.85 (Build 0.85.1754.0; net-1.0.win32; nightly; 10/20/2004) Copyright © 2001-2004 Gerry Shaw http://nant.sourceforge.net Buildfile: file:///C:/nant/examples/Solution/cpp/WinForms/cpp.build Target(s) specified: rebuild clean: [delete] Deleting 5 directories. build: build.winforms: [solution] Starting solution build. [solution] Building 'WinForms' [release] ... [cl] Compiling 1 files to 'C:\nant\examples\Solution\cpp\WinF orms\obj\Release'. BUILD FAILED 'cl' failed to start. The system cannot find the file specified Total time: 1.5 seconds. ********************************************************** I don't understand why cl.exe can't be found. I looked inside, "c:\program files\microsoft visual studio .net 2003\vc7\bin" and found cl.exe. Also in "c:\nant\examples\helloworld" I opened the default.build file and edited so that it can build my simple HelloWorld.cpp file: ********************************************************** <?xml version="1.0"?> <project name="Hello World" default="run"> <property name="basename" value="HelloWorld"/> <property name="debug" value="true"/> <target name="clean"> <delete> <fileset> <include name="${basename}-??.exe"/> <include name="${basename}-??.pdb"/> </fileset> </delete> </target> <target name="build"> <csc target="exe" output="${basename}-cs.exe" debug="${debug}"> <sources> <include name="${basename}.cs"/> </sources> </csc> <jsc target="exe" output="${basename}-js.exe" debug="${debug}"> <sources> <include name="${basename}.js"/> </sources> </jsc> <vbc target="exe" output="${basename}-vb.exe" debug="${debug}"> <sources> <include name="${basename}.vb"/> </sources> </vbc> <cl outputdir="build" options="/clr"> <sources> <include name="${basename}.cpp"/> </sources> </cl> </target> <target name="run" depends="build"> <exec program="${basename}-cs.exe" basedir="."/> <exec program="${basename}-js.exe" basedir="."/> <exec program="${basename}-vb.exe" basedir="."/> <exec program="${basename}-cpp.exe" basedir="."/> </target> </project> ********************************************************** Once I build the file, I get the same build fail message as before stating that cl could not be found. I am pulling all my hair out trying to figure out how to fix this problem. I am running on a .Net 1.1 platform and tried everything. Please HELP! :o Quote
mocella Posted October 21, 2004 Posted October 21, 2004 Have you run "vsvars32.bat" yet? (C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools) This should let NANT find CL.exe - that's what I posted that link for in your last thread. Let me know if that fixes it. Quote
mikelee Posted October 21, 2004 Author Posted October 21, 2004 Nice it compiles!!!! THANK YOU! Hmmmm thats weird though, I tried that before when you posted that in the last thread, but it didnt work. Now that I have it compiling c++ let me ask one more question. In my helloworld.cpp file, this is how it looks: ********************************************************** <iostream.h> void main() { cout << "Hello World" << endl; } ********************************************************** and my build file looks like this: ********************************************************** <?xml version="1.0"?> <project name="Hello World" default="run"> <property name="debug" value="true"/> <target name="clean" description="remove all generated files"> <delete file="HelloWorld.exe" if="${file::exists('HelloWorld.exe')}" /> <delete file="HelloWorld.pdb" if="${file::exists('HelloWorld.pdb')}" /> </target> <target name="build" description="compiles the source code"> <cl outputdir="build" options="/clr"> <sources> <include name="HelloWorld.cpp" /> </sources> </cl> </target> <target name="run" depends="build"> <exec program="HelloWorld.exe" /> </target> </project> ********************************************************** When I build with this build script, I get alot of errors. What do you see wrong? I appreciate your help! Quote
mocella Posted October 22, 2004 Posted October 22, 2004 Well, I did some digging, and I'm by no means a VC++, so this is totally specualation, but here's the compile script generate in VS2003 with a simple HelloWorld console app - somehow, you'll need to make this into NANT tasks/options. This is from BuildLog.htm which VS2003 generates when you compile a C++ project: Creating temporary file "d:\Cpp Test\HelloWorld\Debug\RSP000001.rsp" with contents [ /Od /AI "D:\Cpp Test\HelloWorld\Debug" /D "WIN32" /D "_DEBUG" /D "_MBCS" /FD /EHsc /MTd /GS /Yu"stdafx.h" /Fp"Debug/HelloWorld.pch" /Fo"Debug/" /Fd"Debug/vc70.pdb" /W3 /c /Zi /clr /TP /FU "C:\WINNT\Microsoft.NET\Framework\v1.1.4322\mscorlib.dll" /FU "C:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.dll" /FU "C:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.Data.dll" ".\AssemblyInfo.cpp" ".\HelloWorld.cpp" ] Creating command line "cl.exe @"d:\Cpp Test\HelloWorld\Debug\RSP000001.rsp" /nologo" Creating temporary file "d:\Cpp Test\HelloWorld\Debug\RSP000002.rsp" with contents [ /Od /AI "D:\Cpp Test\HelloWorld\Debug" /D "WIN32" /D "_DEBUG" /D "_MBCS" /FD /EHsc /MTd /GS /Yc"stdafx.h" /Fp"Debug/HelloWorld.pch" /Fo"Debug/" /Fd"Debug/vc70.pdb" /W3 /c /Zi /clr /TP /FU "C:\WINNT\Microsoft.NET\Framework\v1.1.4322\mscorlib.dll" /FU "C:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.dll" /FU "C:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.Data.dll" ".\stdafx.cpp" ] Creating command line "cl.exe @"d:\Cpp Test\HelloWorld\Debug\RSP000002.rsp" /nologo" Creating command line "rc.exe /fo"Debug/app.res" ".\app.rc"" Creating temporary file "d:\Cpp Test\HelloWorld\Debug\RSP000003.rsp" with contents [ /OUT:"D:\Cpp Test\HelloWorld\Debug\HelloWorld.exe" /INCREMENTAL /NOLOGO /DEBUG /ASSEMBLYDEBUG /PDB:"D:\Cpp Test\HelloWorld\Debug/HelloWorld.pdb" /FIXED:No kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ".\Debug\HelloWorld.obj" ".\Debug\AssemblyInfo.obj" ".\Debug\stdafx.obj" ".\Debug\app.res" ] Creating command line "link.exe @"d:\Cpp Test\HelloWorld\Debug\RSP000003.rsp"" Quote
mocella Posted October 22, 2004 Posted October 22, 2004 Also, here's a cleaned-up build file: <?xml version="1.0"?> <project name="Hello World" default="run"> <property name="debug" value="true"/> <target name="clean" description="remove all generated files"> <delete file="HelloWorld.exe" failonerror="false" /> <delete file="HelloWorld.pdb" failonerror="false" /> </target> <target name="build" description="compiles the source code" depends="clean"> <cl outputdir="D:\Cpp Test\" options="/clr"> <sources> <include name="HelloWorld.cpp" /> </sources> </cl> </target> <target name="run" depends="build"> <exec program="HelloWorld.exe" /> </target> </project> Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.