What do you do if it parses fine but the linker throws up?

About Monkey 2 Forums Monkey 2 Programming Help What do you do if it parses fine but the linker throws up?

This topic contains 4 replies, has 3 voices, and was last updated by  Arjailer 2 years, 10 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #2840

    MikeHart
    Participant

    I feel like I am back in my C++ days. These days where I fought more with the linker than with my code logic. I hate it, I hate it, i hate it. What good is a high level language when you have to deal with the underlying technology. It parses fine but then it comes to the linking part, I get errors.

    So…. how do you deal with it? Any hints where you can track back the problem to the original monkey code?

    #2841

    MikeHart
    Participant

    If you are curious, what I see on my screen…

    mx2cc version 1.0.2

    ***** Making module ‘fantomX2’ *****

    Parsing…
    Semanting…
    Translating…
    Compiling….
    Build error: System command ‘g++ -std=c++11 -m32 -O3 -DNDEBUG -I”C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/freetype/freetype-2.6.3/include/” -I”C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/openal/openal-soft/include/” -I”C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/gles20/angle/include/” -I”C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/sdl2/SDL/include/” -I”C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/monkey/native” -c -o “C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/fantomX2/fantomX2.buildv1.0.2/build_cache/desktop_release_windows/fantomX2_0cftTimer.cpp.o” “C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/fantomX2/fantomX2.buildv1.0.2/build_cache/desktop_release_windows/fantomX2_cftTimer.cpp”‘ failed.

    g++ -std=c++11 -m32 -O3 -DNDEBUG -I”C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/freetype/freetype-2.6.3/include/” -I”C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/openal/openal-soft/include/” -I”C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/gles20/angle/include/” -I”C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/sdl2/SDL/include/” -I”C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/monkey/native” -c -o “C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/fantomX2/fantomX2.buildv1.0.2/build_cache/desktop_release_windows/fantomX2_0cftTimer.cpp.o” “C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/fantomX2/fantomX2.buildv1.0.2/build_cache/desktop_release_windows/fantomX2_cftTimer.cpp”

    In file included from C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/monkey/native/bbmonkey.h:10:0,
    from C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/fantomX2/fantomX2.buildv1.0.2/desktop_release_windows/fantomX2_cftTimer.h:5,
    from C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/fantomX2/fantomX2.buildv1.0.2/build_cache/desktop_release_windows/fantomX2_cftTimer.cpp:2:
    C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/monkey/native/bbgc.h: In instantiation of ‘void bbGCVar<T>::enqueue() [with T = t_fantomX2_ftLayer]’:
    C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/monkey/native/bbgc.h:194:10: required from ‘bbGCVar<T>::bbGCVar(T*) [with T = t_fantomX2_ftLayer]’
    C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/fantomX2/fantomX2.buildv1.0.2/desktop_release_windows/fantomX2_cftEngine.h:122:69: required from here
    C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/monkey/native/bbgc.h:186:16: error: cannot dynamic_cast ‘((bbGCVar<t_fantomX2_ftLayer>*)this)->bbGCVar<t_fantomX2_ftLayer>::_ptr’ (of type ‘struct t_fantomX2_ftLayer*’) to type ‘struct bbGCNode*’ (source is a pointer to incomplete type)
    bbGC::enqueue( dynamic_cast<bbGCNode*>( _ptr ) );
    ^
    C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/monkey/native/bbgc.h: In instantiation of ‘void bbGCVar<T>::enqueue() [with T = t_fantomX2_ftImageManager]’:
    C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/monkey/native/bbgc.h:194:10: required from ‘bbGCVar<T>::bbGCVar(T*) [with T = t_fantomX2_ftImageManager]’
    C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/fantomX2/fantomX2.buildv1.0.2/desktop_release_windows/fantomX2_cftEngine.h:126:77: required from here
    C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/monkey/native/bbgc.h:186:16: error: cannot dynamic_cast ‘((bbGCVar<t_fantomX2_ftImageManager>*)this)->bbGCVar<t_fantomX2_ftImageManager>::_ptr’ (of type ‘struct t_fantomX2_ftImageManager*’) to type ‘struct bbGCNode*’ (source is a pointer to incomplete type)
    C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/monkey/native/bbgc.h: In instantiation of ‘void bbGCVar<T>::enqueue() [with T = t_fantomX2_ftFont]’:
    C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/monkey/native/bbgc.h:194:10: required from ‘bbGCVar<T>::bbGCVar(T*) [with T = t_fantomX2_ftFont]’
    C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/fantomX2/fantomX2.buildv1.0.2/desktop_release_windows/fantomX2_cftObject.h:79:62: required from here
    C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/monkey/native/bbgc.h:186:16: error: cannot dynamic_cast ‘((bbGCVar<t_fantomX2_ftFont>*)this)->bbGCVar<t_fantomX2_ftFont>::_ptr’ (of type ‘struct t_fantomX2_ftFont*’) to type ‘struct bbGCNode*’ (source is a pointer to incomplete type)
    C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/monkey/native/bbgc.h: In instantiation of ‘void bbGCVar<T>::enqueue() [with T = t_fantomX2_ftTileMap]’:
    C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/monkey/native/bbgc.h:194:10: required from ‘bbGCVar<T>::bbGCVar(T*) [with T = t_fantomX2_ftTileMap]’
    C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/fantomX2/fantomX2.buildv1.0.2/desktop_release_windows/fantomX2_cftObject.h:112:68: required from here
    C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/monkey/native/bbgc.h:186:16: error: cannot dynamic_cast ‘((bbGCVar<t_fantomX2_ftTileMap>*)this)->bbGCVar<t_fantomX2_ftTileMap>::_ptr’ (of type ‘struct t_fantomX2_ftTileMap*’) to type ‘struct bbGCNode*’ (source is a pointer to incomplete type)
    C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/monkey/native/bbgc.h: In instantiation of ‘void bbGCVar<T>::enqueue() [with T = t_fantomX2_ftObjAnimMng]’:
    C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/monkey/native/bbgc.h:194:10: required from ‘bbGCVar<T>::bbGCVar(T*) [with T = t_fantomX2_ftObjAnimMng]’
    C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/fantomX2/fantomX2.buildv1.0.2/desktop_release_windows/fantomX2_cftObject.h:121:74: required from here
    C:/Users/Micha/Desktop/FantomMonkey/monkey2/modules/monkey/native/bbgc.h:186:16: error: cannot dynamic_cast ‘((bbGCVar<t_fantomX2_ftObjAnimMng>*)this)->bbGCVar<t_fantomX2_ftObjAnimMng>::_ptr’ (of type ‘struct t_fantomX2_ftObjAnimMng*’) to type ‘struct bbGCNode*’ (source is a pointer to incomplete type)
    ***** Fatal mx2cc error *****

    Build error.

    #2843

    peterigz
    Participant

    There’s still some things in the parser that misses these errors before they get to the compiler but they’re getting added overtime I think. It could also just be a bug in mx2cc that’s not translating properly.

    If it happens to me then I look at what the compiler is pointing at, usually a variable, and then try and figure it out from there.

    It’s interesting that it seems to be the garbage collector complaining about a struct (t_fantomX2_ftLayer) or a pointer to a struct when I didn’t think the GC got involved with structs, not that I know much about the inner workings!

    #2851

    MikeHart
    Participant

    It could be, that one problem is the initialisation of class fields which represent an object with a NULL value:

    Field engine:ftEngine = Null

    I have to test this further

    #3083

    Arjailer
    Participant

    I’m getting the same error if I have a class who’s methods are not directly called by any static code.

    The class in question is created by a factory class which can return one of many implementations of an interface. One of those implementations contains the only call to a particular method in another class. Compilation fails with the same error “source is a pointer to incomplete type”.

    If I add a call to the method in question from somewhere else in the codebase then it compiles fine, but that’s a bit daft, and as it stands I can’t proceed with my current design (which worked fine in Monkey X, C# etc)  🙁

    Unfortunately I can’t replicate in a test harness either  🙁

     

    Edit: Having just read MikeHart’s comment above I changed my code to declare the objects without = Null at the end and now it works! Wha?

    Edit: Also I can now replicate it with a small test harness (by adding an = Null). Build app.monkey2 in the attached zip and it should fail. If you remove the = Null from the end of the line Field globalState:GlobalState = Null in logic.monkey2 or put all the code together in one file it should work. Any one know why?

    Attachments:
    1. example.zip
Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.