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 8933351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:31:01+00:00 2026-06-15T09:31:01+00:00

I am trying to compile and run a simple SDL program on OSX 10.8.2,

  • 0

I am trying to compile and run a simple SDL program on OSX 10.8.2, SDL 1.2.15, GHC 7.4.2, haskell SDL bindings 0.6.4:

import Graphics.UI.SDL as SDL

main :: IO ()
main = do
    screen <- setVideoMode 640 480 32 [SWSurface]
    hello <- loadBMP "hello.bmp"

    blitSurface hello Nothing screen Nothing

    SDL.flip screen

    delay 2000

It compiles (ghc test.hs) without erros, but when I try to run it, I get the following exception:

$ ./test 
2012-11-30 12:37:29.453 test[8995:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Error (1000) creating CGSWindow on line 259'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff8cf060a6 __exceptionPreprocess + 198
    1   libobjc.A.dylib                     0x00007fff88e813f0 objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff8cf05e7c +[NSException raise:format:] + 204
    3   AppKit                              0x00007fff87e41c29 _NSCreateWindowWithOpaqueShape2 + 655
    4   AppKit                              0x00007fff87e40420 -[NSWindow _commonAwake] + 2002
    5   AppKit                              0x00007fff87dfee62 -[NSWindow _commonInitFrame:styleMask:backing:defer:] + 1763
    6   AppKit                              0x00007fff87dfdfaf -[NSWindow _initContent:styleMask:backing:defer:contentView:] + 1568
    7   AppKit                              0x00007fff87dfd97f -[NSWindow initWithContentRect:styleMask:backing:defer:] + 45
    8   libSDL-1.2.0.dylib                  0x0000000101dc6bf6 -[SDL_QuartzWindow initWithContentRect:styleMask:backing:defer:] + 279
    9   libSDL-1.2.0.dylib                  0x0000000101dc4ac9 QZ_SetVideoMode + 2629
    10  libSDL-1.2.0.dylib                  0x0000000101dbb903 SDL_SetVideoMode + 886
    11  test                                0x0000000101b9d6b2 smJx_info + 50
)
libc++abi.dylib: terminate called throwing an exception

As far as I understand, this has something to do with main()-replacement trickery SDL performs. I looked at several other SDL-using Haskell apps; the ones that I managed to compile show the same behavior (which may point to some problem with my particular configuration). One exception is Eternal10Seconds which uses -no-hs-main ghc option and some .c/.h magic. Is this necessary, or there is more clear way to make things work?

  • 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-15T09:31:02+00:00Added an answer on June 15, 2026 at 9:31 am

    Sorry for the informational noise, but I managed to solve it myself. It seems that .c magic is inevitable, but it requires certain efforts to make it working with cabal. Based on the example from haskell-SDL repo and TimePiece, I put together a template. I am planning to extend it a bit to make it truly cross-platform (because I need it myself anyway).

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

Sidebar

Related Questions

I am just trying to compile and run a very simple test program, but
Trying to compile and run a simple Allegro program using Sublime Text 2 and
I'm trying to run this on OSX 10.7: /** * simple.d */ import std.stdio;
I'm trying to compile a simple c++ program to run inside ESXi 3.5 console
I am trying to compile and run a simple java class within eclipse. The
I am trying to compile and run a simple tutorial for an Objective C
Trying to run a simple Hello World C++ program on Eclipse (Galileo) CDT plugin
I am trying to run a simple java program in linux but getting a
I'm trying to make a simple JSF (based on PrimeFaces) application run. The main
I'm trying to compile a very simple program in Java 1.6 on Ubuntu Jaunty,

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.