Sign in to follow this  
d1rk

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

Recommended Posts

d1rk    136
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]

Share this post


Link to post
Share on other sites
Marineio    134
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?

Share this post


Link to post
Share on other sites
jpetrie    13104
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.

Share this post


Link to post
Share on other sites
d1rk    136
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 -lglu32
C:/Dev-Cpp/lib/freetype.lib
C:/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.

Share this post


Link to post
Share on other sites
jpetrie    13104

#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).

Share this post


Link to post
Share on other sites
d1rk    136
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.

Share this post


Link to post
Share on other sites
this_is_phil    100
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.

Share this post


Link to post
Share on other sites
SiCrane    11839
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this