Thread: fatal error: wchar.h: no such file or directory

  1. #1
    Registered User
    Join Date
    Apr 2015
    Posts
    24

    fatal error: wchar.h: no such file or directory

    Hi guys, I am really struggling to setup my code::blocks. It is giving me the same error when I try to compile using minGW through the command line. I have
    reinstalled my windows and have not been able to compile any form of
    c++ yet.

    I get on both ways of compiling the following error: fatal error: wchar.h: no such file or directory. I have google the error and reinstalled code blocks with no avail.

    I would appreciate any help I
    can get at this point.
    Please guys

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Are you sure you installed a Code Blocks binary release with MinGW included?

    What program did you attempt to compile? I would create a project and try with:
    Code:
    int main() {}
    and if that works, try:
    Code:
    #include <iostream>
    
    int main()
    {
        std::cout << "Hello world!" << std::endl;
    }
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Apr 2015
    Posts
    24
    Yes, That was my first thing I did. As the first try i did was a huge fiddly project I've been working on I went back to a simple "Hello world" app in both compilers with no luck. I will make sure of the code blocks though. But I installed Code blocks and minGW separately. Like usual.

    *edit : just checked I did install a code blocks binary with minGW included. SO tecnically minGW is installed twice now.

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by Cyberduke
    But I installed Code blocks and minGW separately. Like usual.
    What do you usually do to install MinGW?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Apr 2015
    Posts
    24
    I download the minGW installer and install from there. I then add the directory to the environment variables directly. Has never failed me.

  6. #6
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Post a build log in code tags.

    FAQ-Compiling (errors) - CodeBlocks

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  7. #7
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by Cyberduke View Post
    I download the minGW installer and install from there. I then add the directory to the environment variables directly. Has never failed me.
    I would suggest (with Code::Blocks NOT running) to delete the MinGW folder inside the Code::Blocks installation folder.
    Then, startup Code::Blocks and do an compiler auto-detect.

    FYI: Two installation of MinGW can interfere with each other if one or more of them is in the system environment path variable.
    Or, if the MinGW installation folder is in certain folders.

    Edit2: I believe Code::Blocks will try to use the MinGW in the sub-folder; but, the other MinGW might be causing problems removing one of them will reduce the likelihood of conflicts.

    Tim S.
    Last edited by stahta01; 09-02-2015 at 07:08 PM.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  8. #8
    Registered User
    Join Date
    Apr 2015
    Posts
    24
    Quote Originally Posted by stahta01 View Post
    I would suggest (with Code::Blocks NOT running) to delete the MinGW folder inside the Code::Blocks installation folder.
    Then, startup Code::Blocks and do an compiler auto-detect.
    Tim S.
    Thank you, I've just tried that but it is still not finding the wchar.h file.

  9. #9
    Registered User
    Join Date
    Apr 2015
    Posts
    24
    Quote Originally Posted by stahta01 View Post
    Post a build log in code tags.

    FAQ-Compiling (errors) - CodeBlocks

    Tim S.
    Code:
    
    -------------- Build: Debug in ggg (compiler: GNU GCC Compiler)---------------
    
    
    mingw32-g++.exe -Wall -fexceptions -g  -c C:\Users\Ian\Desktop\ggg\main.cpp -o obj\Debug\main.o
    In file included from c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\postypes.h:40:0,
                     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 C:\Users\Ian\Desktop\ggg\main.cpp:1:
    c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\cwchar:44:19: fatal error: wchar.h: No such file or directory
     #include <wchar.h>
                       ^
    compilation terminated.
    Process terminated with status 1 (0 minute(s), 0 second(s))
    1 error(s), 0 warning(s) (0 minute(s), 0 second(s))

  10. #10
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  11. #11
    Guest
    Guest
    At the risk of sounding like a broken record, I've had good experiences with MinGW-W64 builds. Usually you'd want to pick the threads-posix + seh variant on Windows. You just extract the contents into a directory (like C:\>mingw-w64\ avoid spaces to be safe). Then you add the bin subdirectory to your PATH variable and you're ready to go. I reckon running Code::Blocks' auto detection should work with it.

  12. #12
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    No idea if Code::Blocks auto detection will work with mingw-builds MinGW-W64 or not.
    But, it works with the TDM installer without many problems.
    TDM can install either MinGW32 or MinGW64. TDM-GCC MinGW Compiler download | SourceForge.net

    Directions to compiler configuration Installing a supported compiler - CodeBlocks

    Tim S.
    Last edited by stahta01; 09-03-2015 at 03:15 PM.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  13. #13
    Registered User
    Join Date
    Apr 2015
    Posts
    24
    Quote Originally Posted by stahta01 View Post
    No idea if Code::Blocks auto detection will work with mingw-builds MinGW-W64 or not.
    But, it works with the TDM installer without many problems.
    TDM can install either MinGW32 or MinGW64. TDM-GCC MinGW Compiler download | SourceForge.net

    Directions to compiler configuration Installing a supported compiler - CodeBlocks

    Tim S.
    Excelent. I have uninstalled everything I had. And installed TDM and a compiler less code::blocks. Linking everything manually (it said it auto found but still gave a error that no compiler found, weird). I now am able to compile through code Blocks.

    One question though. When I try to compile using command line now I get errors that will suggest I am giving the instructions wrong. Despite the fact that i'm doing it in the manner its been working before. How does it look like when you guys use command line compiling?

  14. #14
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by Cyberduke View Post
    Excelent. I have uninstalled everything I had. And installed TDM and a compiler less code::blocks. Linking everything manually (it said it auto found but still gave a error that no compiler found, weird). I now am able to compile through code Blocks.

    One question though. When I try to compile using command line now I get errors that will suggest I am giving the instructions wrong. Despite the fact that i'm doing it in the manner its been working before. How does it look like when you guys use command line compiling?
    I do NOT use command line compiling, very often, so I can NOT really help you. But, asking for help with TDM using command line might be worse than asking for help using mingw-builds MinGW-W64. I think more people on this site use a non TDM version of MinGW-W64. There has been complaints about TDM doing changes that affect the command line options on the CB site.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  15. #15
    Registered User
    Join Date
    Apr 2015
    Posts
    24
    Quote Originally Posted by stahta01 View Post
    I do NOT use command line compiling, very often, so I can NOT really help you. But, asking for help with TDM using command line might be worse than asking for help using mingw-builds MinGW-W64. I think more people on this site use a non TDM version of MinGW-W64. There has been complaints about TDM doing changes that affect the command line options on the CB site.

    Tim S.
    Ahh that is quite disappointing. But thank you anyway.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Fatal error: SDL/SDL.h: No such file or directory
    By DecoratorFawn82 in forum C++ Programming
    Replies: 10
    Last Post: 09-10-2013, 10:43 PM
  2. [Help]fatal error LNK1104: cannot open file '%.obj'
    By athena21191 in forum C Programming
    Replies: 0
    Last Post: 11-17-2012, 09:24 PM
  3. fatal error: iostream: No such file or directory
    By yeohwl91 in forum C Programming
    Replies: 11
    Last Post: 10-02-2011, 11:43 PM
  4. fatal error C1083: Cannot open include file:
    By bodhankaryogesh in forum Windows Programming
    Replies: 14
    Last Post: 03-31-2008, 07:02 AM
  5. [Linker Fatal Error] Fatal: Expected a file name
    By Checco in forum C++ Programming
    Replies: 1
    Last Post: 07-27-2005, 05:34 AM