QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: SMcNeill on November 27, 2021, 07:46:06 pm

Title: [fixed] Current Development Build tosses compile errors (fix: falcon.h needs _LOADFONT to work)
Post by: SMcNeill on November 27, 2021, 07:46:06 pm
Code: [Select]
Declare Library ".\falcon"
    Sub uprint_extra (ByVal x&, Byval y&, Byval chars%&, Byval length%&, Byval kern&, Byval do_render&, txt_width&, Byval charpos%&, charcount&, Byval colour~&, Byval max_width&)
    Function uprint (ByVal x&, Byval y&, chars$, Byval txt_len&, Byval colour~&, Byval max_width&)
    Function uprintwidth (chars$, Byval txt_len&, Byval max_width&)
    Function uheight& ()
    Function uspacing& ()
    Function uascension& ()
End Declare

Simpy toss falcon.h into your QB64 folder, and download a fresh copy of the repo, and compile the above.  What I'm getting is the following set of error messages:

C:\Users\the_r\AppData\Local\Temp\ccjqRJ4V.o:qbx.cpp:(.text+0x838): undefined reference to `FT_Get_Char_Index'
C:\Users\the_r\AppData\Local\Temp\ccjqRJ4V.o:qbx.cpp:(.text+0x86c): undefined reference to `FT_Get_Kerning'
C:\Users\the_r\AppData\Local\Temp\ccjqRJ4V.o:qbx.cpp:(.text+0x88e): undefined reference to `FT_Load_Glyph'
C:\Users\the_r\AppData\Local\Temp\ccjqRJ4V.o:qbx.cpp:(.text+0x8b0): undefined reference to `FT_Render_Glyph'
C:\Users\the_r\AppData\Local\Temp\ccjqRJ4V.o:qbx.cpp:(.rdata$.refptr.fonts[.refptr.fonts]+0x0): undefined reference to `fonts'
collect2.exe: error: ld returned 1 exit status

It looks as if QB64 is now trying to get our Temp system folder and work with things from there, but it's failing to do so.  Is someone pushing changes to move the qb64 temp folders into the system Temp folders?  If they are, it appears as if they've missed a few links or some such somewhere.
Title: Re: [fixed] Current Development Build tosses compile errors (fix: falcon.h needs _LOADFONT to work)
Post by: SMcNeill on November 27, 2021, 09:02:16 pm
Ok, this whole situation is getting weirder by the moment...

Opening falcon.h, everything appeared to be in order, but QB64 wouldn't compile with it, listing the 'undefined references' above.  To test things out, I made two little changes:

1) I added this line to the top of the code:  #include "internal/c/parts/video/font/ttf/src/freetypeamalgam.c"

That covered the first four undefined references.

2) I went in and took the "extern" off of the line reading: extern fonts_struct *fonts;

That cleared up the last issue with an undefined reference to fonts.

My program would then compile and run without any issues.  YAY me!



Well, the demo I posted above really doesn't do *anything* except declare the library, so I decided to give it a little larger test run.  I loaded up my Xmas.bas program which I've been working on (which is where I first generated the glitch on), and gave it a run and...

PRESTO!!  8 million error messages for duplicate definitions!!

I had to go in and remove those two changes -- which *WERE* necessary for things to compile properly -- and then save falcon.h back to its original state.

Compile attempt #2, with the now restored falcon.h -- which wouldn't work before without tossing the "undefined reference" messages in my original post -- now worked just peachy fine!



Now, anyone want to explain just what the heck happened to make things suddenly decide to work again??  It *wouldn't* compile without changes...  Then I made the changes...  Then it wouldn't compile *with* the changes...  I had to revert it back again...

WTH is going on between QB64, the c-compiler, and Windows??  I'm utterly lost and confuzzled over this latest escapade into The Glorious Adventures of A Programmer!   
Title: Re: [fixed] Current Development Build tosses compile errors (fix: falcon.h needs _LOADFONT to work)
Post by: luke on November 27, 2021, 09:17:01 pm
Including the falcon header requires using a FONT keyword in your program to pull in the relevant dependencies.
Title: Re: [fixed] Current Development Build tosses compile errors (fix: falcon.h needs _LOADFONT to work)
Post by: RhoSigma on November 28, 2021, 04:59:59 am
Including the falcon header requires using a FONT keyword in your program to pull in the relevant dependencies.

Wasn't it _LOADFONT ?

falcon.h needs the FreeType library. which is included as dependency (parts system) when TTF fonts are used, I'm not sure a simple _FONT/_FONTWIDTH/_FONTHEIGHT will trigger the dependency.

See Note 2 here:
https://www.qb64.org/forum/index.php?topic=2248.msg114890#msg114890
Title: Re: [fixed] Current Development Build tosses compile errors (fix: falcon.h needs _LOADFONT to work)
Post by: luke on November 28, 2021, 07:06:05 am
That's what I get for typing messages on the toilet, I suppose.

Indeed it is _LOADFONT specifically that pulls in the FreeType dependency.
Title: Re: [fixed] Current Development Build tosses compile errors (fix: falcon.h needs _LOADFONT to work)
Post by: FellippeHeitor on November 28, 2021, 10:49:24 am
Solved, it seems.
Title: Re: [fixed] Current Development Build tosses compile errors (fix: falcon.h needs _LOADFONT to work)
Post by: SMcNeill on November 28, 2021, 01:11:12 pm
Solved, it seems.

Not really, as it doesn't explain where my original issue came from.   :P

What had happened was I'd been working on my little Xmas game program, and while taking a break I figured, "Hey, I haven't updated my repo for a while!", while making the little blinking QB64-Xmas IDE...  I popped onto Github, closed all my QB64 windows, and did the "pull from source" to update my version of QB64.  It mentioned "You have 1234567890 changes in your local repo, do you want to stash them first?", so I clicked "SURE" and stashed them to do the update.   

After the update I clicked "Discard stashed changes", and here's where a few odd things started to pop up...

Github, as expected, cleared all my old resource files and such, requiring me to reinstall them back over to my QB64 directory.  No problem, as I always keep those things zipped up in their own folders in a dozen other places, at all times.  Oddly enough, Github didn't "stash and delete" any of my BAS files, even though it cleared everything else out of the directories they were in.  Go figure!  LOL!

falcon.h was removed from the Xmas folder, so I recopied another version of it into the proper place and then did a quick "setup_win.bat" to rebuild the latest QB64.  Once I had the newest QB64, I loaded up my program that had ran perfectly 5 minutes before, compiled it, and I got the original error log I'd posted in the first post.

C:\Users\the_r\AppData\Local\Temp\ccjqRJ4V.o:qbx.cpp:(.text+0x838): undefined reference to `FT_Get_Char_Index'
C:\Users\the_r\AppData\Local\Temp\ccjqRJ4V.o:qbx.cpp:(.text+0x86c): undefined reference to `FT_Get_Kerning'
C:\Users\the_r\AppData\Local\Temp\ccjqRJ4V.o:qbx.cpp:(.text+0x88e): undefined reference to `FT_Load_Glyph'
C:\Users\the_r\AppData\Local\Temp\ccjqRJ4V.o:qbx.cpp:(.text+0x8b0): undefined reference to `FT_Render_Glyph'
C:\Users\the_r\AppData\Local\Temp\ccjqRJ4V.o:qbx.cpp:(.rdata$.refptr.fonts[.refptr.fonts]+0x0): undefined reference to `fonts'

Stripping out falcon.h from the program, and compiling it without _LOADFONT or _FONT explains the issue with the stripped down version, but it doesn't explain why it was failing in the original program where it worked before the repo updated.

The best I can figure is that the g++ compiler is the one that was making the temp windows files (I don't think we have anywhere in QB64 that uses "USER\Temp\" as a path, do we??), and something was going wrong with those files.   

Playing around for a while didn't get me anywhere, so I cleaned Windows of all its Temp junk, deleting all the existing temp files it had stored in those folders, and then PRESTO-- things worked once I added the .c file and removed "extern" from the fonts declaration in falcon.h.   After the test code compiled itself, I then loaded back my original Xmas game code, and gave it a go.... only to have it toss a zillion duplicate definition errors.  /SIGH

Why updating the repo caused it to fail the first time is completely beyond me, unless it just had something to do with the old QB64 version having created a USER/Temp/ccjqRJ4V.o file previously, that didn't quite match up to what the latest version expected...  Since the file existed, it wasn't recreating it, and since it was an outdated version, something went wacky...   is my guess??

Honestly, I don't know how updating the repo broke QB64 for me, but it did.  :P

Somewhere between the github "Stash" and "delete" and update and install, something went wrong somewhere.  Heck, I'd never even thought about g++ using the windows Temp folders before with QB64, but apparently they do somewhere along the process to compilation, as indicated by the error messages above.  Whatever the glitch was this time around, it appears to be on the g++ compiler side of things, rather than on the QB64 side of the fence.

Whatever it was, I'm just glad that *something* finally cleared it up and made it go away for me!  LOL!  ;D