ObjC sample project from scratch
  • Order of the Butterfly
    Order of the Butterfly
    asrael22
    Posts: 436 from 2014/6/11
    From: Germany
    Hi.

    I'm current playing with the ObjC implementation and trying to get a simple Hello World working.

    After creating a new project in FlowStudio and simple main.c that prints a HGelloWorld using printf works fine.

    But when adding a new ObjC class and linking I get a linker error like this:

    Code:

    make: Entering directory '/Work/DevelAdd/Sources/objc/FooTest319'

    compiling main_RELEASE.o

    › q› qcompiling AppMain_RELEASE.mo

    › q› qlinking FooTest

    /gg/ppc-morphos/bin/ld: /gg/ppc-morphos/lib/libobjfwrt.library.a(linklib.o): in function `ctor':

    /home/jaca/morphos/morphoswb/classes/frameworks/objfw/ObjFW/src/runtime/linklib/linklib.m:102: undefined reference to `_Unwind_RaiseException'

    /gg/ppc-morphos/bin/ld: /home/jaca/morphos/morphoswb/classes/frameworks/objfw/ObjFW/src/runtime/linklib/linklib.m:68: undefined reference to `_Unwind_DeleteException'

    /gg/ppc-morphos/bin/ld: /home/jaca/morphos/morphoswb/classes/frameworks/objfw/ObjFW/src/runtime/linklib/linklib.m:70: undefined reference to `_Unwind_GetLanguageSpecificData'

    /gg/ppc-morphos/bin/ld: /home/jaca/morphos/morphoswb/classes/frameworks/objfw/ObjFW/src/runtime/linklib/linklib.m:102: undefined reference to `_Unwind_GetRegionStart'

    /gg/ppc-morphos/bin/ld: /home/jaca/morphos/morphoswb/classes/frameworks/objfw/ObjFW/src/runtime/linklib/linklib.m:102: undefined reference to `_Unwind_GetDataRelBase'

    /gg/ppc-morphos/bin/ld: /home/jaca/morphos/morphoswb/classes/frameworks/objfw/ObjFW/src/runtime/linklib/linklib.m:102: undefined reference to `_Unwind_GetTextRelBase'

    /gg/ppc-morphos/bin/ld: /home/jaca/morphos/morphoswb/classes/frameworks/objfw/ObjFW/src/runtime/linklib/linklib.m:105: undefined reference to `_Unwind_GetIP'

    /gg/ppc-morphos/bin/ld: /home/jaca/morphos/morphoswb/classes/frameworks/objfw/ObjFW/src/runtime/linklib/linklib.m:105: undefined reference to `_Unwind_GetGR'

    /gg/ppc-morphos/bin/ld: /home/jaca/morphos/morphoswb/classes/frameworks/objfw/ObjFW/src/runtime/linklib/linklib.m:105: undefined reference to `_Unwind_SetIP'

    /gg/ppc-morphos/bin/ld: /home/jaca/morphos/morphoswb/classes/frameworks/objfw/ObjFW/src/runtime/linklib/linklib.m:105: undefined reference to `_Unwind_SetGR'

    /gg/ppc-morphos/bin/ld: /home/jaca/morphos/morphoswb/classes/frameworks/objfw/ObjFW/src/runtime/linklib/linklib.m:105: undefined reference to `_Unwind_Resume'

    /gg/ppc-morphos/bin/ld: /home/jaca/morphos/morphoswb/classes/frameworks/objfw/ObjFW/src/runtime/linklib/linklib.m:105: undefined reference to `__register_frame_info'

    /gg/ppc-morphos/bin/ld: /home/jaca/morphos/morphoswb/classes/frameworks/objfw/ObjFW/src/runtime/linklib/linklib.m:105: undefined reference to `__deregister_frame_info'

    collect2: ld returned 1 exit status

    make: *** [Work:DevelAdd/Sources/objc/FooTest319/Makefile:79: FooTest] Error 1

    make: Leaving directory '/Work/DevelAdd/Sources/objc/FooTest319'


    The ObjC code is quite simple:

    Code:

    #import <ob/OBFramework.h>
    #include "stdio.h"

    @interface MainApp : OBObject

    @end

    @implementation MainApp

    - (void) main {
    printf("Hello from MainApp.");
    }

    @end



    Any idea what the problem is?
  • »17.10.25 - 13:16
    Profile
  • MorphOS Developer
    jacadcaps
    Posts: 3237 from 2003/3/5
    From: Canada
    The Flow defaults are unfortunately a little wrong. See if

    ppc-morphos-gcc-9 -o objc objc.m -I /SDK/Frameworks/include -lob.framework -lobjc -noixemul

    works.

    Alternatively -lob-fw.framework -lobjfwrt -noixemul to link with ObjFW runtime.
  • »18.10.25 - 16:20
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    asrael22
    Posts: 436 from 2014/6/11
    From: Germany
    Cool, thanks.

    The former works.
    The latter raises error:
    /System/Development/gg/bin/../lib/gcc-lib/ppc-morphos/9.5.0/../../../../ppc-morphos/bin/ld: cannot find -lobjfwrt: No such file or directory


    Regarding ObjFW, can one use the full ObjFW framework?
  • »20.10.25 - 13:13
    Profile
  • MorphOS Developer
    jacadcaps
    Posts: 3237 from 2003/3/5
    From: Canada
    Sorry, we're changing names of some libs so I might have given you a wrong one there :)

    As for ObjFW - if you want to create a UI app, you need to stick to ob.framework and mui.framework (which can optionally use objfw runtime). If you want to use ObjFW you can, but it would require bridging between objfw and ob.

    Btw you can build full ObjFW yourself from its source - it'll build and work on MorphOS.
  • »20.10.25 - 16:56
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    asrael22
    Posts: 436 from 2014/6/11
    From: Germany
    That's awesome.

    Will this be fixed in FlowStudio in next MorphOS release? Some (or one at least) application templates when for starting a new project would be cool as well.
  • »20.10.25 - 17:47
    Profile
  • MorphOS Developer
    jacadcaps
    Posts: 3237 from 2003/3/5
    From: Canada
    Yes, that's the plan.
  • »20.10.25 - 18:00
    Profile Visit Website