Errors when compiling sftdlib apps

Discussion in '3DS - Homebrew Development and Emulators' started by mashers, Sep 20, 2015.

  1. mashers
    OP

    mashers Stubborn ape

    Member
    3,837
    5,154
    Jun 10, 2015
    Kongo Jungle
    I'm trying to get sftdlib working in the Homebrew launcher so I can change the font. I've installed SF2D, Freetype and sftdlib into my devkitpro environment. When I try to build the Homebrew Launcher, I get an error on the console saying "undefined reference to `sftd_load_font_mem'". The strange thing is that this method is defined in sftd.h, which is included at the top of my c file. If I try to compile the sample included with sftdlib then I get a load of undefined reference errors relating to libpng functions. I installed the libpng portlib but this doesn't seem to have made any difference.

    Any help would be much appreciated!
     


  2. Garcia98

    Garcia98 Hey! Listen!

    Member
    361
    188
    Sep 8, 2015
    Salamanca
  3. mashers
    OP

    mashers Stubborn ape

    Member
    3,837
    5,154
    Jun 10, 2015
    Kongo Jungle
    Hi mate,

    Thanks for your reply. I have two copies of sftd.h. One is in /opt/devkitPro/portlibs/armv6k/include, and the other is in /opt/devkitPro/libstru/include. I did try installing the portlibs with the Makefile you linked to but it only seemed to build them, not actually install them, so I downloaded the individual package and installed them manually.
     
  4. Garcia98

    Garcia98 Hey! Listen!

    Member
    361
    188
    Sep 8, 2015
    Salamanca
    So which are the errors when you try to compile the example?
     
  5. mashers
    OP

    mashers Stubborn ape

    Member
    3,837
    5,154
    Jun 10, 2015
    Kongo Jungle
    Here you go:

    sftdlib sample build errors

    Edit - code tags
     
  6. Garcia98

    Garcia98 Hey! Listen!

    Member
    361
    188
    Sep 8, 2015
    Salamanca
    Are you sure that libpng is properly installed?
     
  7. elhobbs

    elhobbs GBAtemp Advanced Fan

    Member
    767
    284
    Jul 28, 2008
    United States
    These are linker errors. you need to add the libraries to your makefile.
     
  8. mashers
    OP

    mashers Stubborn ape

    Member
    3,837
    5,154
    Jun 10, 2015
    Kongo Jungle
    You're right - it wasn't linked in the makefile. I added -lpng and got lots of errors about VFP register arguments. I changed from hard to soft float and then started getting this error:

    Code:
    iMash:sample mash$ make clean
    clean ...
    iMash:sample mash$ make
    FreeSans.ttf
    main.c
    arm-none-eabi-gcc -MMD -MP -MF /Users/mash/Downloads/sftdlib-master/sample/build/main.d -g -Wall -O2 -mword-relocations -fomit-frame-pointer -ffast-math -march=armv6k -mtune=mpcore -mfloat-abi=soft -I/Users/mash/Downloads/sftdlib-master/sample/include -I/opt/devkitPro/libctru/include -I/opt/devkitPro/portlibs/armv6k/include -I/opt/devkitPro/portlibs/3ds/include -I/Users/mash/Downloads/sftdlib-master/sample/build -DARM11 -D_3DS -c /Users/mash/Downloads/sftdlib-master/sample/source/main.c -o main.o
    linking sftd_sample.elf
    /opt/devkitPro/devkitARM/bin/../lib/gcc/arm-none-eabi/4.9.2/../../../../arm-none-eabi/bin/ld: cannot find 3dsx_crt0.o: No such file or directory
    collect2: error: ld returned 1 exit status
    make[1]: *** [/Users/mash/Downloads/sftdlib-master/sample/sftd_sample.elf] Error 1
    make: *** [build] Error 2
    which apparently means I have to use hard float... So I really have no idea how to get this working. I'm actually wondering if the problem is that I'm using a Mac. Do you think it would make any difference if I set up devkitpro in a Linux VM and try building there?
     
  9. Garcia98

    Garcia98 Hey! Listen!

    Member
    361
    188
    Sep 8, 2015
    Salamanca
    In the example libraries are already in the Makefile (obviously).
    Lol I asked you what were the errors of sftd example, not the errors of your project
     
  10. mashers
    OP

    mashers Stubborn ape

    Member
    3,837
    5,154
    Jun 10, 2015
    Kongo Jungle
    That's what I posted - the errors are all from trying to compile just the sample.
     
  11. Garcia98

    Garcia98 Hey! Listen!

    Member
    361
    188
    Sep 8, 2015
    Salamanca
    So in the Makefile every needed library is there xD
     
  12. mashers
    OP

    mashers Stubborn ape

    Member
    3,837
    5,154
    Jun 10, 2015
    Kongo Jungle
    I think I might have taken -lpng out of the makefile to try to resolve errors before installing libpng properly since I didn't think libpng would be required for text. In any case, the most recent error is now the relevant one.
     
  13. Garcia98

    Garcia98 Hey! Listen!

    Member
    361
    188
    Sep 8, 2015
    Salamanca
    Did you also changed -mfloat-abi=hard to -mfloat-abi=softfp?
     
  14. mashers
    OP

    mashers Stubborn ape

    Member
    3,837
    5,154
    Jun 10, 2015
    Kongo Jungle
    Actually I put -mfloat-abi-soft, but I've just changed it to softfp and got the same error:

    Code:
    iMash:sample mash$ make
    FreeSans.ttf
    main.c
    arm-none-eabi-gcc -MMD -MP -MF /Users/mash/Downloads/sftdlib-master/sample/build/main.d -g -Wall -O2 -mword-relocations -fomit-frame-pointer -ffast-math -march=armv6k -mtune=mpcore -mfloat-abi=softfp -I/Users/mash/Downloads/sftdlib-master/sample/include -I/opt/devkitPro/libctru/include -I/opt/devkitPro/portlibs/armv6k/include -I/opt/devkitPro/portlibs/3ds/include -I/Users/mash/Downloads/sftdlib-master/sample/build -DARM11 -D_3DS -c /Users/mash/Downloads/sftdlib-master/sample/source/main.c -o main.o
    linking sftd_sample.elf
    /opt/devkitPro/devkitARM/bin/../lib/gcc/arm-none-eabi/4.9.2/../../../../arm-none-eabi/bin/ld: cannot find 3dsx_crt0.o: No such file or directory
    collect2: error: ld returned 1 exit status
    make[1]: *** [/Users/mash/Downloads/sftdlib-master/sample/sftd_sample.elf] Error 1
    make: *** [build] Error 2
    iMash:sample mash$ 
     
  15. Garcia98

    Garcia98 Hey! Listen!

    Member
    361
    188
    Sep 8, 2015
    Salamanca
    Lol, you must use hard

    Why do you modify things in the example? The example will compile correctly if your environment is properly set
     
  16. mashers
    OP

    mashers Stubborn ape

    Member
    3,837
    5,154
    Jun 10, 2015
    Kongo Jungle
    Well I've just extracted sftdlib from the github archive again and got exactly the same errors ("VFP register arguments" errors when using hard float, "cannot find 3dsx_crt0.o" when using softfp).
     
  17. Garcia98

    Garcia98 Hey! Listen!

    Member
    361
    188
    Sep 8, 2015
    Salamanca
    Your libraries are also built with -mfloat-abi=hard?
     
    Last edited by Garcia98, Sep 20, 2015
  18. mashers
    OP

    mashers Stubborn ape

    Member
    3,837
    5,154
    Jun 10, 2015
    Kongo Jungle
    I don't know. How do I tell?
     
  19. elhobbs

    elhobbs GBAtemp Advanced Fan

    Member
    767
    284
    Jul 28, 2008
    United States
    After changing the float from soft to hard you need to rebuild everything. Libraries and your project - make clean && make
     
  20. Garcia98

    Garcia98 Hey! Listen!

    Member
    361
    188
    Sep 8, 2015
    Salamanca
    ^That^