EasyBMP C++ Bitmap Library

EasyBMP: Including and Compiling EasyBMP

What do you think? Feedback Requested!

In Version 1.01, EasyBMP started to separate all code into a separate EasyBMP.cpp file. This means that to use EasyBMP into your project, you now have to add a small step when you compile. (See below.) The benefit, however, is that the code is now separate (which is a better coding practice), and EasyBMP works better with larger projects.

In the past, it was enough to simply include EasyBMP.h in your cpp files and compile your project without modification. This was slightly easier for the novice user, but not terribly easier.

So, do you have an opinion on this? Do you have a style that you prefer better? Would you rather see EasyBMP returned to its origins of only header files? Do you like the way it is now? Does it matter?

I'd love to hear your feedback, and I welcome your emails at macklin01@users.sourceforge.net. Thank you!! -- Paul

Introduction

Compiling EasyBMP into your project is easy, and there are several methods available to do so. We include instructions for several major compilers:

Compiling with g++, icc, mingw, etc.

A range of options is available for compiling with a g++-like compiler. All are relatively straightforward, and we detail those approaches here. In all cases, we are assuming that your project consists of a single C++ file main.cpp and EasyBMP, and you want to name your executable program.

Method 1: Basic Compiling (No Makefile or .o Objects)

  1. Get EasyBMP: Download the core library of EasyBMP. The file will be named EasyBMP_#.##.zip, where #.## is the version of the library. Unzip the contents into the main directory of your project.

  2. Include EasyBMP: Add the line

    #include "EasyBMP.h"

    in any project source (.cpp) file that uses EasyBMP.

  3. Compile: Compile your project and EasyBMP as follows:

    g++ -o program main.cpp EasyBMP.cpp

    That's it! You should now have an executable named program.

Method 2: Intermediate Compiling (No Makefile, but with .o Objects)

  1. Get EasyBMP: Download the core library of EasyBMP. The file will be named EasyBMP_#.##.zip, where #.## is the version of the library. Unzip the contents into the main directory of your project.

  2. Include EasyBMP: Add the line

    #include "EasyBMP.h"

    in any project source (.cpp) file that uses EasyBMP.

  3. Compile EasyBMP: Compile EasyBMP to a binary object as follows:

    g++ -c EasyBMP.cpp

  4. Compile and Link: Compile your project and link EasyBMP as follows:

    g++ -o program main.cpp EasyBMP.o

    That's it! You should now have an executable named program.

Method 3: Advanced Compiling with a Makefile

  1. Get EasyBMP: Download the core library of EasyBMP. The file will be named EasyBMP_#.##.zip, where #.## is the version of the library. Unzip the contents into the main directory of your project.

  2. Include EasyBMP: Add the line

    #include "EasyBMP.h"

    in any project source (.cpp) file that uses EasyBMP.

  3. Write a makefile: In your favorite text editor, create a new file named makefile, which has the following lines:

    CC = g++     # name of the compiler
    CFLAGS = -O3 # optimization flags

    program: main.o EasyBMP.o
         $(CC) $(CFLAGS) -o program main.o EasyBMP.o

    main.o: main.cpp
         $(CC) $(CFLAGS) -c main.cpp

    EasyBMP.o: EasyBMP.cpp
         $(CC) $(CFLAGS) -c EasyBMP.cpp

    clean:
         rm -f *.o

  4. Make: Compile your project and link EasyBMP as follows:

    make

    That's it! You should now have an executable named program.

Compiling with Microsoft Visual C++

Coming soon!

Compiling with Borland's Free Command Line Tools

If you're using Borland's free command line tools, you should really look into upgrading to the open source MinGW compiler. It's just as easy to use as Borland, it's free, and it's more modern, less buggy, and more standards-compliant.

However, if you must use Borland's compiler, here are the instructions. Both methods assume that you have a project that consists of a single C++ source file main.cpp and EasyBMP, and you want to name your executable program.

A Note on Strange Warnings

We note that as of the time of this writing (7-22-2006), the Borland produces some strange warnings, such as W8008 and W8066. Most of these warnings appear to be harmless and/or incorrect, but we are working to eliminate as many Borland errors as possible. A new release of EasyBMP will be forthcoming.

Method 1: Compiling and Linking in One Command

  1. Get EasyBMP: Download the core library of EasyBMP. The file will be named EasyBMP_#.##.zip, where #.## is the version of the library. Unzip the contents into the main directory of your project.

  2. Include EasyBMP: Add the line

    #include "EasyBMP.h"

    in any project source (.cpp) file that uses EasyBMP.

  3. Compile and Link: Compile your project as below:

    bcc32 -eprogram EasyBMP.cpp main.cpp

    That's it! You should have an executable named program.exe.

Method 2: Compiling and Linking Separately

  1. Get EasyBMP: Download the core library of EasyBMP. The file will be named EasyBMP_#.##.zip, where #.## is the version of the library. Unzip the contents into the main directory of your project.

  2. Include EasyBMP: Add the line

    #include "EasyBMP.h"

    in any project source (.cpp) file that uses EasyBMP.

  3. Compile the binary objects: Use the following commands to compile the binary objects:

    bcc32 -c EasyBMP.cpp
    bcc32 -c main.cpp

  4. Link the binary objects: As below:

    bcc32 -eprogram EasyBMP.obj main.obj

    That's it! You should have an executable named program.exe.