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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:57:52+00:00 2026-05-12T17:57:52+00:00

How to make an Objective-C project work on Ubuntu? My files are: Fraction.h #import

  • 0

How to make an Objective-C project work on Ubuntu?

My files are:

Fraction.h

    #import <Foundation/NSObject.h>

    @interface Fraction: NSObject {
        int numerator;
        int denominator;
    }

    -(void) print;
    -(void) setNumerator: (int) n;
    -(void) setDenominator: (int) d;
    -(int) numerator;
    -(int) denominator;
    @end

Fraction.m

    #import "Fraction.h"
    #import <stdio.h>

    @implementation Fraction
    -(void) print {
        printf( "%i/%i", numerator, denominator );
    }

    -(void) setNumerator: (int) n {
        numerator = n;
    }

    -(void) setDenominator: (int) d {
        denominator = d;
    }

    -(int) denominator {
        return denominator;
    }

    -(int) numerator {
        return numerator;
    }
    @end

main.m

    #import <stdio.h>
    #import "Fraction.h"

    int main( int argc, const char *argv[] ) {
        // create a new instance
        Fraction *frac = [[Fraction alloc] init];

        // set the values
        [frac setNumerator: 1];
        [frac setDenominator: 3];

        // print it
        printf( "The fraction is: " );
        [frac print];
        printf( "\n" );

        // free memory
        [frac release];

        return 0;
    }

I’ve tried two approaches to compile it:

  1. Pure gcc:

    $ sudo apt-get install gobjc gnustep gnustep-devel
    $ gcc `gnustep-config --objc-flags` -o main main.m -lobjc -lgnustep-base
    /tmp/ccIQKhfH.o:(.data.rel+0x0): undefined reference to `__objc_class_name_Fraction'
    
  2. I created a GNUmakefile Makefile:

    include ${GNUSTEP_MAKEFILES}/common.make
    
    TOOL_NAME = main
    main_OBJC_FILES = main.m
    
    include ${GNUSTEP_MAKEFILES}/tool.make
    

    … and ran:

    $ source /usr/share/GNUstep/Makefiles/GNUstep.sh
    $ make
    Making all for tool main...
     Linking tool main ...
    ./obj/main.o:(.data.rel+0x0): undefined reference to `__objc_class_name_Fraction'
    

So in both cases compiler gets stuck at

    undefined reference to `__objc_class_name_Fraction'

Do you have and idea how to resolve this issue?

  • 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-05-12T17:57:53+00:00Added an answer on May 12, 2026 at 5:57 pm

    It’s right. In both cases you did not include Fraction.m in your list of files to be compiled, so it can’t find the implementation of the class Fraction

    From the comment, this command works

    gcc `gnustep-config --objc-flags` -o main *.m -lobjc -lgnustep-base
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i don't really know what ruby,gems, or ror is, my objective is make this
I'm trying to make a good block-based initializer for an objective-c class. I'm declaring
Possible Duplicate: how to make phone call by using objective c? I am trying
I'm learning Objective-C and trying to make a very simple command line calculator. 'S'
I'm a .NET developer trying to make the leap into objective-c iPhone programming. I
Are there standard optimization tricks for Objective-C to make for faster execution along the
I am programmatically creating a tableview in objective c. How can I make the
I have to make a project for the Windows OS in strics ANSI C
I've run into an Objective-C problem that doesn't seem to make any sense to
I'm currently in a project that need to work both on Mac and Windows.

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.