[Help] - Compile Daedalus with the most recent KOS Version.

Discussion in 'Sega Dreamcast Development and Research' started by LuizNai, Jan 14, 2018.

  1. LuizNai

    LuizNai Robust Member

    Joined:
    Jul 13, 2016
    Messages:
    243
    Likes Received:
    349
    Hi everyone, I´m trying to compile Daedalus for the Dreamcast using the most recent KOS version. The makefile that comes with the source code is a litlle bit messy and it contains very old libraries (Example: -lk++).

    Does someone could help me get it working with a new KOS version? It´s for an experiment! Thanks.

    Edit:

    Update 1 -
    Emulator compiled with new libraries, VMU ICON for Mario 64, Emulator booting Mario 64 automatically, speed improved a bit.



    GitHub link: https://github.com/TItanGuy99/Daedalus-Dreamcast

    My goal is try to achieve at least 15 fps for Mario 64 (Currently between 4.5/6.5 FPS in game), any help would be welcome! Next step I'll try to improve some routines in the CPU code!
     
    Last edited: Jan 23, 2018
    TerdFerguson likes this.
  2. -=FamilyGuy=-

    -=FamilyGuy=- Site Supporter 2049

    Joined:
    Mar 3, 2007
    Messages:
    3,097
    Likes Received:
    1,046
    TerdFerguson and LuizNai like this.
  3. LuizNai

    LuizNai Robust Member

    Joined:
    Jul 13, 2016
    Messages:
    243
    Likes Received:
    349
    Thanks brother, sent him a message!
     
    TerdFerguson and -=FamilyGuy=- like this.
  4. TerdFerguson

    TerdFerguson ls ~/

    Joined:
    Apr 27, 2015
    Messages:
    755
    Likes Received:
    468
    The graphics are actually pretty good for the build floating around, aside from the 2fps frame rate with no sound

    SM64 looks a lot sharper on VGA

    It'd be nice to see even 20fps with sound. but if it was ever full speed, playing DK64 or conker on dreamcast would be off the chain

    though i suppose the only hope for something llike that is A LOT of ASM, using DirectX\Direct3D via Windows CE for dll 'plugin' support for graphics, ARM SPU, maple, etc. cool prospect though
     
    LuizNai likes this.
  5. 8bitplus

    8bitplus Gutsy Member

    Joined:
    Feb 25, 2008
    Messages:
    476
    Likes Received:
    48
    That suddenly reminded me of early N64 emulation on the PSP. good times.
     
  6. LuizNai

    LuizNai Robust Member

    Joined:
    Jul 13, 2016
    Messages:
    243
    Likes Received:
    349
    Ok, I think I´m close now, I redid the makefile and now its just giving me an error -lk++ not found! I think it was removed in the new KOS. I need to know with what I will replace it. If someone has some hint let me know.

    Here is my makefile updated:

    ###############################################################################
    # This section can be adapted to the respective project
    ###############################################################################

    # Compilerdefinition
    CC = sh-elf-gcc
    CPP = sh-elf-g++
    AS = sh-elf-as
    RM = del
    MKDIR = C:\cygwin\bin\mkdir

    # File to create
    BIN = DaedalusDC.elf

    # output directory
    OUTPUT = -I"C:/cygwin/home/luiz_/dc/kos/Projects/my_game/obj" \

    # Directories with source code files
    SOURCES = -I"C:/cygwin/home/luiz_/dc/kos/Projects/my_game/src" \
    -I"C:/cygwin/home/luiz_/dc/kos/Projects/my_game/src/math/matrix" \
    -I"C:/cygwin/home/luiz_/dc/kos/Projects/my_game/src/math/plane" \
    -I"C:/cygwin/home/luiz_/dc/kos/Projects/my_game/src/math/vector" \

    # Include directories for the C compiler
    INCS = -I"C:/cygwin/home/luiz_/dc/kos/include" \
    -I"C:/cygwin/home/luiz_/dc/kos/addons/include" \
    -I"C:/cygwin/home/luiz_/dc/kos/kernel/arch/dreamcast/include" \
    -I"C:/cygwin/home/luiz_/dc/kos-ports/include" \
    -I"C:/cygwin/opt/toolchains/dc/sh-elf/sh-elf/include" \
    -I"src"

    # Include directories for the C ++ compiler
    CXXINCS = -I"C:/cygwin/home/luiz_/dc/kos/include" \
    -I"C:/cygwin/home/luiz_/dc/kos/addons/include" \
    -I"C:/cygwin/home/luiz_/dc/kos/kernel/arch/dreamcast/include" \
    -I"C:/cygwin/home/luiz_/dc/kos-ports/include" \
    -I"C:/cygwin/opt/toolchains/dc/sh-elf/sh-elf/include" \
    -I"C:/cygwin/opt/toolchains/dc/sh-elf/sh-elf/include/c++/4.7.3" \
    -I"src"

    # Library Directories
    LIBS = -L"C:/cygwin/home/luiz_/dc/kos/lib/dreamcast" \
    -L"C:/cygwin/home/luiz_/dc/kos/addons/lib/dreamcast" \
    -L"C:/cygwin/opt/toolchains/dc/sh-elf/sh-elf/lib"

    # Further settings for the assembler
    ASFLAGS = -little

    # Further settings for the C compiler
    CFLAGS = -Wall -g -ml -m4-single-only -O2 -fno-builtin -fno-strict-aliasing -fomit-frame-pointer -fno-optimize-sibling-calls -D_arch_dreamcast

    # Further settings for the C ++ compiler
    CXXFLAGS = -Wall -g -ml -m4-single-only -O2 -fno-builtin -fno-strict-aliasing -fomit-frame-pointer -fno-optimize-sibling-calls -D_arch_dreamcast

    # Additional settings for the linker
    LDFLAGS = -Wall -ml -m4-single-only -nostartfiles -nostdlib -Wl,-Ttext=0x8c010000 -Wl,--start-group -lk++ -lstdc++ -lparallax -lconio -lm -lkallisti -lc -lgcc -Wl,--end-group

    ###############################################################################
    # This section does not need to be customized
    ###############################################################################

    # Create a list of all files that need to be compiled
    ASSRC = $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.s))
    CSRC = $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.c))
    CPPSRC = $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.cpp))

    # Create a list of the object files created during compilation
    ASOBJ = $(patsubst %.s, %.o, $(ASSRC))
    COBJ = $(patsubst %.c, %.o, $(CSRC))
    CPPOBJ = $(patsubst %.cpp, %.o, $(CPPSRC))
    OBJ = $(ASOBJ) $(COBJ) $(CPPOBJ)

    # Specify that the object files are also searched for in the output directory
    vpath %.o $(OUTPUT)

    # Assemble all Assembler source code files
    %.o: %.s
    $(MKDIR) -p $(dir $(OUTPUT)/$*.o)
    $(AS) $(ASFLAGS) $*.s -o $(OUTPUT)/$*.o

    # Compile all C source code files into object files
    %.o: %.c
    $(MKDIR) -p $(dir $(OUTPUT)/$*.o)
    $(CC) $(CFLAGS) $(INCS) -c $*.c -o $(OUTPUT)/$*.o

    # Compile all C ++ source code files into object files
    %.o: %.cpp
    $(MKDIR) -p $(dir $(OUTPUT)/$*.o)
    $(CPP) $(CXXFLAGS) $(CXXINCS) -c $*.cpp -o $(OUTPUT)/$*.o

    # All object files and external libraries link to the output file
    $(BIN): $(OBJ)
    $(CPP) -o $(BIN) startup.o $(patsubst %, $(OUTPUT)/%, $(OBJ)) $(LIBS) $(LDFLAGS)

    clean:
    -rm -f main.elf $(OBJS)
    -rm -f romdisk.*

    dist:
    -rm -f $(OBJS)
    -rm -f romdisk.*
    $(KOS_STRIP) startup.elf

    rm-elf:
    -rm -f startup.elf
    -rm -f romdisk.*







    Here is the error I´m getting:

    $ make
    sh-elf-g++ -o DaedalusDC.elf startup.o -L"C:/cygwin/home/luiz_/dc/kos/lib/dreamcast" -L"C:/cygwin/home/luiz_/dc/kos/addons/lib/dreamcast" -L"C:/cygwin/opt/toolchains/dc/sh-elf/sh-elf/lib" -Wall -ml -m4-single-only -nostartfiles -nostdlib -Wl,-Ttext=0x8c010000 -Wl,--start-group -lk++ -lstdc++ -lparallax -lconio -lm -lkallisti -lc -lgcc -Wl,--end-group
    /opt/toolchains/dc/sh-elf/lib/gcc/sh-elf/4.7.3/../../../../sh-elf/bin/ld: cannot find -lk++
    collect2: error: ld returned 1 exit status
    make: *** [makefile:93: DaedalusDC.elf] Error 1
     
  7. -=FamilyGuy=-

    -=FamilyGuy=- Site Supporter 2049

    Joined:
    Mar 3, 2007
    Messages:
    3,097
    Likes Received:
    1,046
    You may get an old version of KOS to check what's actually used from k++ then find the corresponding header in the current version. You could still try to simply not include it and see if it works, maybe it is obsolete now.
     
    LuizNai likes this.
  8. LuizNai

    LuizNai Robust Member

    Joined:
    Jul 13, 2016
    Messages:
    243
    Likes Received:
    349
    If I remove -lk++ I get this error:

    sh-elf-g++ -o DaedalusDC.elf startup.o -L"C:/cygwin/home/luiz_/dc/kos/lib/dreamcast" -L"C:/cygwin/home/luiz_/dc/kos/addons/lib/dreamcast" -L"C:/cygwin/opt/toolchains/dc/sh-elf/sh-elf/lib" -Wall -ml -m4-single-only -nostartfiles -nostdlib -Wl,-Ttext=0x8c010000 -Wl,--start-group -lstdc++ -lparallax -lconio -lm -lkallisti -lc -lgcc -Wl,--end-group
    C:/cygwin/home/luiz_/dc/kos/lib/dreamcast/libkallisti.a(init.o): In function `arch_shutdown':
    /opt/toolchains/dc/kos/kernel/arch/dreamcast/kernel/init.c:257: undefined reference to `_fini'
    C:/cygwin/home/luiz_/dc/kos/lib/dreamcast/libkallisti.a(init.o): In function `arch_main':
    /opt/toolchains/dc/kos/kernel/arch/dreamcast/kernel/init.c:209: undefined reference to `_init'
    /opt/toolchains/dc/kos/kernel/arch/dreamcast/kernel/init.c:209: undefined reference to `_main'
    collect2: error: ld returned 1 exit status
    make: *** [makefile:93: DaedalusDC.elf] Error 1
     
  9. LuizNai

    LuizNai Robust Member

    Joined:
    Jul 13, 2016
    Messages:
    243
    Likes Received:
    349
    Going to check that, tks bro!
     
    -=FamilyGuy=- likes this.
  10. -=FamilyGuy=-

    -=FamilyGuy=- Site Supporter 2049

    Joined:
    Mar 3, 2007
    Messages:
    3,097
    Likes Received:
    1,046
    You won't like it, but I found this post by Mr. Sebald that says it's obsolete and should be deleted from the makefile.

    So you might have to fix those compilation errors in the end.
     
  11. -=FamilyGuy=-

    -=FamilyGuy=- Site Supporter 2049

    Joined:
    Mar 3, 2007
    Messages:
    3,097
    Likes Received:
    1,046
  12. BlueCrab

    BlueCrab Member

    Joined:
    Feb 6, 2007
    Messages:
    16
    Likes Received:
    11
    That Makefile looks extremely complicated for what you probably need to do...

    A normal Makefile for something built with KOS should not require all of that cruft these days... For instance, here's the Makefile for a little DNS server I made for the Sylverant PSO Server:
    Code:
    #
    # Sylverant DNS Server
    # Dreamast Makefile
    #
    # Why? Because I can.
    #
    
    TARGET = pso_dns.elf
    OBJS = pso_dns.o romdisk.o
    KOS_ROMDISK_DIR = romdisk
    KOS_CFLAGS += -Wno-char-subscripts
    
    all: $(TARGET)
    
    $(TARGET): $(OBJS)
        kos-cc -o $(TARGET) $(OBJS)
        -rm -f romdisk.*
        -rm -rf romdisk
    
    romdisk:
        mkdir romdisk
        cp pso_dns.conf.sample romdisk/pso_dns.conf
    
    romdisk.img: romdisk
    
    clean:
        -rm -f $(OBJS) $(TARGET) romdisk.*
        -rm -fr romdisk
    
    .PHONY: clean all
    
    include $(KOS_BASE)/Makefile.rules

    Usually, that's pretty much all there is to it. You certainly shouldn't have to list out all the compiler's built-in include directories or any of KOS' either. Anyway, here's a stab at what you're probably looking for... For simplicity, this assumes that you're building out of the src directory (so you should put the Makefile there).
    Code:
    TARGET = DaedalusDC.elf
    
    SOURCES = . math/matrix math/plane math/vector
    
    # Create a list of all files that need to be compiled
    ASSRC = $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.s))
    CSRC = $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.c))
    CPPSRC = $(foreach dir, $(SOURCES), $(wildcard $(dir)/*.cpp))
    
    # Create a list of the object files created during compilation
    ASOBJ = $(patsubst %.s, %.o, $(ASSRC))
    COBJ = $(patsubst %.c, %.o, $(CSRC))
    CPPOBJ = $(patsubst %.cpp, %.o, $(CPPSRC))
    
    # You need to put all your object files that should be compiled here. All the
    # voodoo work up above should hopefully fill in all of the variables used here
    # and make a complete list here... All of that stuff was used directly from your
    # old Makefile, for reference.
    OBJS = $(ASOBJ) $(COBJ) $(CPPOBJ)
    
    # This shouldn't be needed, unless you're including things out of the src
    # directory with #include <file.h> instead of #include "file.h". But, since you
    # had this here before effectively, it shouldn't hurt to include it.
    KOS_CFLAGS += -I.
    
    # This list of libraries taken directly from your old Makefile, with ones you
    # definitely don't need removed from it. I obviously can't comment on whatever
    # you have left here.
    LIBS = -lparallax -lconio -lm
    
    all: $(TARGET)
    
    $(TARGET): $(OBJS)
        kos-c++ -o $(TARGET) $(OBJS) $(LIBS)
    
    clean:
        -rm -f $(OBJS) $(TARGET)
    
    .PHONY: clean all
    
    # This includes all the KOS magic for you, including rules to build .o files out
    # of .c, .cpp, and .s files.
    include $(KOS_BASE)/Makefile.rules
    I (obviously) haven't tested this Makefile out, but it looks sane enough...
     
  13. LuizNai

    LuizNai Robust Member

    Joined:
    Jul 13, 2016
    Messages:
    243
    Likes Received:
    349
    Ohh man thanks a lot! You are the best!
     
    TerdFerguson likes this.
  14. TerdFerguson

    TerdFerguson ls ~/

    Joined:
    Apr 27, 2015
    Messages:
    755
    Likes Received:
    468
    post the results of the compile dude
     
    LuizNai likes this.
  15. LuizNai

    LuizNai Robust Member

    Joined:
    Jul 13, 2016
    Messages:
    243
    Likes Received:
    349
    I will do that tonight bro!
     
  16. LuizNai

    LuizNai Robust Member

    Joined:
    Jul 13, 2016
    Messages:
    243
    Likes Received:
    349
    I got this:


    /home/luiz_/dc/kos/lib/dreamcast/libkallisti.a(init.o): In function `arch_main':
    /opt/toolchains/dc/kos/kernel/arch/dreamcast/kernel/init.c:209: undefined reference to `_main'
    collect2: error: ld returned 1 exit status
    make: *** [makefile:34: DaedalusDC.elf] Error 1



    I know cygwin sucks, Im going to install KOS on Ubuntu and try it tonight.

    Edit: Other projects I can compile. But Ill install in linux anyway.
     
    Last edited: Jan 17, 2018
  17. LuizNai

    LuizNai Robust Member

    Joined:
    Jul 13, 2016
    Messages:
    243
    Likes Received:
    349
    LoL, I got it working! Thanks a lot, Im going to post the results here soon!
     
    TerdFerguson likes this.
  18. TerdFerguson

    TerdFerguson ls ~/

    Joined:
    Apr 27, 2015
    Messages:
    755
    Likes Received:
    468
    !?!
     
    LuizNai likes this.
  19. LuizNai

    LuizNai Robust Member

    Joined:
    Jul 13, 2016
    Messages:
    243
    Likes Received:
    349
    I got it compiled and it is running now! I´m doing my tests If I get any improvement Ill post it here.
     
    TerdFerguson and fafadou like this.
  20. LuizNai

    LuizNai Robust Member

    Joined:
    Jul 13, 2016
    Messages:
    243
    Likes Received:
    349
    Update 1 -
    Emulator compiled with new libraries, VMU ICON for Mario 64, Emulator booting Mario 64 automatically, speed improved a bit.



    GitHub link: https://github.com/TItanGuy99/Daedalus-Dreamcast

    My goal is try to achieve at least 15 fps for Mario 64 (Currently between 4.5/6.5 FPS in game), any help would be welcome! Next step I'll try to improve some routines in the CPU code!
     

Share This Page