Announcement: Be excellent to each other.


Caravel Forum : Other Boards : Anything : Glut and FTGL (Now it is a more general problem)
New Topic New Poll Post Reply
Poster Message
Kevin_P86
Level: Smitemaster
Avatar
Rank Points: 535
Registered: 06-28-2005
IP: Logged
icon Glut and FTGL (0)  
I realize this is probably not the most appropriate place to ask something like this, but I've spent far too much time searching for the answer, and I figure someone here might be able to help.

---------

So I have recently been introduced to programming with OpenGL and glut in on of my CS classes. It's all well and good, except for the fact that rendering fonts is more or less impossible with it. I did some searching and found FreeType, and then later FTGL, and downloaded them both.

After many problems, I finally got MSVC++ to build ftgl_static_MT.lib (a static, multi-threaded library for FTGL). I am now attempting to build an application that makes use of this. I placed a copy of the .lib file in c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Lib, and in the project I am developing I went to Project -> Properties -> Linker -> Input, and added "ftgl_static_MT.lib" to the "Additional Dependencies" field.

I run the application, and it can not find any of the objects (or other code) declared in FTGL (specfically, FTGLPixmapFont).

So is there just something else I need to do to get it to find / include the .lib file? Or is it more serious than that?

Any suggestions will be greatly appreciated.

____________________________
+++++[>+++++<-]>[>+++>++++>+++++<<<-]>.>+.>-------.<++++.+++++.

[Last edited by Kevin_P86 at 03-06-2007 04:38 AM]
02-21-2007 at 03:53 AM
View Profile Send Private Message to User Send Email to User Show all user's posts This architect's holds Quote Reply
TripleM
Level: Smitemaster
Rank Points: 1373
Registered: 02-05-2003
IP: Logged
icon Re: Glut and FTGL (0)  
I would say the DROD forum is the best place to ask about anything at all :P
Not that I have a solution for you. I've had troubles getting everything to link fine in the past too though. I presume you're including the correct header files, but what precisely do you mean by 'cannot find'? Is it a linker error or something else?
02-21-2007 at 05:49 AM
View Profile Send Private Message to User Show all user's posts Quote Reply
Kevin_P86
Level: Smitemaster
Avatar
Rank Points: 535
Registered: 06-28-2005
IP: Logged
icon Re: Glut and FTGL (0)  
I'm not exactly sure. The only errors it gives me are the ones related to it not being able to find the FTGL code (which is supposedly in the .lib).

However, I did some experimenting: if I comment out the code that uses FTGL, it compiles and runs fine (which is good, I guess). Then, if I replace FTGL_static_MT.lib with something that obviously doesn't exist (something like alsdkhg.lib), it complains about the .lib file not existing (also good, I guess). However, if I un-comment the FTGL code, leaving the non-existant .lib, it complains about the same errors as before (regarding the FTGL classes not existing). Therefore, it seems it's not even getting to the .lib before it decides the classes don't exist. However, it also means it's finding the .lib (which is one good thing, I guess).

TripleM wrote:
I presume you're including the correct header files
That is likely the problem. However, I do not know what header(s) I need to include. The output of building FTGL was only the .lib file. Right now, the only header I have included is glut.h.

I did find a FTGL.h in the FTGL directory (which I would imagine is the intuitive file to include), but including that doesn't seem to change anything. I also tried including the FTGLPixmapFont.h header file. This seems to be closer to working, but then it complains about exit(int) being declared with __declspec(noreturn) and defined without (in stdlib.h, which must've been included by FreeType or FTGL). Does anyone know what this means / how I might go about fixing it?

____________________________
+++++[>+++++<-]>[>+++>++++>+++++<<<-]>.>+.>-------.<++++.+++++.

[Last edited by Kevin_P86 at 02-21-2007 07:15 AM]
02-21-2007 at 06:14 AM
View Profile Send Private Message to User Send Email to User Show all user's posts This architect's holds Quote Reply
Briareos
Level: Smitemaster
Avatar
Rank Points: 3516
Registered: 08-07-2005
IP: Logged
icon Re: Glut and FTGL (+2)  
Kevin_P86 wrote:
I placed a copy of the .lib file in c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Lib, and in the project I am developing I went to Project -> Properties -> Linker -> Input, and added "ftgl_static_MT.lib" to the "Additional Dependencies" field.
Ugh... don't do that - don't add files to the Visual Studio installation directory, that's a rather big no-no.

Rather, add the directory that your .lib-file is in to your project's library path, and add the path with the FTGL header files (which are already included with the source) to your project's include path.

Also, if you really want to get useful help - why don't you just post the error messages exactly like you get them in Visual Studio's output window?

Just copy and paste them into a [code]-tag in a post here.

____________________________
"I'm not anti-anything, I'm anti-everything, it fits better." - Sole
R.I.P. Robert Feldhoff (1962-2009) :(

[Last edited by Briareos at 02-21-2007 08:34 AM]
02-21-2007 at 08:33 AM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts Quote Reply
TripleM
Level: Smitemaster
Rank Points: 1373
Registered: 02-05-2003
IP: Logged
icon Re: Glut and FTGL (+1)  
Yeah, I agree about the copying and pasting of error messages, thats the best thing to do.
But not including the right headers would be the main problem. This doesn't look very well documented at all, but I suggest you try out some of the sample code in the /demo folder for FTGL (assuming you downloaded it from the same source I did; [url http://homepages.paradise.net.nz/henryj/code/index.html.

Hopefully you should be able to get that to work, and it should give you an idea of what headers you'll need.

After that, if you've still got the exit problem, try posting that error message and we'll see what happens.
02-21-2007 at 09:21 AM
View Profile Send Private Message to User Show all user's posts Quote Reply
Kevin_P86
Level: Smitemaster
Avatar
Rank Points: 535
Registered: 06-28-2005
IP: Logged
icon Re: Glut and FTGL (0)  
Ok, the exit error is as follows:

c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\stdlib.h(256): error C2381: 'exit' : redefinition; __declspec(noreturn) differs
and the line its complaining about is:

_CRTIMP __declspec(noreturn) void   __cdecl exit(int);
And here is the MSDN documentation on C2381:

'function' : redefinition; __declspec(noreturn) differs

A function was declared and then defined but the definition used the noreturn __declspec modifier. The use of noreturn constitutes a redefinition of the function; the declaration and definition need to agree on the use of noreturn.

Briareos wrote:
Ugh... don't do that - don't add files to the Visual Studio installation directory, that's a rather big no-no.

Rather, add the directory that your .lib-file is in to your project's library path, and add the path with the FTGL header files (which are already included with the source) to your project's include path.
I have added the FTGL headers to the include path (and therefore was also required to add the FT headers, because FTGL includes some of the FT headers). But I don't know where to find the library path. All I can find is the Additional Dependencies I mentioned before, and it doesn't look like that wants directories.

TripleM wrote:
doesn't look very well documented at all, but I suggest you try out some of the sample code in the /demo folder for FTGL
I have looked at some of those, but it looks like all they did was include the FTGL headers they used. When I tried that, it couldn't find the corresponding .cpp files (which are in a different directory).

Just for reference, the error messages it gave me before:
c:\Progs\GlutTest\main.cpp(16): error C2065: 'FTGLPixmapFont' : undeclared identifier
c:\Progs\GlutTest\main.cpp(16): error C2146: syntax error : missing ';' before identifier 'font'
c:\Progs\GlutTest\main.cpp(19): error C2228: left of '.Render' must have class/struct/union type
        type is ''unknown-type''
c:\Progs\GlutTest\main.cpp(16): error C3861: 'font': identifier not found, even with argument-dependent lookup
c:\Progs\GlutTest\main.cpp(19): error C3861: 'font': identifier not found, even with argument-dependent lookup
And the corresponding lines its complaining about (lines 16-19):
   FTGLPixmapFont font("Font:Arial");
   glRasterPos2f(1.0f, 1.0f);
   glColor3f(1.0f, 1.0f, 1.0f);
   font.Render("abcdefg");


____________________________
+++++[>+++++<-]>[>+++>++++>+++++<<<-]>.>+.>-------.<++++.+++++.
02-21-2007 at 05:55 PM
View Profile Send Private Message to User Send Email to User Show all user's posts This architect's holds Quote Reply
Briareos
Level: Smitemaster
Avatar
Rank Points: 3516
Registered: 08-07-2005
IP: Logged
icon Re: Glut and FTGL (+2)  
Kevin_P86 wrote:
Ok, the exit error is as follows:

c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\stdlib.h(256): error C2381: 'exit' : redefinition; __declspec(noreturn) differs
and the line its complaining about is:

_CRTIMP __declspec(noreturn) void   __cdecl exit(int);
Ouch. That means that the include files you're including define the "exit" function more than once - you might want to grep your included files for other instances of "exit" and work around that. I'm afraid I can't give you specific help without having your drive in hand... :(
Briareos wrote:
Ugh... don't do that - don't add files to the Visual Studio installation directory, that's a rather big no-no.

Rather, add the directory that your .lib-file is in to your project's library path, and add the path with the FTGL header files (which are already included with the source) to your project's include path.
I have added the FTGL headers to the include path (and therefore was also required to add the FT headers, because FTGL includes some of the FT headers). But I don't know where to find the library path. All I can find is the Additional Dependencies I mentioned before, and it doesn't look like that wants directories.
In Visual Studio 2005, that's "Configuration Properties > Linker > General > Additional Library Directories", which is a single line of text with a button that opens some directory list widget. I don't have VS.Net here, so it might be slightly different on your end...

np: Death Cab For Cutie - 20th Century Towers (Stability EP)

____________________________
"I'm not anti-anything, I'm anti-everything, it fits better." - Sole
R.I.P. Robert Feldhoff (1962-2009) :(
02-21-2007 at 06:11 PM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts Quote Reply
Kevin_P86
Level: Smitemaster
Avatar
Rank Points: 535
Registered: 06-28-2005
IP: Logged
icon Re: Glut and FTGL (0)  
Briareos wrote:
Ouch. That means that the include files you're including define the "exit" function more than once - you might want to grep your included files for other instances of "exit" and work around that. I'm afraid I can't give you specific help without having your drive in hand... :(
I searched the entire FT and FTGL solutions (all header and source files) for "exit(", and all 12 that it found were just calling the function, not declaring / defining it.

Edit: And when I just search for "exit" (with no parenthesis), the only extra ones it finds are a whole bunch of "Exit:" labels, and the corresponding "goto Exit;" lines.

Briareos wrote:
In Visual Studio 2005, that's "Configuration Properties > Linker > General > Additional Library Directories", which is a single line of text with a button that opens some directory list widget. I don't have VS.Net here, so it might be slightly different on your end...
Ok, it's in the same place in VS.NET. Thanks :D.

____________________________
+++++[>+++++<-]>[>+++>++++>+++++<<<-]>.>+.>-------.<++++.+++++.

[Last edited by Kevin_P86 at 02-21-2007 06:33 PM]
02-21-2007 at 06:20 PM
View Profile Send Private Message to User Send Email to User Show all user's posts This architect's holds Quote Reply
Kevin_P86
Level: Smitemaster
Avatar
Rank Points: 535
Registered: 06-28-2005
IP: Logged
icon Re: Glut and FTGL (0)  
So I did some more searching. I searched through all the standard include files being included (i.e. <iostream>, <string>, <math.h>, and a few others) as well as all files they included, and no occurences of "exit" anywhere.

I then searched through all the source files of FreeType and FTGL, and found the following lines in \src\gzip\zutil.c in the FreeType directory:
#ifndef STDC
extern void exit OF((int));
#endif
Does anyone know enough to tell me if that could possibly be the problem? Although if it is the problem, it certainly doesn't help. And if it is not the problem, then I have even less of an idea as to what the problem is than I did before (if that is possible).

____________________________
+++++[>+++++<-]>[>+++>++++>+++++<<<-]>.>+.>-------.<++++.+++++.

[Last edited by Kevin_P86 at 03-02-2007 10:44 PM]
03-02-2007 at 10:44 PM
View Profile Send Private Message to User Send Email to User Show all user's posts This architect's holds Quote Reply
Briareos
Level: Smitemaster
Avatar
Rank Points: 3516
Registered: 08-07-2005
IP: Logged
icon Re: Glut and FTGL (0)  
Kevin_P86 wrote:
#ifndef STDC
extern void exit OF((int));
#endif
I guess you should pass a "-DSTDC" to the compiler, then. That sets the define "STDC" and prevents the inclusion of that piece of code.

(Nevermind that I can't imagine why one would use something dirty like that... :huh)

____________________________
"I'm not anti-anything, I'm anti-everything, it fits better." - Sole
R.I.P. Robert Feldhoff (1962-2009) :(
03-02-2007 at 11:22 PM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts Quote Reply
Kevin_P86
Level: Smitemaster
Avatar
Rank Points: 535
Registered: 06-28-2005
IP: Logged
icon Re: Glut and FTGL (0)  
In case it matters, I tried defining STDC, and it gave me the same error (which leads me to believe (ok, convinces me) that these lines are in fact not the problem... :()

____________________________
+++++[>+++++<-]>[>+++>++++>+++++<<<-]>.>+.>-------.<++++.+++++.
03-03-2007 at 07:57 AM
View Profile Send Private Message to User Send Email to User Show all user's posts This architect's holds Quote Reply
Kevin_P86
Level: Smitemaster
Avatar
Rank Points: 535
Registered: 06-28-2005
IP: Logged
icon Re: Glut and FTGL (0)  
Ok, now I fell really really really really stupid.

This problem was fixed by simply including <stdlib.h> (which defines exit(int) ) in main.cpp... :(

However, now I have a more general problem.

1) I compiled the FTGL project into FTGL_static_MT.lib, which is located at C:\Progs\FTGL\win32_vcpp\build\FTGL_static_MT.lib

2) In the current project (the one in which I wish to use this .lib), I went to Properties -> Linker -> General, and added "C:\Progs\FTGL\win32_vcpp\build" to the "Additional Library Directories" field.

3) In Properties -> Linker -> Input, I added "FTGL_static_MT.lib" to the "Additional Dependencies" field.

From what I understand, that is all I should need to do to use the .lib file. However, it cannot find the code in this .lib file. Specifically, I get errors including
GlutTest error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall FTGLPixmapFont::FTGLPixmapFont(char const *)" (__imp_??0FTGLPixmapFont@@QAE@PBD@Z) referenced in function "void __cdecl display(void)" (?display@@YAXXZ)
which is politely letting me know it can't find the FTGLPixmapFont(const char*) constructor (there are two others similar errors, politely letting me know it can't find the two other functions I call either).

Any suggestions?

____________________________
+++++[>+++++<-]>[>+++>++++>+++++<<<-]>.>+.>-------.<++++.+++++.
03-06-2007 at 04:46 AM
View Profile Send Private Message to User Send Email to User Show all user's posts This architect's holds Quote Reply
Kevin_P86
Level: Smitemaster
Avatar
Rank Points: 535
Registered: 06-28-2005
IP: Logged
icon Re: Glut and FTGL (0)  
Ok, update:

I figured out I need to #define FTGL_STATIC_LIB since I'm using a static library for FTGL. Then I realized I also needed to link to the FreeType .lib... :blush

So now it compiles, links and runs, but I get a nice run-time error on the FTGLPixmapFont::Render(const char*) call. I'll keep searching and hopefully be able to fix this problem as well...!

____________________________
+++++[>+++++<-]>[>+++>++++>+++++<<<-]>.>+.>-------.<++++.+++++.
03-06-2007 at 08:39 PM
View Profile Send Private Message to User Send Email to User Show all user's posts This architect's holds Quote Reply
New Topic New Poll Post Reply
Caravel Forum : Other Boards : Anything : Glut and FTGL (Now it is a more general problem)
Surf To:


Forum Rules:
Can I post a new topic? No
Can I reply? No
Can I read? Yes
HTML Enabled? No
UBBC Enabled? Yes
Words Filter Enable? No

Contact Us | CaravelGames.com

Powered by: tForum tForumHacks Edition b0.98.8
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team and the Caravel team.