#1
  1. web.graphic.print
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Location
    Lancaster, CA USA
    Posts
    118
    Rep Power
    114

    Unhappy C++ noob needs help:)


    Hello,

    I just installed MinGW (C++) and im trying to compile a simple hello world script. It says it's having a fatal error, it can't find stddef.h. Any ideas?

    Thanks!
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,837
    Rep Power
    480
    Can you build and run this program?
    Code:
    int main() {
      int puts(const char*);
      puts("hi!");
      return 0;
    }
    Provide additional information to help whomever it is that can solve your mystery from afar. Onto which operating system did you install mingw? Did you read the gcc manual about search paths for include files? Do you know how to investigate these issues? How did you install mingw?

    I've got mingw on a 64 bit windows 7 system. From an ash shell, which I start with the command "bash", the program works great.
    $ gcc -Wall c.c
    $ ./a
    hi!
    $
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. web.graphic.print
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Location
    Lancaster, CA USA
    Posts
    118
    Rep Power
    114

    Talking woo!


    Hello world!

    Got it to work. I installed everything from the mingw-get and suddenly it works. One thing: if the .exe is not in the mingw/bin directory it can't find a .dll. Is there anyway around this to make a standalone .exe?

    edit:
    Also, i tried your program, it says "undefined reference to 'puts(char const*)'". ? I'm on windows vista. I'm not sure what the path is, I didn't bother with it, i just invoke the c++.exe from mingw/bin and point it where it needs to be pointed.
    Last edited by fireminded; September 11th, 2013 at 12:02 PM. Reason: Forgot something
  6. #4
  7. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,145
    Rep Power
    2222
    I have had no problem at all running MinGW from any directory nor in running any exe it creates. In fact. all I've had to do to port MinGW to another system has been to copy the entire sub-directory tree over and place it in the same location on the other system (eg, since I installed it as part of Dev-C++, which I have long since abandoned, that sub-directory tree is at C:\Dev-Cpp). And I add c:\dev-cpp\bin to the search path environment variable, PATH.

    Have you updated PATH with the path to the bin directory?

    {Added By Edit:
    If you are not familiar with changing PATH, here is the bat file that I created to do the job:
    Code:
    path=c:\dev-cpp\bin;%PATH%
    You would need to replace that with the bin path on your system. The %PATH% is very important, since it represents all the search paths already defined, so you wouldn't want to lose those.

    To simplify the process even more, I simply updated the PATH environment variable on my system. Microsoft keeps hiding that feature with each version of Windows and since I have never had the "pleasure" of doing anything in Vista I have no idea where it's hiding on your system. Perhaps somewhere in the Control Panel, maybe under System.
    }

    Also, what DLL does it report as missing? Remember that MinGW uses the MSVCRT run-time DLL, which should reside in the C:\WINDOWS\SYSTEM32 directory; since I have several copies of Microsoft Visual C++ installed here at work, I have several versions of that DLL -- bear in mind that MinGW uses the one from Visual C++ v6, hence the fact that it does not support C99. On my Win7 laptop, onto which I have only installed Visual Studio 2008, that directory contains a copy of msvcrt.dll, but I don't know whether it had come with the system or with VS2008. And MinGW works just fine on my laptop, having been ported there in the manner described above.

    The puts function prototype is provided in stdio.h and its code is provided in the standard C library file, which should be linked in automatically. What b49P23TIvg had done in that program was to write the prototype explicitly instead of relying on gcc finding the header file. Was that a compiler or a linker error you got? A copy-and-paste of the entire error line would help -- to highlight and copy from a console window, right-click on the Cmd Prompt caption bar to display the context menu, select the Edit sub-menu and select from that Mark, then highlight a rectangular region with your mouse and hit the Enter key to copy it. Then you can paste it into your forum editor as you normally would.
    Last edited by dwise1_aol; September 11th, 2013 at 01:39 PM.

IMN logo majestic logo threadwatch logo seochat tools logo