Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8207699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:04:51+00:00 2026-06-07T09:04:51+00:00

I have been trying to use g++ to compile a program with SDL. The

  • 0

I have been trying to use g++ to compile a program with SDL.

The program is only a main.cpp file with two SDL test lines in it, like this:

#include "SDL/SDL.h"

using namespace std;

int main(void) {
    SDL_Init(SDL_INIT_EVERYTHING);

    SDL_Quit();

    return 0;
}

But my problem is that I get an error to do with the SDL libraries.

First of all I installed MinGW32 so that I could learn about C++11, so when I ask what version GCC is it says that it is version 4.7.0.

Then I downloaded the SDL-devel-1.2.15-mingw32.tar.gz file from the SDL website and extracted the folder to the desktop.

After that I copied all of the header files from /SDL-1.2.15/include/SDL to C:/MinGW/include/SDL

Then I copied 3 files from the /SDL-1.2.15/lib folder to the C:/MinGW/lib folder

They were:

libSDL.dll.a
libSDL.la
libSDLmain.a

And finally I copied the SDL.dll file from the bin directory to the same directory that the .exe file will be compiled from.

I think I have set everything up correctly, but I get two different messages based on how I try to compile it.

First of all I tried compiling it using the build system functionality in the Sublime Text 2 editor.

This is the command that I have told Sublime Text 2 to run:

"cmd": ["g++", "${file}", "-o", "${file_path}/${file_base_name}", "-lmingw32 -lSDLmain -lSDL -mwindows"]

When I run this I get the error message:

c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/bin/ld.exe: cannot find lmingw32 -lSDLmain -lSDL -mwindows
collect2.exe: error: ld returned 1 exit status
[Finished in 0.3s with exit code 1]

So I then tried to compile directly from the command prompt.

I changed the directory to the same directory as my main.cpp and ran the following:

g++ main.cpp -o main.exe -lmingw32 -lSDLmain -lSDL -mwindows

And got the following error message:

c:/mingw/bin/../lib/gcc/mingw32/4.7.0/../../../libSDLmain.a(SDL_win32_main.o): In function `console_main':
/Users/slouken/release/SDL/SDL-1.2.15/./src/main/win32/SDL_win32_main.c:315: undefined reference to `_SDL_main'
collect2.exe: error: ld returned 1 exit status

Can anybody see what I am doing wrong?

Why is it that I get two different messages depending on where I run the command from, and how can I fix this?

Any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T09:04:52+00:00Added an answer on June 7, 2026 at 9:04 am

    I seem to have solved my own problem.

    The error I was getting in the windows command prompt was because SDL appears to require the correct signature for the main() function so I changed:

    int main(void) {
    

    to:

    int main(int argc, char *argv[]) {
    

    This allowed me to compile from the command prompt without any problems.

    Then the Sublime Text 2 error turned out to be a problem with the way I had written the build system file.

    I just needed to split up the -l flags into separate values.

    Previously I had the flags written like this:

    "-lmingw32 -lSDLmain -lSDL -mwindows"
    

    But I needed to change it to this:

    "-lmingw32", "-lSDLmain", "-lSDL", "-mwindows"
    

    And now I can build from Sublime Text 2 by hitting F7.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to use date_format , however as far as I know,
I have been trying to use array_unique to remove duplicates from the search results
I have been trying to use routes.rb for creating a URL /similar-to-:product (where product
I have been trying to use the hibernate dialect for SQLite from http://code.google.com/p/hibernate-sqlite/ in
I have been trying to use/save the boolean value of a checkbox in other
I have been trying to use 3rd party tool called visiblox for rendering charts
I have been trying to use the document.getElementByID to pull information from an HTML
Right now I have been trying to use Launchpad's API to write a small
Ok I'm stumped. I have been trying to use Simpletip to create a tooltip
I have been trying to figure out why and how to use performSelector. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.