[SOLVED] Undefined references to freetype2's everything

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
zhiayang
Member
Member
Posts: 368
Joined: Tue Dec 27, 2011 7:57 am
Libera.chat IRC: zhiayang

[SOLVED] Undefined references to freetype2's everything

Post by zhiayang »

So after building my shiny new toolchain, I decided to start porting some libraries over. I managed to get freetype to build after doing these things:
edit builds/unix/config.sub in a way similar to OS Specific Toolchain

Code: Select all

# note that x86_64-orionx-gcc etc. is the name of my toolchain
export DESTDIR=$SYSROOT
./configure --prefix=/usr --host=x86_64-orionx --without-harfbuzz --without-png --without-bzip2 --without-zlib
make
make install
I get a shiny libfreetype.a in my $SYROOT/usr/lib.
Except when I try to link with it, doing the simplest example from http://www.freetype.org/freetype2/docs/ ... step1.html, ie. just setup an FT_Library object and call FT_Init_FreeType(&library)

Code: Select all

x86_64-orionx-g++ -Wall -O2 -o test test.cpp -lfreetype

test.cpp:(.text.startup+0xa): undefined reference to `FT_Init_FreeType'
collect2: error: ld returned 1 exit status
I've tried all manner of things:
1. recompiling the thing 23910823 times
2. wrapping the #includes in extern "C"
3. compiling test as a C program

nothing. If anybody is willing to spend some time, the static library is here:
https://drive.google.com/file/d/0BxDNp6 ... sp=sharing

Thank you.


EDIT: I should probably mention that I'm using FreeType 2.5.3 from the website download.
Last edited by zhiayang on Tue Aug 12, 2014 4:13 am, edited 1 time in total.
jnc100
Member
Member
Posts: 775
Joined: Mon Apr 09, 2007 12:10 pm
Location: London, UK
Contact:

Re: Undefined references to freetype2's everything

Post by jnc100 »

I've tried downloading it and also get the same issue you do with a stock x86_64-elf cross compiler. Out of interest, running nm on it suggests it is still trying to link to png_ and hb_ functions (?harfbuzz) despite your options to freetype's configure script.

One thing you may wish to try is:

Code: Select all

mkdir libfreetype
cp libfreetype.a libfreetype
cd libfreetype
x86_64-orionx-ar x libfreetype.a
cd ..
x86_64-orionx-g++ -o test test.cpp -Wl,--start-group libfreetype/*.o -Wl,--end-group
and you should see exactly what external dependencies are missing.

Regards,
John.
User avatar
zhiayang
Member
Member
Posts: 368
Joined: Tue Dec 27, 2011 7:57 am
Libera.chat IRC: zhiayang

Re: Undefined references to freetype2's everything

Post by zhiayang »

Hmm, thanks for your suggestion. I can't test it right now, but for the few minutes I was able to, I was getting undefined references to SIG_MASK or something like that. I'll admit my libc isn't complete at all, but I'll have to try again when I can later.
User avatar
zhiayang
Member
Member
Posts: 368
Joined: Tue Dec 27, 2011 7:57 am
Libera.chat IRC: zhiayang

Re: Undefined references to freetype2's everything

Post by zhiayang »

@jnc100:

Thanks for your help. Turns out my libc isn't as feature-complete as I thought -- I was missing 'setjmp' and 'longjmp', which I have since implemented.
Still don't know why LD would report FT_Init_FreeType as undefined though...

Anyway thanks for your troubles.
Post Reply