I am trying to get Button.c to work, which is the first of the Walkthroughs from Week 5. I transferred the spl folder to my current directory, altered the Makefile from Breakout so it is working on button.c and I actually got the program to compile. I get the following runtime error: "Error: Unable to access jarfile spl.jar" I did not use the syntax suggested in the Walkthrough for the 2014 version because that did not compile so my code looks like this:

#include <stdio.h>
#include <string.h>
/*#include <spl/gevents.h>
#include <spl/ginteractors.h>
#include <spl/gwindow.h>*/
#include "gevents.h"
#include "ginteractors.h"
#include "gwindow.h"

int main(void)
    GWindow window = newGWindow(320, 240);

    GButton button = newGButton("Button");
    setActionCommand(button, "click");

    addToRegion(window, button, "SOUTH");

    while (true)
        GActionEvent event = waitForEvent(ACTION_EVENT);

        if (getEventType(event) == WINDOW_CLOSED) break;

        if (strcmp(getActionCommand(event), "click") == 0) printf("button was clicked.\n");
    return 0;

The Makefile looks like this:

# Makefile
# Computer Science 50
# Week 5 Walkthroughs

button: button.c Makefile
    clang -ggdb3 -Ispl/include -O0 -std=c99 -Wall -Werror -Wno-unused-variable -o button button.c -Lspl/lib -lcs -lm

    rm -f *.o core button
  • make sure the file named spl.jar from pset4 files exists in the same directory as your executable! – Kareem Oct 18 '14 at 16:30
  • Thanks Kareem! That worked. Add it as an answer, rather than a comment, and you can get credit for answering. – Brendan Rafferty Oct 18 '14 at 18:56

Place the file named spl.jar (from pset4 files) in the same directory as your executable!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .