[dev-c++] How to include a library?(solved)

Started by
6 comments, last by SiCrane 15 years, 7 months ago
I wanted to use this font rendering code but it depended on the freetype library. I downloaded the devpack and installed it. I added freetype.lib and freetype-bcc.lib to my linker. When I tried to compile the my program I got the following errors: I've got similar problems before when I tried to install other libraries. So could someone clearly explain to me how to include a library to dev-c++ without the devpack and to link it in my projects. Thank you [Edited by - d1rk on September 5, 2008 3:03:28 PM]
Advertisement
Quote:Original post by d1rk
I wanted to use this font rendering code but it depended on the freetype library. I downloaded the devpack and installed it. I added freetype.lib and freetype-bcc.lib to my linker. When I tried to compile the my program I got the following errors:



I've got similar problems before when I tried to install other libraries. So could someone clearly explain to me how to include a library to dev-c++ without the devpack and to link it in my projects.

Thank you


Can you post some code please?
It looks like the preprocessor sees you trying to do:
#include freetype.h

or something similar. However, as the error message tells you, the #include directive expects an argument in double quotes or angle brackets; in your case double-quotes are likely correct:
#include "freetype.h"


Before that, it also appears as if you are trying to include a file that the preprocessor cannot find, perhaps because it does not exist or your search paths are wrong.
I didn't write this part of the code myself. I just included it like I was told to on the website of GLFT_Font.

GLFT_font code:
#ifndef GLFT_FONT_HPP#define GLFT_FONT_HPP#include <GL/gl.h>#include <ft2build.h>#include FT_FREETYPE_H#include <string>#include <vector>#include <stdexcept>#include <cstdarg>#include <sstream>


project options->linker
-lglfw -lopengl32 -lglu32C:/Dev-Cpp/lib/freetype.libC:/Dev-Cpp/lib/freetype-bcc.lib


I think my search paths are wrong but i've never learned how to make them right. So could someone tell how to make them right?

PS: I can host my whole project so far if you want to see more source code but I don't think that it'll help. I think the problem is in the linking of freetype.
#include FT_FREETYPE_H

That's not legal code, so I'm immediately distrustful of the source of the code -- assuming you did actually copy it verbatim.

Look in the Dev-C++ manual for include paths. I don't use the program (and because of its age, I don't recommend you do either, but transitioning to Visual C++ Express might be more re-education than you are willing to commit to immediately; nonetheless consider it for your next project).
Quote:Original post by jpetrie
#include FT_FREETYPE_H

That's not legal code, so I'm immediately distrustful of the source of the code -- assuming you did actually copy it verbatim.

Look in the Dev-C++ manual for include paths. I don't use the program (and because of its age, I don't recommend you do either, but transitioning to Visual C++ Express might be more re-education than you are willing to commit to immediately; nonetheless consider it for your next project).


If you say the code isn't ok then I think I have to switch to another font rendering library. I'll try FTGL instead.

(offtopic) Why do you recommend VC++? If it's really better I don't mind switching.
It looks like FT_FREETYPE_H is the header guard off of the header file. If you know the header file that you are trying to include then you just use the file name in double quotes. As for switching to VC++, I much prefer Code::Blocks, the interface is nicer in my opinion, I have never used Dev-C++ so I don't know how much different it is.
Quote:Original post by jpetrie
#include FT_FREETYPE_H

That's not legal code, so I'm immediately distrustful of the source of the code -- assuming you did actually copy it verbatim.


Unfortunately, it is legal code. When using the FreeType library, in order to include the main header you need to do this:
#include <ft2build.h>#include FT_FREETYPE_H

Inside ft2build.h it #defines FT_FREETYPE_H to whatever the main FreeType header should be. It's crazy-stupid, but legal code.

This topic is closed to new replies.

Advertisement