Jump to content
  • Advertisement
Sign in to follow this  
MaulingMonkey

Short story: The nightmare of getting FreeType2 working

This topic is 5380 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I give unto thee the brave adventures of MaulingMonkey in his attempts to create his own C++ GUI system. There once was a lad, by the name of MaulingMonkey. This lad was a nerd of some sort - quite ugly and smelly to boot. He said unto himself: "Why, I thinkst I wishest to create a C++ GUI for the game I plan to make!!! Let me start by getting some text working... but not only that, but text where I can get the sizes of letters and soforth so I might have automatic wrapping of text!" And so the young lad set forth to the great library of Google, and searched through it's massive archives, after which he came to a decision. "FreeType looks to be the tool I need - I'll just download it and try a small tutorial to make sure It's installed nicely!!" So MaulingMonkey downloaded and installed his new tool - he allready had the GNU C compiler installed, via his cygwin installation. And so the young lad compiled his example, and tested it out. Lo and behold it did not work! He got a run time error - something about not having enough room to grow the cygwin heap, and windows error "487". He tried many a DLL, googled for answers - he got some stuff about it being due to the DLL expecting to be run inside of cygwin - but running it inside the cygwin environment just provided DIFFERENT run time errors related to heap growth! And so the lad decided he would try to compile his fine DLL, since he had compiled many a DLL before, and hopefully by compiling it himself, he'd avoid the cygwin environment dependancies that plauged him! The lad knew what to do. He downloaded the source code from the website, unzipped it, and quickly brought up a command window. A few mishaps later, and he figure out how he was supposed to build his dll:
C:\freetype-2.1.9\>sh configure
...
...
...
C:\freetype-2.1.9\>make
...
...
...
C:\freetype-2.1.9\>make install
...
...
...
Which worked fine. He tested out the new DLL. Did it succeed? The poor lad was beginning to get quite fustrated after it reported the exact same heap error messages. "Why must you torment me so, oh great library!!! I must have downloaded thee, installed thee, and nurtured thee a thousand times by now!!!" After searching the great google library once more, the lad found some related email archives relating to cygwin and the GTK. Similar errors, fixed by setting CC to "gcc -mno-cygwin -mnatural-struct" (or something like that). So the lad decided to try again through the scripts:
C:\freetype-2.1.9\>set CC=gcc -mno-cygwin
C:\freetype-2.1.9\>set LD=ld -mno-cygwin
"So far, so good" said the lad.
C:\freetype-2.1.9\>sh configure
...
...
...
The lad noted the use of "gcc -mno-cygwin" in some of the tests the config script made. "Good good, this might just work after all!" said the lad.
C:\freetype-2.1.9\>make
...
...
...
The lad noted that -mno-cygwin was indeed being appended to all the invocations of gcc. He was glad that he was nearly done building a working DLL. C:\freetype-2.1.9\>make install ... ... ... The lad ran the command. And then all hell broke loose. Errors started streaming in:
lib /OUT:/cygdrive/c/freetype-2.1.9/objs/.libs/libfreetype.lib  /cygdrive/c/free
type-2.1.9/objs/ftsystem.o /cygdrive/c/freetype-2.1.9/objs/ftdebug.o /cygdrive/c
/freetype-2.1.9/objs/ftinit.o /cygdrive/c/freetype-2.1.9/objs/ftbase.o /cygdrive
/c/freetype-2.1.9/objs/ftbbox.o /cygdrive/c/freetype-2.1.9/objs/ftbdf.o /cygdriv
e/c/freetype-2.1.9/objs/ftglyph.o /cygdrive/c/freetype-2.1.9/objs/ftmm.o /cygdri
ve/c/freetype-2.1.9/objs/ftpfr.o /cygdrive/c/freetype-2.1.9/objs/ftstroke.o /cyg
drive/c/freetype-2.1.9/objs/fttype1.o /cygdrive/c/freetype-2.1.9/objs/ftwinfnt.o
 /cygdrive/c/freetype-2.1.9/objs/ftxf86.o /cygdrive/c/freetype-2.1.9/objs/autohi
nt.o /cygdrive/c/freetype-2.1.9/objs/bdf.o /cygdrive/c/freetype-2.1.9/objs/ftcac
he.o /cygdrive/c/freetype-2.1.9/objs/cff.o /cygdrive/c/freetype-2.1.9/objs/type1
cid.o /cygdrive/c/freetype-2.1.9/objs/ftgzip.o /cygdrive/c/freetype-2.1.9/objs/f
tlzw.o /cygdrive/c/freetype-2.1.9/objs/pcf.o /cygdrive/c/freetype-2.1.9/objs/pfr
.o /cygdrive/c/freetype-2.1.9/objs/psaux.o /cygdrive/c/freetype-2.1.9/objs/pshin
ter.o /cygdrive/c/freetype-2.1.9/objs/psnames.o /cygdrive/c/freetype-2.1.9/objs/
raster.o /cygdrive/c/freetype-2.1.9/objs/sfnt.o /cygdrive/c/freetype-2.1.9/objs/
smooth.o /cygdrive/c/freetype-2.1.9/objs/truetype.o /cygdrive/c/freetype-2.1.9/o
bjs/type1.o /cygdrive/c/freetype-2.1.9/objs/type42.o /cygdrive/c/freetype-2.1.9/
objs/winfnt.o
./builds/unix/libtool: line 1: lib: command not found
make: *** [/cygdrive/c/freetype-2.1.9/objs/libfreetype.la] Error 127
Poor lad!!! He copied this text and pasted it into notepad. Removing the newlines, he changed "lib" to "sh builds/unix/libtool --mode=finish" and pasted the command back into his command window, whereupon his command line simply gave him more greif. The poor lad was about to hang himself - no matter how much he tried to coax the library into installing, it just would not work! But the lad did not hang himself. The lad decided it was time to put this library into it's place. "Library!" he shouted. "Library! Hear me! I will put an end to thy wicked ways! Repent now or be manually compiled!" And the Library sat silent. "Library! This is your final warning! Surrender now, or feel the taste of my blade, GCC!!!" And the Library sat silent. The lad kept his trusty "GNU ld" up for defense, circling the library. It seemed to have all it's object files so far in one place... C:\freetype-2.1.9\objs\ . A quick feinting cd into the .libs subdirectory of that, followed by a quick stab to "cd ..", the lad thrust his mighty command: "gcc -shared *.o -o libfreetype.dll -shared -fPIC -mno-cygwin" (yes, the lad truely typed this first try) and lo and behold:
C:\freetype-2.1.9\objs>gcc -shared *.o -o libfreetype.dll -shared -fPIC -mno-cyg
win

C:\freetype-2.1.9\objs>
His code had compiled without error or even warning!!! Triumphant, he copied this new DLL into C:\cygwin\bin, edited his makefile for the new paths (which had previously been tangling with "C:\Program Files\GnuWin32" and it's children), and compiled. And lo and behold, instead of errors having nothing to do with this poor lad's code, there was output:
C:\eclipse\workspace\industry\>test
Everything seems to be running AOK
libindustry.gui.dll version: 0.01
showing that his trusty DLL's constructor,
void __attribute__((constructor)) industry_gui_dll_init( void )
{
	libindustry_gui_dll_version = "0.01";
	FT_Error error = FT_Init_FreeType( &library );
	if (error); //we should do something but we're lazy bastards
}
had indeed been called (as libindustry_gui_dll_version had no assignment besides there, as confirmation). The young lad, victorious, returned to his native homeland, GameDev.net, where he proclaimed his victory to the masses.

Share this post


Link to post
Share on other sites
Advertisement
Hehe, thanks. Originally I was just trying to get FTGL working, but then I realized FTGL sucked (C-style prefixes instead of namespaces, for one thing). Since most of the other libraries out there depended on FreeType (including FTGL), or don't have a method of getting per-character widths, or look ugly (glut builtin fonts), I really didn't have much choice. It took me a few hours (mainly googling), but hey, it's installed now, I think it works (I havn't actually tried viewing the results yet), and the nightmare is finally over.

Plus, the stores are open now (I pulled an all nighter for the hell of it) and I can now overdose on caffinee and breakfast. GLEE!!!

Share this post


Link to post
Share on other sites
sudo apt-get install freetype2-devel

Yup, because Windows is totally the right kind of environment to get real work done in. :P

[Edited by - Ravuya on October 22, 2004 1:23:09 PM]

Share this post


Link to post
Share on other sites
I wish i had your luck fixing the bug in the Radeon drivers for Fedora Core 3. (wtf, patch the kernel.. huh?)

Anyway, look at the link in my sig, you might find it interesting.

Share this post


Link to post
Share on other sites
Aside: The king has decreed that cygwin sucks. By royal command, mingw/msys is the POSIX-like environment for Windows henceforth. Unless you need to use an X server.

Share this post


Link to post
Share on other sites
Let me get this straight :

You're compiling in cygwin and you're passing the flag -mno-cygwin to the compiler ?

Share this post


Link to post
Share on other sites
-mno-cygwin makes it link against mingw libraries installed as part of Cygwin, if any. A good choice if you don't want to GPL your program, since normally Cygwin-built programs are linked against cygwin1.dll which is GPL'd.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!