I am making an Asteroids clone using SDL and OpegGL in C++. Like most games, I needed to render text and after some hassle with SDL_ttf, I decided to try FTGL which uses Freetype2. I am using Visual Studio C++ 2008 Express Edition.

There is no precompiled library included in the download. You have to compile it yourself (both freetype2 and FTGL). I have little experience with static libraries, but I managed to compile a .lib file after a couple of minutes. However, after I copied the library to my game's directory and set my project's properties to link it, it gives the following error message:

fatal error C1083: Cannot open include file: 'ft2build.h': No such file or directory

Here are my settings:

Properties -> Configuration Properties -> Linker -> Input -> Additional Dependencies:

SDL.lib SDLmain.lib SDL_image.lib SDL_mixer.lib SDL_ttf.lib freetype242_D.lib ftgl_static_D.lib opengl32.lib glu32.lib // in that order

I experienced the same situation when I tried compiling the FTGL library, but after entering the correct paths I solved it, so why is the message showing up again?

Thank you in advance for any help.

Recommended Answers

All 4 Replies

You have to specify the correct include path in your own stuff too. This error is not in the FTGL library which compiled successfully. Once compiled, it no longer needs to find the includes for the .lib, but it needs to find the includes that you use in your code and it doesn't find it because the include path is not complete or incorrect.

So my application still needs to include the same stuff as I included in my compilation of FTGL?

In my code I included: <FTGL/ftgl.h> as it is the only file needed. This file includes ft2build.h though, which is probably causing the error.

After adding all the same paths to Configuration Properties -> C/C++ -> General -> Additional Include Directories, that I did when I built the FTGL library it worked! :D

However, since I added exactly the same code for my application as I did for the library, what is the purpose of the static library? I thought it was to reuse to code and NOT have to include it all in the project...I'm obviously doing something wrong, but it works now so I'll keep on coding!

Thanks, mike_2000_17

The headers are not the code (well not the bulk of it at least). The headers declare what exists in the library such that you can use them in your code. So you need to include the headers in your code, successfully, to be able to use the code that is in the library. The purpose of the library is that all the code (cpp files) that is compiled in the library (which is much more than what is in its headers, which are mostly prototypes and trivial functions like get/set methods) doesn't need to be recompiled every time you compile your application, because it never changes.

Hey mike_2000_17,

Was a little busy, but thank you for the clarification. I understand now :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.