help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: newbie question


From: Guy Harrison
Subject: Re: newbie question
Date: Mon, 23 Aug 2004 00:01:37 GMT
User-agent: KNode/0.7.7

Joe wrote:

> Hi, I have a problem in executing a program compiled by myself.
> 
> My Environment is WinXp sp1.
> I installed cygwin 1.5.10-3, and g++(gcc) 3.3.3.
> Then I launched cygwin and used nano to create a cpp file named
> "test.cpp". The file content is here:
> 
> 
> 
> #include <iostream>
> 
> using namespace std;
> 
> int main()
> {
>    cout << "Hello";
>    return (0);
> }
> 
> 
> Then back to the console, I type "g++ test.cpp -o test".
> Fortunately, I got no errors and a file "test.exe" in the same directory.
> 
> But I got a problem here.
> When I type "test" or "test.exe" to execute that program, nothing
> happened. There isn't any error or message, just like it is an empty
> program.
> 
> Am I doing wrong somewhere??

$ ./test

You've fallen foul of two things. First off, is searches are only made along
$PATH. Second is a common mistake. In unix there's a command called 'test'.
This will have been executed instead, hence the behaviour you observe. EG:

$ if test -d test.exe; then echo dir; else echo file; fi

"man/info test" for details. In other words, don't name your executables
"test"! ;-)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]