[SOLVED] Undefined Reference with xFont FB-1.07.1

General FreeBASIC programming questions.
Post Reply
BasicScience
Posts: 489
Joined: Apr 18, 2008 4:09
Location: Los Angeles, CA
Contact:

[SOLVED] Undefined Reference with xFont FB-1.07.1

Post by BasicScience »

I have used xFont by LeonHeart for years, up through FB-1.03.0 for Win.

Today, I finally upgraded to FB-1.07.1 and now I get a compiler error

undefined reference to 'XFONT::INTERFACE::FORECOLOR__SET__(unsigned long)@8'

whenever I try to set the ForeColor as shown in the code below. The same problem occurs with BackColor. Fortunately, xFont is otherwise working with the default colors in FB-1.071

Code: Select all

#Include Once "xfont.bi"
Dim Shared As xfont.interface font
ScreenRes 640,480,32

Font.Loadfont ("Comic20.xf",1)
Font.FOntIndex = 1

font.forecolor = rgb(255,0,255)

font.drawstring (,"Hello World",50,50)
sleep


LeonHeart's xFont project at XaviorSoft is now shut down. I do have the source code (the link to the source code is dead). Here are some relevant sections

Code: Select all

'04 August 2008
'v 8.8.28  : Fix autolock problem [last edit 30 august 2008)
'v 10.6.17 : Support viewport now. Suport isLoaded property [last edit 17 June 2010)
'v 11.9.13 : Fix windows.bi include conflict.

#Include Once "file.bi"
#Include Once "crt/string.bi"
#Include Once "std_font_0.bas"

Namespace xfont
 .
 .
 .
 
       Type Interface'--------------------------------------------------------------------------------------------------
        'Public
        Declare Constructor ()
        Declare Destructor ()
        .
        .
        .
        Declare Property ForeColor() As uInteger 
        Declare Property ForeColor(ByVal Expression As uInteger)
        .
        .
        .
           
       
    Property Interface.ForeColor(ByVal Expression As uInteger)
        With xForeColor 'Selalu dalam 32-bit
            .Red         = (Expression Shr 16) And &HFF
            .Green       = (Expression Shr 8) And &HFF
            .Blue        =  Expression And &HFF
            .Alpha       = (Expression Shr 24) And &HFF
            .Palette     = Expression
            .AlphaFactor = AlphaFactor255(.Alpha)
            .iAlphaFactor= iAlphaFactor255(.Alpha)
            .AfRed       = .AlphaFactor * .Red
            .AfGreen     = .AlphaFactor * .Green
            .AfBlue      = .AlphaFactor * .Blue
        End With
        ColorChange = _True_
        'Print Expression 
    End property
'____________________________________________________________________________________________________________________________________________________    
    
    Property Interface.ForeColor() As uInteger
        Return xForeColor.Palette    
    End property
'___________________       
                
End namespace

Thanks.
Last edited by BasicScience on Dec 27, 2019 17:59, edited 1 time in total.
Xusinboy Bekchanov
Posts: 789
Joined: Jul 26, 2018 18:28

Re: Undefined Reference with xFont FB-1.07.1

Post by Xusinboy Bekchanov »

Maybe you are using a library file from an old compiler. The new compiler does not work with old library files.
BasicScience
Posts: 489
Joined: Apr 18, 2008 4:09
Location: Los Angeles, CA
Contact:

Re: Undefined Reference with xFont FB-1.07.1

Post by BasicScience »

Yes, the library was created in 2010. That said, I thought "old" libraries were backward compatible with Win-32 versions of the compiler.
badidea
Posts: 2591
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Undefined Reference with xFont FB-1.07.1

Post by badidea »

I tried the linux version, similar error here.
If you have the source, then try to recompile the library, or better publish the source e.g. on github.
I think that the creator has no problem with that, see: https://freebasic.net/forum/viewtopic.p ... 45#p171049
BasicScience
Posts: 489
Joined: Apr 18, 2008 4:09
Location: Los Angeles, CA
Contact:

Re: [SOLVED] Undefined Reference with xFont FB-1.07.1

Post by BasicScience »

Indeed, recompiling the library with the 1.07.1 version of FBC solved the problem.

Others may want to use xfont, but the source code is needed to recompile the library. LeonHeart made the source public, but the URL is no longer active. I would be happy to share the code. Perhaps someone can post it here or on GitHub (I'm not a user).

BasicScience
paul doe
Moderator
Posts: 1732
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: [SOLVED] Undefined Reference with xFont FB-1.07.1

Post by paul doe »

BasicScience wrote:...
Perhaps someone can post it here or on GitHub (I'm not a user).
...
I wouldn't mind, but I'll need a link to download the source. After that, I'll simply upload the source to my account and post a link to it.
badidea
Posts: 2591
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: [SOLVED] Undefined Reference with xFont FB-1.07.1

Post by badidea »

I have received the code from BasicScience. Thanks for that.
I'll put it on GitHub later today, maybe tomorrow.
Probably fix the (u)integer stuff first.
BasicScience
Posts: 489
Joined: Apr 18, 2008 4:09
Location: Los Angeles, CA
Contact:

Re: [SOLVED] Undefined Reference with xFont FB-1.07.1

Post by BasicScience »

@ Badidea, thanks. You might also consider fixing an annoying bug in xFont. The LoadFont function always closes file #1 instead of using FreeFile to identify an open file #. This glitch can be difficult to track down when your project is experiencing unexpected closures of File #1.
badidea
Posts: 2591
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: [SOLVED] Undefined Reference with xFont FB-1.07.1

Post by badidea »

Sounds almost like work. Will be tomorrow. Too much beer now.
badidea
Posts: 2591
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: [SOLVED] Undefined Reference with xFont FB-1.07.1

Post by badidea »

Going through the code now. Found the close #1
There is some confusing stuff like "Dim fontptr As uInteger".
The name suggests a pointer, but it is used as an index.

Google translate can be useful:
"Mengisi persegi dengan warna latar belakang dan alpha latar belakang" -> "Fill in the square with background color and background alpha"

All compile warnings gone here and 64-bit seems to work as well. I'll do some more checks and do the github upload tomorrow.
badidea
Posts: 2591
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: [SOLVED] Undefined Reference with xFont FB-1.07.1

Post by badidea »

Uploaded: https://github.com/verybadidea/XFont-Lib

Tested with 32 & 64 bit fbc 1.07.1 linux version
Compile library first with 'fbc -lib xfont.bas'
Also removed the double page in the manual.
Added examples from the manual to /test directory.
It had a fancy version numbering, version 12.0.0 did sound nice.
BasicScience
Posts: 489
Joined: Apr 18, 2008 4:09
Location: Los Angeles, CA
Contact:

Re: [SOLVED] Undefined Reference with xFont FB-1.07.1

Post by BasicScience »

@badidea,

Many thanks. Verified everything works on win32 and win64.
Post Reply