Home » Language IDEs » C / C++ IDE (CDT) » Error running C++ program
Error running C++ program [message #80038] |
Thu, 11 September 2003 18:37  |
Eclipse User |
|
|
|
Originally posted by: webdevil2003.excite.com
Hi All,
I am trying to run HelloWorld project that comes with Tutorials and I am
getting
the following error
ERROR:Launching HelloWorld : Error starting process : Exec error:Launching
Failed
What could be the reason for it?
Thanks
WD
|
|
| | | | | | |
Re: Error running C++ program [message #80204 is a reply to message #80189] |
Sun, 14 September 2003 22:43   |
Eclipse User |
|
|
|
Rajinikanth Sambasivan wrote:
> Hi WD,
> Even i had problems compiling c++ through cdt, the CDT user faq at the
> home page is kinda old and i request people responsible to update it with
> the following if possible.I had to go through old mails in the newsgroup
> to find the way to male it work.
Actually, the example works if you follow the steps.
The main thing is to add the C:\MinGW\bin and (if you use MSYS too)
C:\msys\1.0\bin to the path before starting Eclipse.
> follow these steps:
> Open a C/C++ Perspective and complete the following steps:
>
> 1)In the C/C++ Projects View right click and select "New Project ..."
> 2)Select "C++" in the left pane and then select "Standard Make C++ Project"
> 3)Enter a name for the new project and select Finish. In the "Build
> Settings"
> remove the default option and type c:\msys\1.0\make -f makefile
If you set the PATH variable as above, you'll only tell make or
mingw32-make here (see below). Btw. Makefiles start capitalized usually.
If you name your makefiles otherwise, you need to give them by -f option
to make.
> 4)In the C/C++ Projects View right click and select "New" > "Simple" >
> "File". Name your file hello.cpp
> Repeat the previous step and name the second new file "makefile".
> Copy the following text into the "hello.cpp" file:
> #include <iostream>
> using namespace std;
>
> int main ()
> {
> // Say Hello five times
> for (int index = 0; index < 5; ++index)
> { cout << "HelloWorld!" << endl;
> }
>
> char input = 'i';
>
> cout << "To exit, press " << endl;
>
> while(input != 'm')
> {
> cin >> input;
> cout << "You just entered " << input
> << " you need to enter m to exit." << endl;
> }
>
> exit(0);
> }
>
main method usually only returns with code not exit, but thats usually a
users choice.
>
> 7)Copy the following text into the "makefile" file:
> Remember that makefiles require indented lines be a <tab> character and
> not spaces
>
>
> objects = hello.o
>
> LIB_DIR = C:/MinGW/lib/gcc-lib/mingw32/3.2/
> BIN_DIR = C:/MinGW/bin/
if you use the correct compiler frontend (gcc for C, g++ for C++) you
won't have to explicitly set the library path (it's predefined in the
compiler), though there are aspects for explicitly setting them (i.e.
replacing the standard lib by a customized one).
> GCC = $(BIN_DIR)g++
There is a standard variable for holding compiler in make.
CC - for C Compiler (like gcc)
CXX - for C++ Compiler (like g++)
AS - for Assembler
CFLAGS - for C Compiler flags (includes, debug, warnings...)
CXXFLAGS - for C++ Compiler flags (includes, debug, warnings...)
LDFLAGS - for Linker flags (libs, lib-paths)
>
> COMPILE_OPTS = -g
> CFLAGS = $(COMPILE_OPTS)
> ALL_CFLAGS = -I. $(CFLAGS)
>
> #COMPILE_OPTS = -Wno-deprecated
>
> hello : $(objects)
hello -- is the target here
$(objects) -- are prerequisites
> $(GCC) -o hello $(objects) -lstdc++ $(CFLAGS)
$(CXX) -o $@ $^ $(LDFLAGS)
This is a sufficient line.
$(CXX) -- the compiler as set above or if not set the predefined
-o $@ -- output to the target as declared above
$^ -- the prerequisites as given in the line above
$(LDFLAGS) -- the linker flags as defined above the rules
> # $(GCC) -o hello $(objects) -L $(LIB_DIR) -lstdc++ $(CFLAGS)
>
> $(objects) : hello.cpp
> $(GCC) -c hello.cpp $(ALL_CFLAGS)
>
A more generic rule suites better and is less writing work, like:
%.o: %.cpp
$(CXX) $(CXXFLAGS) -o $@ $<
It means, create an object file from an cpp file and the % means that
the names before the extensions are the same.
The meaning of the command line is similar to the linker rule above.
The advantage on this more general rules are that you set the CXXFLAGS
and LDFLAGS only once, and you don't have to explicitly add a rule for
each file.
> all : hello
>
Usually the all, debug rules are places before all other rules like the
ones above. The reason is, that if you call make without an specific
target like 'make all' make will take the _first_ rule in the makefile!
That means, make would take the 'hello: $(objects)' rule.
> PHONY : clean
You could add all and debug to the PHONY rule to. Btw. you forgot to put
the '.' in front of the PHONY!
..PHONY: all debug clean
> clean :
> del -f hello.exe $(objects)
you better use a line like
$(RM) $(TARGET) $(OBJECTS)
and add an
RM = rm -f
to the part of the makefile, where CC is set (see above).
One more note below.
>
> 9)now right click n the project and choose build.
>
> I dontknow why rebuild doesnt work it gives me a clean error!!!.
If there is no file in place which should be deleted, then the call
fails. Though you better say
-$(RM) $(TARGET) $(OBJECTS)
Watch the '-' infront of the $(RM). It tells make to ignore errors on
the call. This is useful, if there are no objects to be cleaned.
> And does any person use MinGw's make instead of msys make bcoz, the
> program builds fine if i use the build command as c:\msys\1.0\make -f
> makefile
> but doesnt if i use c:\MinGW\bin\make -f makefile .. why is this
> discrepancy?may be its a problem with MinGW???
> thanks,
The MinGW comes with an mingw32-make.exe within the C:\MinGW\bin
directory. Though you can do two things here if you don't use MSYS!
* Make a copy of mingw32-make.exe to make.exe
* Change the default build command to mingw32-make and add a line in the
makefile at the CC,CXX settings like the following:
MAKE = mingw32-make
This assumes, you have the MinGW bin-dir in your PATH. You can set this
by going on the Desktop, right-click on the 'My Computer', go in the
Popup-Menu to 'Properties'. In the Dialog go to the 'Advanced
Settings'-Tab and click on the Environment Settings Button. Change the
PATH in the bottom list, by adding the MinGW\bin path and if you use
MSYS, the \bin-path too.
Why the MinGW team has named make to mingw32-make, someone told me,
thats because MSYS comes with make too, though there would be a name-clash.
> Rajinikanth Sambasivan.
>
> WD wrote:
>
>
>>Hi All,
>>I am trying to run HelloWorld project that comes with Tutorials and I am
>>getting
>>the following error
>
>
>>ERROR:Launching HelloWorld : Error starting process : Exec error:Launching
>>Failed
>
>
>>What could be the reason for it?
>
>
>>Thanks
>>WD
>
|
|
| | | | | |
Re: Error running C++ program [message #86868 is a reply to message #86829] |
Sun, 23 November 2003 17:18  |
Eclipse User |
|
|
|
Well, I didn't know if you have MinGW or Cygwin, but the PATH thing can
apply to both.
MinGW is another Compiler based also on the GCC Toolchain. The
difference to Cygwin
is, that it links against msvcrt (Microsoft C Runtime) and you wont need
the cygwin.dll
to run your programs.
WyleySam schrieb:
> Ok, I found it, but what is MinGW??? I downloaded something called Cygwin.
> I also downloaded something called gcc-3.3.2.
>
>
> "Henning Riedel" <kesselhaus@gmx.net> wrote in message
> news:bpq2n7$mil$1@eclipse.org...
>
>>Right click on your Project, select Properties, there select C/C++ in the
>>left pane, now its right the first tab on the right pane.
>>
>>What you could also do is, add C:\MinGW\bin and C:\msys\1.0\bin to
>>your PATH-variable and restart Eclipse. Eclipse should pickup the new
>>path-settings and find your make program.
>>
>>WyleySam schrieb:
>>
>>>I can not find a Build Settings. Where is it.
>>>
>>
>> > ...
>>
>
>
>
|
|
|
Goto Forum:
Current Time: Thu Jul 17 22:05:07 EDT 2025
Powered by FUDForum. Page generated in 0.08402 seconds
|