|
This guide describes how you can use Agar to compile an application using
Microsoft
Visual Studio
2005, 2003, 2002 or v6.
It also describes the procedure for compiling Agar itself under
Visual Studio.
It assumes that you already have both the
Microsoft Windows SDK
("Platform SDK") and the
Visual C++ 2005 Redistributable Package
installed on your system.
|
Get the latest Agar Windows binary package from the
download page.
You can unpack the archive to a location such as
C:\Program Files\Agar.
Start Visual Studio and bring up Tools / Options.
Select Projects and Solutions / VC++ Directories.
In the Show directories for field, select the option
Include files. If you have unpacked the Agar SDK package
into C:\Program Files\Agar, for example, insert the line:
C:\Program Files\Agar\include
Now select Show directories for / Library files and insert
the line:
C:\Program Files\Agar\lib
|
|
As of version 1.3, Agar requires SDL. If you have not already installed
the SDL development package, go to the
SDL download area,
download the file SDL-devel-1.2.*-VC8.zip (or -VC6.zip),
unpack its contents into a location such as C:\Program Files\SDL
and add C:\Program Files\SDL\include to your include path and
C:\Program Files\SDL\lib to your library path like you just did
with the Agar SDK.
You will also want to copy SDL.dll to your C:\Windows\System
(or C:\Windows\System32 on Windows x64).
If you are going to be redistributing your application, you might want to
include SDL.dll, README-SDL.txt and COPYING in the
package.
|
|
If you have installed one of the nothreads flavors of the Agar SDK,
you can skip this section.
Thread safety and support for thread management in Agar-Core requires the
POSIX threads API. Even if you are not using threads directly, network
applications usually require threads to prevent blocking of the GUI during
network operations.
POSIX threads are supported natively by all modern, decent operating
systems. Under Windows, you will need to install a small library called
Pthreads-win32.
Go to the Pthreads-win32
download area,
get the latest version (pthreads-w32-2-x-x-release.exe) and extract to
in some temporary location.
Rename and move the Pre-built.2 directory over to
C:\Program Files\Pthreads.
Copy the DLL files (or at least PthreadVC2.DLL) from the lib
subdirectory to your C:\Windows\System (or C:\Windows\SysWOW64
with Windows x64).
Go to
Tools / Options / Projects and Solutions / VC++ Directories
in Visual Studio and add
C:\Program Files\Pthreads\include to your include path and
C:\Program Files\Pthreads\lib to your library path like you
just did for Agar and SDL.
|
|
Optional: Installing FreeType (from binary package) |
|
If you have installed one of the nofreetype flavors of the Agar SDK,
you can skip this section.
Without FreeType, Agar will revert to a built-in, low-quality bitmap font
engine (but you probably don't want to use it).
You can download a binary package of FreeType for Windows, which was compiled
and tested using Visual Studio 2005, here:
FreeType235-win32-i386.zip,
and unpack it into a directory such as
C:\Program Files\FreeType.
If for some reason this package doesn't work, there is also a package
available from
GnuWin32 (SourceForge download area), but you will have to
rename lib/libfreetype.dll.a to freetype.lib (and
copy bin/freetype6.dll to your C:\windows\system also or
C:\windows\system32). You will probably get some linker warnings since
the GnuWin32 binaries were not compiled with Visual C++.
|
|
Optional: Installing FreeType (by compiling it yourself) |
If you would like to compile FreeType using Visual Studio yourself,
follow these steps:
Go to the
FreeType download area,
download the latest source package (ft*.zip), and unpack it to
some temporary location.
In the FreeType source directory, go to the builds\win32\visualc
subdirectory and open up freetype.sln in Visual Studio.
Locate the "Solution Configurations" selector in the Visual Studio toolbar,
and select "Release Multithreaded".
Now build the solution. This will generate the .lib file we need. Then,
right-click on the freetype project entry in Solution Explorer,
go to Properties and locate Configuration Properties / General.
In the Project Defaults section, set the Configuration Type
field to Dynamic Library (.dll), and build the solution again, this
time it will generate our .dll file.
Exit Visual Studio, and go to the build directory of FreeType
(i.e., objs in the FreeType source directory). Locate the
.lib file (e.g., freetype*MT.lib), copy it over to
a new directory, such as C:\Program Files\FreeType\lib, and
rename it freetype.lib. Then, locate freetype.dll in
release_mt in the FreeType build directory, and copy it to
C:\Program Files\FreeType\lib. You may want to copy this DLL
to your C:\Windows\System or C:\Windows\System32 as
well.
Copy the entire include directory from the FreeType sources to
C:\Program Files\Freetype\include.
Like you just did with Agar and SDL, add the directories
C:\Program Files\FreeType\include and
C:\Program Files\FreeType\include\freetype2
to your include path and add
C:\Program Files\FreeType\lib
to your library path in
Tools / Options / Project and Solutions / VC++ Directories.
You should now be able to use FreeType from Visual Studio.
|
|
Creating an Agar application in Visual Studio |
|
You can now create your application. In the Application Wizard,
set Application type to Console application, check
the Empty project box and click Finish.
In the Solution Explorer, go to Properties from the
popup menu of your project.
Click on Configuration Properties / Linker / System and set
the SubSystem parameter to
Windows (/SUBSYSTEM:WINDOWS).
Click on Configuration Properties / Linker / Input, and add
the following to the Additional Dependencies field:
ag_gui.lib
ag_core.lib
SDL.lib
SDLmain.lib
opengl32.lib
freetype.lib
If you are using a nogl flavor of the Agar SDK, you can remove
opengl32.lib.
If you are using a nofreetype flavor, you can remove
freetype.lib.
Add a new C++ file to Source Files in the Solution Explorer,
such as main.cpp. Here is a standard
Hello World
you can use.
Your application should now compile and run properly.
Note: If you want your application to be portable to other operating
systems and other development environments, consider the
BSDBuild
utility. It can even generate project files for you.
|
|
Compiling Agar itself with Visual Studio |
|
If you are not using the precompiled SDK and would like to compile Agar
yourself, look for the project files included in the .\ProjectFiles\
directory in the Agar source. Locate the .zip file matching your
Visual C++ release, for example vs2005-windows.zip will work with all
Visual C++ 2005 editions.
There are also some flavors such as nothreads, which disable thread
safety and nofreetype which does not depend on FreeType.
Unpack the archive into the very top Agar source directory, such that
Agar.sln will end up in the same directory as Agar's README
file.
Open Agar.sln with Visual Studio and you should now be able to compile
the toolkit.
Once Agar is compiled, run INSTALL-SDK.EXE in the root
of the Agar source directory to install the libraries on your system.
By default, they are installed into
C:\Program Files\Agar.
|
|
If you are getting this linker error:
SDLmain.lib(SDL_win32_main.obj): error LNK2019:
unresolved external symbol _SDL_main referenced in function _main
Make sure your main() is declared exactly as int main(int argc, char *argv).
|
|