News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Problem Building project with Code::Block

Started by arashfahim, October 04, 2010, 12:31:23 AM

Previous topic - Next topic

arashfahim

Hi,
I am an absolute beginner in C++ and I installed full version of Code::Block in my Laptop. I tried to run the "Hello World!" program as the first program. I received the following error.

Quote-------------- Build: Debug in test1 ---------------

mingw32-g++.exe -Wall -fexceptions  -g    -I"C:\Program Files\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include" -I"C:\Program Files\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++" -I"C:\Program Files\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\backward" -I"C:\Program Files\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\mingw32" -I"C:\Program Files\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\bits" -I"C:\Program Files\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\debug" -I"C:\Program Files\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\ext" -I"C:\Program Files\CodeBlocks\MinGW\lib\gcc\mingw32\4.4.1\include\c++\mingw32\bits"  -c "C:\Documents and Settings\user\Desktop\C++tests\test1\main.cpp" -o obj\Debug\main.o
In file included from c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/ios:43,
                 from c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/ostream:40,
                 from c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/iostream:40,
                 from C:\Documents and Settings\user\Desktop\C++tests\test1\main.cpp:2:
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/ios_base.h:234: error: field '_M_msg' has incomplete type
In file included from c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/basic_ios.h:39,
                 from c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/ios:45,
                 from c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/ostream:40,
                 from c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/iostream:40,
                 from C:\Documents and Settings\user\Desktop\C++tests\test1\main.cpp:2:
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/locale_facets.h: In member function 'std::string std::numpunct<_CharT>::grouping() const':
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/locale_facets.h:1746: error: return type 'struct std::string' is incomplete
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/locale_facets.h: In member function 'virtual std::string std::numpunct<_CharT>::do_grouping() const':
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/locale_facets.h:1814: error: return type 'struct std::string' is incomplete
In file included from c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/locale_facets.h:2599,
                 from c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/basic_ios.h:39,
                 from c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/ios:45,
                 from c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/ostream:40,
                 from c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/iostream:40,
                 from C:\Documents and Settings\user\Desktop\C++tests\test1\main.cpp:2:
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/locale_facets.tcc: In member function '_InIter std::num_get<_CharT, _InIter>::_M_extract_float(_InIter, _InIter, std::ios_base&, std::_Ios_Iostate&, std::string&) const':
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/locale_facets.tcc:192: error: invalid use of incomplete type 'struct std::string'
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/stringfwd.h:52: error: declaration of 'struct std::string'
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/locale_facets.tcc:263: error: invalid use of incomplete type 'struct std::basic_string<char, std::char_traits<char>, std::allocator<char> >'
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/stringfwd.h:52: error: declaration of 'struct std::basic_string<char, std::char_traits<char>, std::allocator<char> >'
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/locale_facets.tcc:277: error: invalid use of incomplete type 'struct std::string'
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/stringfwd.h:52: error: declaration of 'struct std::string'
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/locale_facets.tcc:300: error: invalid use of incomplete type 'struct std::string'
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/stringfwd.h:52: error: declaration of 'struct std::string'
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/locale_facets.tcc:336: error: invalid use of incomplete type 'struct std::string'
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/stringfwd.h:52: error: declaration of 'struct std::string'
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/locale_facets.tcc: In member function '_InIter std::num_get<_CharT, _InIter>::_M_extract_int(_InIter, _InIter, std::ios_base&, std::_Ios_Iostate&, _ValueT&) const':
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/locale_facets.tcc:448: error: invalid use of incomplete type 'struct std::string'
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/stringfwd.h:52: error: declaration of 'struct std::string'
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/locale_facets.tcc:534: error: invalid use of incomplete type 'struct std::string'
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/stringfwd.h:52: error: declaration of 'struct std::string'
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/locale_facets.tcc:547: error: invalid use of incomplete type 'struct std::string'
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/stringfwd.h:52: error: declaration of 'struct std::string'
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/locale_facets.tcc: In member function 'virtual _InIter std::num_get<_CharT, _InIter>::do_get(_InIter, _InIter, std::ios_base&, std::_Ios_Iostate&, float&) const':
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/locale_facets.tcc:675: error: invalid use of incomplete type 'struct std::string'
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/stringfwd.h:52: error: declaration of 'struct std::string'
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/locale_facets.tcc:677: error: invalid use of incomplete type 'struct std::string'
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/stringfwd.h:52: error: declaration of 'struct std::string'
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/locale_facets.tcc: In member function 'virtual _InIter std::num_get<_CharT, _InIter>::do_get(_InIter, _InIter, std::ios_base&, std::_Ios_Iostate&, double&) const':
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/locale_facets.tcc:690: error: invalid use of incomplete type 'struct std::string'
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/stringfwd.h:52: error: declaration of 'struct std::string'
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/locale_facets.tcc:692: error: invalid use of incomplete type 'struct std::string'
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/stringfwd.h:52: error: declaration of 'struct std::string'
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/locale_facets.tcc: In member function 'virtual _InIter std::num_get<_CharT, _InIter>::do_get(_InIter, _InIter, std::ios_base&, std::_Ios_Iostate&, long double&) const':
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/locale_facets.tcc:722: error: invalid use of incomplete type 'struct std::string'
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/stringfwd.h:52: error: declaration of 'struct std::string'
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/locale_facets.tcc:724: error: invalid use of incomplete type 'struct std::string'
c:\program files\codeblocks\mingw\bin\../lib/gcc/mingw32/4.4.1/include/c++/bits/stringfwd.h:52: error: declaration of 'struct std::string'
Process terminated with status 1 (0 minutes, 0 seconds)
31 errors, 0 warnings

I tried to reinstall Code::Block, but it gave me the same error. I also tried to google the error but no success.

I appreciate you experts to help me remove the problem.

Thanks a lot

stahta01

Did you re-install the Compiler?
If not, I suggest trying it.

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

arashfahim

Yes, I reinstalled it. I chose full installation. But, still  got the same error.

ollydbg

Quote from: arashfahim on October 04, 2010, 12:31:23 AM
I tried to run the "Hello World!" program as the first program.
some suggestions:

1, give us the full steps how you create and build the "hello world" program.
2, the minimal sample code of the "hello world" program.
3, use .cpp (not .c).

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

arashfahim

Quote from: ollydbg on October 04, 2010, 02:16:22 AM
Quote from: arashfahim on October 04, 2010, 12:31:23 AM
I tried to run the "Hello World!" program as the first program.
some suggestions:

1, give us the full steps how you create and build the "hello world" program.
2, the minimal sample code of the "hello world" program.
3, use .cpp (not .c).


I did it in 2 ways.
First I created an empty file main.cpp. I put the following on the file:
Quote#include<iostream>
using namespace std;

int main(){
    cout <<"Hello World!" << endl;
    return 0;
}
Then F9.
Second through New>Project>Console Application
choosing C++ and naming the project as test1. Then F9.

I took your advice. The file is called main.cpp not  .c. But the problem still exists.

arashfahim

I run the new  simple program:
Quoteusing namespace std;

int main(){
     int a=2;
//    cout <<"Hello World!" << endl;
    return a;
}
It works perfectly. Therefore the problem should be in iostream.
Am I true? Should I add some path to compiler folder?

ollydbg

Quote from: arashfahim on October 04, 2010, 02:46:05 AM
Should I add some path to compiler folder?
No, these folders were added by compiler by default.

I have no idea about other error.

BTW: you can put your project file in a folder WITHOUT a space in the folder path.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

arashfahim

Quoteyou can put your project file in a folder WITHOUT a space in the folder path.
It does not helped. Does anyone have any idea?

stahta01

If you have another MinGW in your system path, remove it.
If you have an MinGW in the folder x:\mingw for any drive letter in place of x rename or delete the MinGW folder.

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

arashfahim

Thanks Tim. I searched all the hard drive.  The only path is "C:\Program Files\CodeBlocks\MinGW". There is no other one. Did you mean that by system path?

oBFusCATed

no, he means the PATH environment variable
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

arashfahim

I checked this:
My Computer>System Properties>Advance [tab]> environment variables
Obviously there is no "C:program files/.../mingw" PATH in there. Should I add any. If yes which PATH. Because Code::Block has many folders one inside another, I can't figure out which one.

Jenna

If another installation is in system-path, it should be no problem (if the installation you use is complete), but if any of the disks has a \MinGW folder an installation in another folder might break.

Jenna

While compiling, C::B prepends the compilers bin dir to the path-variable (if your compiler installation dir is setup correctly in C::B).

arashfahim

Dear Jens,
How should I check if my compiler installation dir is setup correctly in C::B?