How to build FreeGLUT with Pelles C?

Started by YellowBeast, April 29, 2014, 12:17:20 PM

Previous topic - Next topic

YellowBeast

Hello people!
I would appreciate it a lot if someone could give me a step-by-step tutorial for how to build the FreeGLUT libraries with Pelles C 7.

So far, I can build the LIB and the DLL (by simply compiling all the C files in src), but I get a lot of "not referenced" warnings, and the program using FreeGLUT crashes when started.

Something I am not doing right so I'd like to know how others do it instead.
Thank you.

Here FreeGLUT 2.8.1 can be downloaded:
http://freeglut.sourceforge.net/

TimoVJL

#1
With static library use define FREEGLUT_STATIC FREEGLUT_BUILDING_LIB
Check this example.
May the source be with you

YellowBeast

TimoVJL, thank you very much for your project sample.
After configuring it to use the FreeGLUT include folder on my computer, both the LIB and EXE compile fine and work.

I have some questions:

1. The "XYZ is not referenced" warnings still appear when compiling the library.
Why? And how can they be fixed?

2. For the LIB, the compiler uses __cdecl calling convention but assembler uses stdcall.
I don't understand how different conventions work together.

3. For the LIB, why was the file freeglut_ext.c excluded?

Thanks again.

YellowBeast

Bumping for interest.
Could someone try to answer my questions above, please? Thank you.

TimoVJL

Quote from: YellowBeast on April 29, 2014, 03:04:07 PM
1. The "XYZ is not referenced" warnings still appear when compiling the library.
Why? And how can they be fixed?
Turn off warnings. ;)

Quote from: YellowBeast on April 29, 2014, 03:04:07 PM
2. For the LIB, the compiler uses __cdecl calling convention but assembler uses stdcall.
I don't understand how different conventions work together.
__cdecl was chosen because new users try to make console application anyway. ;)

Quote from: YellowBeast on April 29, 2014, 03:04:07 PM
3. For the LIB, why was the file freeglut_ext.c excluded?
Mistake? That's for DLL ?   :-\
May the source be with you

jj2007

Quote from: YellowBeast on April 29, 2014, 03:04:07 PM
2. For the LIB, the compiler uses __cdecl calling convention but assembler uses stdcall.
I don't understand how different conventions work together.

The caller overrides its default convention:
int __stdcall some_C_function(void);

YellowBeast

Quote from: TimoVJL on May 01, 2014, 09:24:05 AM
Quote from: YellowBeast on April 29, 2014, 03:04:07 PM
1. The "XYZ is not referenced" warnings still appear when compiling the library.
Why? And how can they be fixed?
Turn off warnings. ;)
Heh. ::)
Seriously though, what do the warnings mean exactly?

Quote from: TimoVJL on May 01, 2014, 09:24:05 AM
Quote from: YellowBeast on April 29, 2014, 03:04:07 PM
2. For the LIB, the compiler uses __cdecl calling convention but assembler uses stdcall.
I don't understand how different conventions work together.
__cdecl was chosen because new users try to make console application anyway. ;)
Well in the case this will help others, my current settings are:

(both library and test program)
Compiler -> Calling conv: __cdecl
Assembler -> Calling conv: cdecl

(test program)
Linker -> Subsystem -> Type: Windows
Linker -> Entry point: mainCRTStartup

Quote from: jj2007 on May 01, 2014, 09:27:34 AM
Quote from: YellowBeast on April 29, 2014, 03:04:07 PM
2. For the LIB, the compiler uses __cdecl calling convention but assembler uses stdcall.
I don't understand how different conventions work together.

The caller overrides its default convention:
int __stdcall some_C_function(void);
By checking the source code of FreeGLUT, I didn't find any such overrides. Thanks for the idea though.

Stefan Pendl

Quote from: YellowBeast on April 29, 2014, 03:04:07 PM
1. The "XYZ is not referenced" warnings still appear when compiling the library.
Why? And how can they be fixed?

The variables or other objects are declared, but never used.

To fix these, you need to use them, but if this is third party source code, it might just have been included for future use.
---
Stefan

Proud member of the UltraDefrag Development Team