Course list http://www.c-jump.com/bcc/
DLLs are Dynamic Link Libraries
set of pre-compiled functions
reused by multiple programs
C++ header files
have no executable code
only declare functions available in DLLs
#include "myheader.h" // search for this file in my project directory
#include <anotherheader.h> // search for this file elsewhere
Lib files
binary files used by the linker
help the linker to locate functions in the DLL
provide physical addresses of functions declared in header files and implemented in DLLs
We need to configure the project and specify
location of the header files
location of the lib files
We also have to make sure that our .EXE can find the DLLs.
For simplicity, we can keep copies of the DLLs in the EXE output directory.
Decide where your OpenGL-related projects will live on your drive. This doesn't have to be a fixed directory (Windows refers to directories as "folders".) For example, on my desktop computer I have it in
C:\bcc\courses
and on my laptop it is in
F:\research
You will be able to copy the entire directory to a different place and it will continue to work there. So all you need to do is decide where to start. Keep it simple, for example,
C:\bcc
I strongly recommend not to use spaces in your directory and file names. If you do, some things can break and cause a headache.
Download GL262Labs.zip and unzip its contents under your directory. The result should be:
C:\bcc\GL262Labs
It will contain the following subdirectories:
bin.........EXE programs that you build will be here
common......C++ files shared between multiple project
example.....Sample C++ projects
external....External libraries: FreeGLUT, GLEW, GLM
labs........Your homeworks
Models......Cars, dragons, pyramids, teapots, cows, and so on
Explore the external subdirectory. Understand that you don't have to install any of those because they're just a bunch of DLL, LIB, and C++ header files.
C++ header files are plain text files that contain declarations of functions and constant variables.
Function declarations are functions without a body. For example,
// myheader.h
// Function declaration:
bool load_data_from_file( char const* filename );
Once the header is included in your C++ program, you can call this function
// main.cpp
#include "myheader.h"
int main( int argc, char* argv[] )
{
bool success = false;
success = load_data_from_file( "C:/data/mydata.txt" );
if ( !success ) {
// could not load data from file
} else {
// everything is good
}
return 0;
}
There are two possibilities where function load_data_from_file() can be defined:
(a) you implement it in your own C++ file and compile
(b) it is written by someone else and exists in a binary form inside a DLL (dynamic link library)
What's the difference?
(a) no additional steps required
(b) you need to tell the linker where in a DLL the function implementation is. The way you do it -- specify a path to the LIB file in "Additional Library Directories" and "Additional Dependencies" of your linker's configuration.
And, where are the DLLs themselves? -- in our case -- in the same location where our EXE file is written. The reason is because when your program runs, it searches the local directory (the place the program is run from) for the DLL first. If it can't find it, it looks in anything that your $PATH environment variable specifies.
There are actually two places where our EXE files may be written:
C:\bcc\GL262Labs\bin\Debug
C:\bcc\GL262Labs\bin\Release
It depends whether you use "Debug" or "Release" configuration in your project. Most programmers test their code under both configurations.
Note: if EXE couldn't find your DLL, you get a message box like this:
A LIB file (or library) contains binary code used by the linker to link the code into an executable file. We use a type of .lib files that contain indirect references to DLL functions, which are also binary code.
Go ahead and open Visual Studio project
C:\bcc\GL262Labs\labs\c262_lab01\c262_lab01.sln
Compile it:
Build -> Build Solution
(or simply press F7.)
When you compile your program,
All CPP files are compiled into OBJ files by the C++ compiler
All OBJ and LIB files are linked together and written into the EXE file by the linker.
When you run your EXE program, the DLLs are also loaded into memory, and program starts making calls into those DLLs.
Start Visual Studio.
Create a new project
File -> New -> Project
Make sure to select C++ language and "Empty Project C++"
Name your project, e.g. MyOpenGLProgram
Specify 'labs' location of your project (or nothing will work!!)
C:\bcc\GL262Labs\labs
Select "Create new solution"
Check "Place solution and project in the same directory"
Click Create
Select
View -> Solution Explorer
Right-click "Source Files", then
Add -> New Item...
and select CPP file type. Name it main.cpp
Copy and paste the code from c262_lab01.cpp in c262_lab01 lab.
C:\bcc\GL262Labs\labs\c262_lab01
Right-click the name of your project in the Solution Explorer. Select "Configuration Properties"
Switch Configuration to 'All Configurations'
Under "General", specify "Output Directory" as $(SolutionDir)\..\..\bin\$(Configuration)\
Under C/C++, specify "Additional Include Directories" add
..\..\external\freeglut\include ..\..\external\glew-2.1.0\include
Under Linker/General, specify "Additional Library Directories" add
..\..\external\freeglut\lib\x64 ..\..\external\glew-2.1.0\lib\Release\x64
Under Linker/Input, specify "Additional Dependencies" add
glew32.lib freeglut.lib
Apply changes and close the project's Configuration Properties dialog.
Compile and run your program!
Run google search for GLEW OpenGL Extension Wrangler Library
Download binaries for "Windows 32-bit and 64-bit".
GLEW is a collection of of DLLs, libs, and C++ header files
No need to install any of the files. Open downloaded archive and examine its contents.
Extract new files to C:\bcc\GL262Labs\external directory.
Copy the new GLEW DLLs from
GL262labs26s\external\glew-2.x.x\lib\Release\x64
to directories
GL262labs26s\bin\Debug GL262labs26s\bin\Release
Run google search for freeglut
Download and unzip into C:\bcc\GL262Labs\external directory.
Copy new FreeGLUT DLL to C:\bcc\GL262Labs\bin\Debug and Release subdirectories.
NOTE: File external\freeglut\include\GL\freeglut_std.h now includes support for freeglutd.lib, controlled via macro definition
#ifdef NDEBUG
However, freeglutd.lib is not included in the binary distribution package. To avoid problems, simply make a copy of freeglut.lib and name it freeglutd.lib.
There are no files to submit.
Demonstrate a working c262_lab01 program to your instructor.