Fatal error: SDL/SDL.h: No such file or directory

This is a discussion on Fatal error: SDL/SDL.h: No such file or directory within the C++ Programming forums, part of the General Programming Boards category; I'm using Code::Blocks with MinGW Settings -> Compiler -> Search Directories -> Compiler -> Added: D:\InstalledPrograms\CodeBlocks\SimpleDirectMediaL ayer\SDL2-2.0.0\x86_64-w64-mingw32\include Settings -> Compiler ...

  1. #1
    Registered User
    Join Date
    Feb 2013
    Location
    Sweden
    Posts
    92

    Question Fatal error: SDL/SDL.h: No such file or directory

    I'm using Code::Blocks with MinGW

    Settings -> Compiler -> Search Directories -> Compiler -> Added:
    D:\InstalledPrograms\CodeBlocks\SimpleDirectMediaL ayer\SDL2-2.0.0\x86_64-w64-mingw32\include

    Settings -> Compiler -> Search Directories -> Linker -> Added:
    D:\InstalledPrograms\CodeBlocks\SimpleDirectMediaL ayer\SDL2-2.0.0\x86_64-w64-mingw32\lib

    Settings -> Compiler -> Linker Settings -> Other Linker Options -> Added: -lmingw32 -lSDLmain -lSDL

    The code of the main.cpp file:

    Code:
    #include <iostream>
    #include "SDL/SDL.h"
    
    
    using namespace std;
    
    
    int main(int argc, char* argv[])
    {
        return 0;
    }
    I've too included the SDL2.dll file in the folder of the project

  2. #2
    Registered User
    Join Date
    Feb 2013
    Location
    Sweden
    Posts
    92
    Find out that you needed to say: #include "SDL2/SDL.h" if you are using SDL2 and in the: Settings -> Compiler -> Linker Settings -> Other Linker Options -> Added: -lmingw32 -lSDL2main -lSDL2
    But the compiler now gives me this error: Undefined reference to WinMain@16

    The build log says:

    mingw32-g++.exe -LD:\InstalledPrograms\CodeBlocks\SimpleDirectMedia Layer\SDL2-2.0.0\x86_64-w64-mingw32\lib -o bin\Debug\SDL_TEST.exe obj\Debug\main.o -lmingw32 -lSDL2main -lSDL2 -mwindows
    d:/installedprograms/codeblocks/mingw/bin/../lib/gcc/mingw32/4.7.1/../../../libmingw32.a(main.o):main.c.text.startup+0xa7): undefined reference to `WinMain@16'
    collect2.exe: error: ld returned 1 exit status
    Process terminated with status 1 (0 minutes, 0 seconds)
    1 errors, 0 warnings (0 minutes, 0 seconds)

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,029
    The problem is that you're trying to make a Windows project (ie an application that runs without a command prompt). This will cause the linker to look for a function named WinMain. You must add this. Google it for more info. After having added it, it should work.
    Or if you really wanted a console, then you have to change your settings to make it a console project instead. After that, it should work.
    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.

  4. #4
    Registered User
    Join Date
    Feb 2013
    Location
    Sweden
    Posts
    92

    Question

    Quote Originally Posted by Elysia View Post
    The problem is that you're trying to make a Windows project (ie an application that runs without a command prompt). This will cause the linker to look for a function named WinMain. You must add this. Google it for more info. After having added it, it should work.
    Or if you really wanted a console, then you have to change your settings to make it a console project instead. After that, it should work.
    What do you mean I have to add if I don't want a console window popup when I run the program?

    I tried to change the GUI to Console Application but it do still say the same error. How do I fix this? Any tutorial or something? Please help

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,029
    Try it from scratch.
    Create a console program, copy your code, compile link. It should work. Otherwise you have to return with the exact error.
    If you don't want the console to pop up every time you run your program, then you need to create a windows application. There should be some tutorial on doing that for Code::Blocks. I don't use it, so I don't know.
    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.

  6. #6
    Registered User
    Join Date
    Feb 2013
    Location
    Sweden
    Posts
    92

    Question

    Quote Originally Posted by Elysia View Post
    Try it from scratch.
    Create a console program, copy your code, compile link. It should work. Otherwise you have to return with the exact error.
    If you don't want the console to pop up every time you run your program, then you need to create a windows application. There should be some tutorial on doing that for Code::Blocks. I don't use it, so I don't know.
    And now another error is causing problems . This error: C::B Unable to start (0xc000007b) on win64/MinGW64 GCC 4.5.0

    I just don't understand what to do?

  7. #7
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,029
    That means you got past the previous error. Unfortunately, what you have is not a C++ problem. It's specific to C::B and/or mingw, so my best suggestions is to seek help from the C::B board since they probably know what's wrong better (I am not so familiar with C::B and Mingw, so I don't know what's wrong).
    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.

  8. #8
    Registered User HelpfulPerson's Avatar
    Join Date
    Jun 2013
    Location
    Over the rainbow
    Posts
    288
    There is a SDL project you can use in Code::Blocks. That was easy for me to setup after the headache of figuring out how to do it on my own with no prior exprience linking. If you can use that, you should be fine, and all you have to do is set up environment variables.
    "Some people think they can outsmart me, maybe. Maybe. I've yet to meet one that can outsmart bullet" - Meet the Heavy, Team Fortress 2

  9. #9
    Registered User
    Join Date
    May 2009
    Posts
    2,774
    Did you compile SDL for yourself?

    I strongly suggest verifying whether you have a 32-bit or 64-bit of the SDL library!

    Tim S.
    "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the Universe is winning." Rick Cook

  10. #10
    Registered User
    Join Date
    Feb 2013
    Location
    Sweden
    Posts
    92
    I've the 32 bit of the SDL2. And it looks like this when I try to compile it
    Name:  problem_sdl.jpg
Views: 3371
Size:  50.5 KB

    Translated message: Couldn't start the program correct (0xc000007b). Click on OK to close the program


    EDIT:

    I finally figured out what's wrong. And that was that I'm using a 64-bit SDL2.dll file instead of using a 32-bit when I've a SDL WinRar package that is for 32-bits.

    This article really helped me figuring out all http://msoos.wordpress.com/2010/09/1...rror-solution/ . But thanks for your replies all!
    Last edited by DecoratorFawn82; 09-10-2013 at 11:42 PM.

  11. #11
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,029
    Tips:
    - You can actually copy the text in some message boxes by simply making sure the message box has focus and pressing Ctrl+C.
    - If that doesn't work, then you can use Alt + Print Screen to only copy the window that has currently focus.
    - Don't resize the image when posting them. I had to upsize your image to see what the message box actually said.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. [Help]fatal error LNK1104: cannot open file '%.obj'
    By athena21191 in forum C Programming
    Replies: 0
    Last Post: 11-17-2012, 09:24 PM
  2. fatal error: iostream: No such file or directory
    By yeohwl91 in forum C Programming
    Replies: 11
    Last Post: 10-03-2011, 12:43 AM
  3. [Linker Fatal Error] Fatal: Expected a file name
    By Checco in forum C++ Programming
    Replies: 1
    Last Post: 07-27-2005, 06:34 AM
  4. fatal error C1004: unexpected end of file found
    By Gutty in forum C++ Programming
    Replies: 1
    Last Post: 08-11-2003, 10:58 PM
  5. Weird fatal error, header file related
    By alkis_y3k in forum C++ Programming
    Replies: 2
    Last Post: 12-26-2002, 09:54 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21