Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Trying to run Hello World(Clean installation of Eclipse and MinGW cannot run Hello World)
Trying to run Hello World [message #1752284] Fri, 20 January 2017 15:26 Go to next message
Eric Jensen is currently offline Eric JensenFriend
Messages: 3
Registered: January 2017
Junior Member
I'm trying to run the Hello World c++ project template from Eclipse Neon release 4.6.2. I currently have not edited the file, but have only built the project. I have 66 errors. They are all of the form:

'__intptr_t' does not name a type
'__off32_t' does not name a type
'_BEGIN_C_DECLS' does not name a type
...
'::isqalnum' has not been declared
...
'intptr_t was not declared in this scope
...
'mbstate_t' in namespace 'std' does not name a type
...
expression list treated as compound expression in initializer [-fpermissive]

Since I have not changed the program and it looks like the programs I can find online I am nearly certain that this is an issue with my installation.
The trouble is I don't know where to start.
The first thing I tried was deleting eclipse and MinGW. Removing the references in the PATH, rebooting and re-installing. This gave the same error (its consistent... yay :-$ )

I am running Windows 7 service pack 1.
My main suspect is the MinGW installation. I attempted to use the mingw installer, but received the "mingw-get: *** ERROR *** unexpected end of archive reading header record" errors and could not find a way around it.
On the MinGW website there are instructions for a manual install. I downloaded all the required files for the minimum install as well as the files for C++, debugger, and make.
They were all unpacked into the C:\MinGW directory.
I then used the eclipse installer and selected the C/C++ version.
After installation I immediately created a c++ project, selecting the Hello World template.

I know I've made an error somewhere, but I can't find it. Any ideas?
Re: Trying to run Hello World [message #1752335 is a reply to message #1752284] Sun, 22 January 2017 08:08 Go to previous messageGo to next message
David VavraFriend
Messages: 1417
Registered: October 2012
Senior Member
I've installed Eclipse Neon.2 and MinGW in Windows 7 Professional.
The Hello World project compiles and runs OK.
I added includes for stdint.h and sys/types.h
and the declaration __intptr_t pint;

That, too, worked.

I then converted the project to use a generated makefile and to run make.
It builds and runs OK as long as I build from within Eclipse.
I was getting something similar for the __intptr_t declaration when building using standalone make.
However I found that there were two installations of g++.
The one being used when building standalone came with Perl64.
Fixing the path to use the g++ that came with MinGW fixed the problem.


Can you be more specific about how and when you encounter these errors?
Are you building from within Eclipse?
Are you sure there is only one GCC installed? Execute "where g++".
Can you attach the build log?


[Updated on: Sun, 22 January 2017 13:41]

Report message to a moderator

Re: Trying to run Hello World [message #1752381 is a reply to message #1752335] Mon, 23 January 2017 08:33 Go to previous messageGo to next message
Eric Jensen is currently offline Eric JensenFriend
Messages: 3
Registered: January 2017
Junior Member
Hi David

Thanks for the reply!
I tried including stdint.h and sys/types. No errors were shown for those includes (or the rest of the cpp file), but I still get errors in the project.
I checked and the project is configured to generate a make file and the build command is "make" (no quotations).
I build using Project > Build Project. My project settings show it using the MinGW g++.

The errors are presented after attempting to build the project with Project > Build Project in Eclipse.
I am not sure there is only one GCC installed. How would I execute the "where g++" command?
When I check "Preprocessor Includes Paths, Macros etc." under "C/C++ General" in the Project settings I can see "CDT Cross GCC Built-in Compiler Settings" and "CDT GCC Built-in Compiler Settings" and "CDT GCC Built-in Compiler Settings Cygwin" as possible alternative providers. I guess I have at least a cygwin installed somewhere. Maybe that is an issue? I can't find references to it being utilized in the Project settings.
The output of the console after the build is attached.
  • Attachment: build log.txt
    (Size: 19.06KB, Downloaded 113 times)
Re: Trying to run Hello World [message #1752392 is a reply to message #1752381] Mon, 23 January 2017 11:23 Go to previous messageGo to next message
Jonah Graham is currently offline Jonah GrahamFriend
Messages: 404
Registered: June 2014
Senior Member
I can see some other people with similar errors with mingw. I haven't reproduced your problem, but this looks like a mistake in the mingw header files.

(From your log you are running the mingw32 version of g++)

From your log:
g++ -O0 -g3 -Wall -c -fmessage-length=0 -o "src\\HW.o" "..\\src\\HW.cpp" 
In file included from c:\mingw\include\wchar.h:61:0,
                 from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\cwchar:44,
                 from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\postypes.h:40,
                 from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\iosfwd:40,
                 from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\ios:38,
                 from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\ostream:38,
                 from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\iostream:39,
                 from ..\src\HW.cpp:9:
c:\mingw\include\wctype.h:92:1: error: '_BEGIN_C_DECLS' does not name a type
 _BEGIN_C_DECLS
 ^


_BEGIN_C_DECLS is defined in w32api.h, included by _mingw.h which is just above the error message line. So either some of those conditions are wrong, or something in your program have caused a problem.

Can you post two things:

1. The top 9 lines of your program (up until ..\src\HW.cpp:9). Although unlikely, perhaps you have defined something that has caused the header file error to pop-up.

2. The pre-processed HW.cpp file. Easiest way is to add -save-temps to other flags and attach the .i file. (Check that the contents of the file is ok to upload Smile, doesn't contain anything you don't want public as it will contain your entire HW.cpp and all the headers it includes).
Re: Trying to run Hello World [message #1752394 is a reply to message #1752392] Mon, 23 January 2017 11:25 Go to previous messageGo to next message
Jonah Graham is currently offline Jonah GrahamFriend
Messages: 404
Registered: June 2014
Senior Member
The answer on SO to a similar problem recommended changing -std=c++11 to -std=gnu++11. At the moment you have neither, so you could try setting the language flag to see if that resolves the issue.

Source http://stackoverflow.com/a/38441595/2796832
Re: Trying to run Hello World [message #1752413 is a reply to message #1752394] Mon, 23 January 2017 14:37 Go to previous messageGo to next message
David VavraFriend
Messages: 1417
Registered: October 2012
Senior Member
_BEGIN_C_DECLS depends on __cplusplus which I would think defined when compiling a C++ file.
Perhaps something undefined it or this entire section of code is inactive.

Definition of _BEGIN_C_DECLS starting win32api.h:173
#ifdef __cplusplus
# define _EXTERN_C       extern "C"
# define _BEGIN_C_DECLS  extern "C" {
# define _END_C_DECLS    }
#else
:
#endif

Put the following at the top of HW.cpp file and see what you get.
#ifdef __cplusplus
#pragma message "cplusplus is defined"
#else
#pragma message "cplusplus is NOT defined"
#endif

The guard statement for __off32_t is more complicated.
The typedef for it is at sys/types.h:62:

To list all g++.exe files in path order :
In a command window type "where g++"
C:\Users\dvavra>where g++
c:\Apps\MinGW\bin\g++.exe
C:\Apps\Perl64\site\bin\g++.exe

The version of GCC I downloaded from MinGW is 5.3.0
You seem to be using 4.8.1

[Updated on: Mon, 23 January 2017 21:48]

Report message to a moderator

Re: Trying to run Hello World [message #1752574 is a reply to message #1752413] Wed, 25 January 2017 09:18 Go to previous message
Eric Jensen is currently offline Eric JensenFriend
Messages: 3
Registered: January 2017
Junior Member
Hi again

Thanks for all the great input!
I think my issue was a with 32-bit vs 64-bit. I am running a 64-bit system.
I found a guide for installing msys2 (which is for 64-bit systems, link: http://wiki.netbeans.org/HowToSetup64-BitQt5WithNetBeans8.0OnWindows). After completing installation I tested it in netbeans (the guide used it so I did as well). Everything built correctly. I then reinstalled Eclipse after removing the 32-bit versions of msys and mingw. This also executed without issue.

It all works now!
Also: the time you have spent thinking about my issue and replying to my post is greatly appreciated! Thank you very much!
Previous Topic:Code Completion / Doxygen
Next Topic:Differences between "ELF Parser" and "GNU ELF Parser"?
Goto Forum:
  


Current Time: Fri Jan 28 03:49:51 GMT 2022

Powered by FUDForum. Page generated in 0.02670 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top