MarshallSoft GPS Component
for C/C++
Programmer's Manual
(MGC4C)
Version 2.0
June 22, 2007
This software is provided as-is.
There are no warranties, expressed or implied.
Copyright (C) 2007
All rights reserved
MarshallSoft Computing, Inc.
Post Office Box 4543
Huntsville AL 35815
Voice : 1.256.881.4630
email : info@marshallsoft.com
web : www.marshallsoft.com
MARSHALLSOFT is a registered trademark of MarshallSoft Computing.
1 Introduction
1.1 Features2 Library Overview
1.2 Documentation Set
1.3 Example Program
1.4 Installation
1.5 Uninstalling
1.6 Pricing
1.7 Updates
2.1 Dynamic Link Libraries3 Compiler Issues
2.2 Keycode
2.3 Using the Library
2.4 GUI and Console Mode
2.5 Using Threads
2.6 Win32 STDCALL and DECLSPEC
2.7 Calling MGC from C++
2.8 Adding MGC To An Existing Program
2.9 Error Display
2.10 Explicitly Loading MGC32.DLL
3.1 Compiling Using an IDE4 Supported Compilers
3.2 Command Line Tool Setup
3.2.1 Microsoft3.3 Command Line Batch Files
3.2.2 Borland
3.2.3 Watcom
3.2.4 Lcc-Win32
3.4 Command Line Makefiles
4.1 Microsoft Visual C/C++5 Compiling Programs
4.2 Microsoft Visual C++ .NET
4.3 Microsoft Visual C# .NET
4.4 Borland C/C++
4.5 Turbo C/C++ for Windows
4.6 Borland C++ Builder
4.7 Watcom C/C++
4.8 Lcc-Win32 C/C++
5.1 Compiling MGC6 Example Programs
5.2 Compiling Example Programs
5.3 Static Linking
7 Revision History
The MarshallSoft GPS Component for C/C++ (MGC4C) library is a toolkit that allows software developers to quickly develop GPS applications in C/C++. The MarshallSoft GPS Component (MGC) is a library of functions providing direct and simple control of GPS data.
A straightforward interface provides the functionality to read and decode standard GPS (Global Positioning System) NMEA 183 sentences from the RS232 serial port as well as compute great circle distances and bearings.
The MarshallSoft GPS Component for C/C++ library toolkit supports and has been tested with C/C++, Microsoft Visual C++, Visual C++ .NET, C# .NET, Borland C/C++, Borland Turbo C++ for Windows, Borland C++ Builder, Microsoft Foundation Class (MFC), Watcom C/C++, and LCC-Win32 C compilers. MGC4C can also be used with most other C/C++ Windows compilers.
Registered users can statically link MGC with their application rather than using the MGC32.DLL.
A Win32 DLL (Dynamic Link Library) is provided. The MarshallSoft GPS component library runs under all versions of Windows (Windows 98, Windows ME, Windows 2000, Windows 2003, Windows NT, Vista and Windows XP). The MarshallSoft GPS Component DLL (MGC32.DLL) can also be used from any language (Visual Basic, Delphi, Visual FoxPro, COBOL, Xbase++, dBase, etc.) capable of calling the Windows API. Since the MGC toolkits use the same DLL for all software languages, a developer, for example, can purchase a developer license for MGC4C and use the same DLL also with MGC4VB.
MGC4C includes multiple C/C++ example programs with full source code including examples for Visual C++ .NET and C# .NET. Sixteen example programs are included, demonstrating MGC functions to read and decode GPS data. Microsoft Foundation Class (MFC) and Borland C++ Builder (BCB) examples are also provided. Refer to Section 5 for more details on each of the example programs.
[PROGRAM] [DESCRIPTION]
MGCVER: Program that displays the MGC4C version & build numbers.
HELLO: Program similar to MGCVER but uses the MGC class fMGC.
GPRMC: Program that decodes GPRMC sentences.
GPGGA: Program that decodes GPGGA sentences.
GPGLL: Program that decodes GPGLL sentences.
GPGSV: Program that decodes GPGSV sentences.
GPVTG: Program that displays all NMEA GPVTG sentences.
RAW: Program that decodes all sentences.
LATLON: Program that graphically displays latitude & longitude.
COMPUTE: Computes distances and bearings.
CONVERT: Converts between (deg,min,min/100), (deg,min,sec), etc.
BCB_PRJ: Borland C++ Builder version of LATLON.C
MFC_PGM: Microsoft Foundation Class version of LATLON.
VC_CGA: Microsoft VC .NET example program similar to GPGGA.
VC_VERS: Microsoft VC .NET example program similar to MGCVER.
CS_VERS: Microsoft Visual C# .NET example program similar to MGCVER.
VC_LATLON: Microsoft VC .NET version of LATLON.C
CS_LATLON: Microsoft Visual C# version of LATLON.C
CALLBACK: Example program that uses mgcCallback.
The latest version of the MarshallSoft GPS Component software can be found online at:
http://www.marshallsoft.com/mgc4c.htm
The evaluation and registered versions are identical except that the evaluation version displays the evaluation (SW_Info) screen. The evaluation version is limited to a time period of 60 days.
Some of the many features of the MarshallSoft GPS Component (MGC) library toolkit are:
The complete set of documentation consists of three manuals in three formats. This is the first manual (MGC_4C) in the set.
Each manual comes in three formats:
The MGC4C Programmer's Manual is the language specific (C/C++) manual and provides information needed to install and compile example programs in a C/C++ environment.
The MarshallSoft GPS Component User's Manual (MGC_USR) discusses GPS (Global Positioning System) fundamentals as well as language independent programming issues such as application notes, purchasing and licensing.
The MarshallSoft GPS Component Reference Manual (MGC_REF) contains details on each individual MGC function.
Online documentation can be accessed on the MarshallSoft GPS Component for C/C++ product page at:
http://www.marshallsoft.com/mgc4c.htm
The following example demonstrates the use of some of the MarshallSoft GPS Component library toolkit functions. It reads, decodes and prints out GPGGA navigation sentence data.
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "mgc.h"
static char DataBuffer[256];
static int Port;
int ShowMGCError(int Code)
{printf("MGC error %d\n",Code);
return Code;
}
void main(int argc, char *argv[])
{int Code;
double Latitude;
double Longitude;
/* process args */
if(argc!=2)
{printf("Usage: EXAMPLE <port>\n");
return;
}
Code = mgcAttach(MGC_KEY_CODE);
if(Code<0)
{printf("Error %d: Cannot attach MGC32.DLL, check key code\n", Code);
return;
}
Port = atoi(argv[1]) - 1;
Code = mgcOpen(Port);
if(Code<0)
{ShowMGCError(Code);
exit(1);
}
printf("EXAMPLE Program\n");
// specify GPGGA sentences
Code = mgcSetInteger(MGC_SET_SENTENCE_TYPE, MGC_SENTENCE_GPGGA);
if(Code<0)
{ShowMGCError(Code);
exit(1);
}
while(1)
{// lock data buffer
mgcLockData(1);
// get data quality
Code = mgcGetData(GPGGA_QUALITY,(LPSTR)DataBuffer);
if(Code<0) ShowMGCError(Code);
if(Code==1)
{// reference count = 1 (1st time seen this data set)
printf("<%s> ", DataBuffer);
// get latitude
Latitude = (double)mgcGetLatitude() / 100000.0;
printf("Lat=%0.4f ", Latitude);
// get longitude
Longitude = (double)mgcGetLongitude() / 100000.0;
printf("Lon=%0.4f ", Longitude);
printf("\n");
}
// unlock data buffer
mgcLockData(0);
Sleep(500);
}
mgcClose();
} /* end main */
All recent WIN32 C/C++ compilers support the "declspec" keyword. Microsoft Visual C++ (version_4.0 and up), Borland (version_5.0 and up), Watcom (version_11.0 and up), and LCC-Win32 compilers support the "declspec" keyword.
Uninstalling MGC4C is very easy. MGC does NOT modify the registry. First, delete the MGC project directory created when installing MGC4C. Second, delete MGC32.DLL from your Windows directory, typically C:\WINDOWS for Windows 95/98/Me/XP/2003/Vista and C:\WINNT for Windows NT/2000. That's it!
A developer license for the MarshallSoft GPS Component library can be purchased for $115 (or $195 with source code to the library DLL). Purchasing details can be found in Section 1.3, "How to Purchase", of the MGCC User's Manual (MGC_USR). (http://www.marshallsoft.com/mgc_usr.htm#Section_1.3)
Also see INVOICE.TXT or http://www.marshallsoft.com/order.htm
When a developer license is purchased for MGC4C, the developer will be sent a registered DLL (MGC32.DLL) plus a license file (MGCxxxx.LIC) that can be used to update the registered DLL for a period of one year from purchase. Updates can be downloaded from
http://www.marshallsoft.com/oem.htm
After one year, the developer license must be updated to be able to download updates. The developer license can be updated for $30 if ordered within one year of the original purchase (or previous update). From one year to three years, licenses can be updated for $55. After 3 years, licenses can be updated for $75. These updates do not include source code. Source code can be updated for $50 in addition to the cost of the update ($30, $55 or $75).
Note that the registered DLL does not expire.
The MarshallSoft GPS Component Library (CSC) is implemented as a Win32 dynamic link library (DLL). A DLL is characterized by the fact that it need not be loaded until required by an application program and that only one copy of the DLL is necessary regardless of the number of application programs that use it. Contrast this to the traditional static library that is bound to each and every application that uses it at link time.
An important advantage that DLL's have over other "popular" library formats such as VBX or OCX is that DLL's are callable by all Windows applications. Since DLL's are the building blocks of the Windows Operations System, they will not be replaced by a "newer technology".
MGC32.DLL has a keycode encoded within it. Your keycode is a 9 or 10 digit decimal number (unless it is 0), and will be found in the file KEYCODE.H. The keycode for the evaluation version is 0. You will receive a new key code when registering. During SETUP, the keycode is copied to the \APPS sub-directory.
If the error message (value -74) is received when calling mgcAttach, it means that the keycode in your application does not match the keycode in the DLL. After registering, it is best to remove the evaluation version of MGC32.DLL from the Windows search path.
The MarshallSoft GPS Component Library for C/C++ ++ has been tested on multiple computers running Windows 95/98/Me/XP/Vista and Windows NT/2000.
The MGC4C library has also been tested with several C/C++ compilers, including Microsoft Visual C++ (all versions including C++ .NET and C# .NET), Borland C/C++, Borland C++ Builder, Turbo C/C++ for Windows, and Watcom C/C++.
The SETUP installation program will copy the Lib's and DLL to your Windows directory.
MGC4C functions can be called from any Win32 application program (Win32 GUI mode or Win32 console mode). MGC4C functions cannot be called from Win16 programs.
A "GUI Mode" program is the common Windows program with the Graphical User Interface (GUI).
A "console mode" program is a Windows 95/98/NT/2000/Me/XP/VISTA WIN32 command line program running in a command window. Although console mode programs look like DOS programs, they are WIN32 programs that have access to the Win32 API and the entire Windows address space. Programming using console mode programs reduces the complexity of using GUI code. All console mode programs can be converted to GUI mode by adding the necessary Windows interface code
MGC4C is thread safe, and may be called from threaded applications.
MGC is compiled using the _stdcall and _declspec keywords. This means that MGC4C uses the same calling conventions and file naming conventions as the Win32 API. In particular, function names are NOT decorated. There are no leading underscores, nor trailing "@size" strings, added to function names.
Microsoft Visual C++ users can look at the MGC function names using the dumpbin.exe executable:
dumpbin /exports mgc32.dll
Like Windows itself, MGC functions are coded in ANSI C, but they can be called directly from both ANSI C programs and from C++ and C# programs.
MGC functions can also be called using the C++ class wrapper fmgc. See fmgc.cpp and fmgc.h. Refer to HELLO.CPP for an example.
In order to add MGC to an existing program, (1) add
#include "mgc.h"
to your source code, (2) link with MGC32.LIB (for MSVC), MGC32BCB.LIB (Borland C/C++ and C++ Builder), MGC32.LIB (Watcom), or MGC32LCC (Win32/LCC), and recompile from source.
Refer also to Section 4.0 below.
The error message text associated with MGC error codes can be displayed by calling mgcErrorText.
void DisplayError(int ErrCode, char *MsgPtr)
{int Len;
char ErrBuff[129];
printf("ERROR %d: ", ErrCode);
if(MsgPtr) printf("%s: ", MsgPtr);
Len = mgcErrorText(ErrCode, (char *)ErrBuff, 128);
if(Len>0) printf("%s\n", ErrBuff);
else printf("\n");
}
When an application program runs that makes calls to MGC32.DLL, the Windows operating system will locate MGC32.DLL by searching the directories as specified by the Windows search path. If the MGC32.DLL is placed in the \WINDOWS directory (or \WINNT for Windows NT/2000), it will always be found by Windows.
However, MGC32.DLL can also be loaded from a specified directory by using the GetProcAddress Win32 API function. For an example, refer to the LoadLib.c program.
MGC programs can be compiled using an IDE or command line compiler tools. The following sections provide general compiler information. In order to compile from the command line, command line compiler tools must be set up properly.
All current windows compilers have an "Integrated Development Environment" (IDE) for building application programs in the Windows environment. Since there is no standard format for IDE project files, file names must be entered into the IDE from the keyboard.
Note that not only do IDE's vary between the different compiler manufacturers, but they also vary from version to version for the same compiler.
Most of the example programs can be compiled from your compiler's IDE. For Visual C/C++, "project makefiles" are used since they can be used by all versions of Microsoft Visual C++ (v4.0, v5.0, and v6.0). When opening the workspace, select "makefiles(.mak)" for the file type.
Alternatively, for Visual C++ v6.0, select "projects (.dsp)" for the file type.
Creating a project makefile for the examples that have only command line makefiles is fairly straight forward. All of the IDE's use the concept of a file hierarchy. For example, the MGCVER example program file hierarchy in the IDE (for 32-bit) should look like:
MGCVER.EXE
+++ MGCVER.C
+++ MGC.LIB
Replace MGC.LIB above with MGCBCB.LIB if using Borland C++ Builder and with MGCLCC.LIB if
using Lcc-Win32.
The order of the files is not significant. Also refer to the sections on individual IDE's that follow this section.
Many software developers overlook the power of using command line compilers. There are a number of very significant advantages to using the command line version of your C/C++ compiler. Among these are:
If you want to compile from the command line, your command line compiler tools must be set up properly. Note that you have an option of installing the command line tools (or not) when your compiler is first installed. Refer to your compiler manufacturer's manual for details.
If necessary, you can increase the size of your environment table space (to 1024 for example) by adding
SHELL=C:\COMMAND.COM /e:1024 /p
to CONFIG.SYS in C:\ and then rebooting. This works for all versions of Windows, including Windows NT, 2000, and XP.
For all compilers, your path should point to the compiler's BIN directory. For example, to add "C:\BC50\BIN" to your existing path, use
PATH C:\BC50\BIN;%PATH%
Set LIB and INCLUDE environment variables. For example,
SET INCLUDE=C:\MSVC\INCLUDE
SET LIB=C:\MSVC\LIB
Check that TURBOC.CFG, BCC32.CFG, TLINK.CFG, and TLINK32.CFG all have the correct information in them, as they should have when your compiler was installed. For example, assuming your BC compiler is installed at C:\BC5, the INCLUDE (-I) and LIB (-L) paths are specified by:
-IC:\BC5\INCLUDE
-LC:\BC5\LIB
BRCC (the Borland Resource Compiler) doesn't use the *.CFG files. Set the INCLUDE environment variable or BRCC will not be able to find the INCLUDE files (such as WINDOWS.H). For example,
SET INCLUDE=C:\BC5\INCLUDE
Clear the LIB environment variable (so it is not present when SET is typed at the command line) with
SET LIB=
Set the WATCOM environment variables to point to your compilers include (H) and BIN directories. For example,
SET INCLUDE=C:\WC11\H;C:\WC11\H\NT
SET WATCOM=C:\WC11
SET EDPATH=C:\WC11\EDDAT
SET WWINHELP=E:\BINW
The LCC environment variables are set like the others. For example,
SET INCLUDE=C:\LCC\INCLUDE
SET LIB=C:\LCC\LIB
After making the above changes for your compiler, type PATH at the command line prompt to verify the search path, and type SET at the command line prompt to verify the INCLUDE and LIB environment variables.
If your compiler installation includes command line tools, then all of the example programs can be compiled directly from the command line. These same compiler commands can also be placed in a batch file.
See MGCVER$.BAT for an example of a console mode command line batch file and LATLON$.BAT for an example of a GUI mode command line batch file. Similarly, command line batch files can be created for all of the example programs.
Command line makefiles originated on UNIX systems. They are the standard way that C/C++ programs are constructed in command line environments. The advantage of makefiles (as compared to an integrated development environment) is that all compiler switches are coded within the makefile and the makefile can be run with a single keystroke.
Command line makefiles are provided for Microsoft, Borland, Watcom, and LCC-Win32 command line compilers. They can be found in the APPS sub-directory:
The MarshallSoft GPS Component for C/C++ has been tested with Microsoft Visual C++ (all versions including Visual C++ .Net and Visual C# .NET), Borland C/C++, Borland C++ Builder, Borland Turbo C++, Watcom C/C++, and Lcc-Win32 C. Other Windows C/C++ compilers may work as well. Refer also to Section 5.2 "Compiling Example Programs".
Microsoft Visual C/C++ programs can be compiled from either the command line or from within the Microsoft development environment. All MS VC programs are Win32 only.
Programs can be compiled using command line makefiles. All Microsoft (Win32) command line makefiles end with '._m_". To compile using a makefile, use the Microsoft NMAKE utility. For example,
NMAKE -f LATLON._M_
MGC can be used with Microsoft Foundation Class (MFC) programs. Use the MFC_PGM.MAK makefile to compile the MFC_PGM example program.
NMAKE -f MFC_PGM.MAK
To open an existing project, choose "File", then "Open Workspace", and then select "Makefiles" from the list of file types. Several of the example programs have Microsoft Visual Studio C/C++ makefiles, ending with ".MAK" , such as
MGCVER.MAK
LATLON.MAK
To create a new project in MS VC 4.0, choose "File", then "New", then "Project Workspace". Select "Application" or "Console Application" for "Type:" and your project name for "Name:". Choose Win32 for platform. Then select "Create". Select "Insert", then "Files into Project". Add all filenames including any resource file (.RC) and MGC.LIB. Lastly, select "Build", then "Rebuild All".
To create a new project in MS VC 5.0, choose "File", then "New", then "Win32 Application" or "Win32 Console Application " and your project name. Check "Create new workspace". Select "Project", then "Add to Project". Add all filenames including any resource file (.RC) and MGC.LIB. Lastly, select "Rebuild All".
If the compiler complains that it cannot find "_main", "Console Application" was chosen but the program being compiled is a GUI application. If the compiler complains that it cannot find "WinMain", "Application" was chosen but the program being compiled is a Console Mode application.
Creating a new project in MSVC 6.0 follows the same logic as for MSVC 5.0.
All Visual Studio VC .Net projects end with extension ".vcproj". For example,
vc_vers.vcproj
In order to open an existing Visual C++ .Net project, choose "File", "Open", and then "Project" from the Visual Studio menu. Specify the directory containing the Visual C++ .Net project files (for example, C:\MGC4C\APPS).
In order to call MGC functions from C++ .Net programs, do the following to your existing C++ .Net project:
(4) Rebuild. NOTE: If using pre-compiled headers, the include statement
#include "stdafx.h"
must be the first include statement in your program.
MarshallSoft GPS Component functions can be called from Microsoft Visual C# (C-sharp) .NET in the same manner as Win32 API functions.
All Visual C# .NET projects end with extension ".csproj". For example,
cs_vers.csproj
In order to open an existing C# .NET project, choose "File", "Open", and then "Project" from the Microsoft C# Development Environment. Specify the directory containing the C# .NET project files (for example, C:\MGC4C\APPS).
In order to call MGC functions from an existing C# .NET program, do the following to the C# .NET source code:
public class mgc : System.Windows.Forms.Form
Look at the cs_vers program in the APPS sub-directory for an example.
Borland C/C++ version 5.0 programs can be compiled from either the command line (using makefiles ending with "._b_") or from within the Borland development environment using Borland v5.0 or above.
Borland C/C++ version 5.5 (which can be downloaded from www.borland.com) is a free Win32 console mode compiler (no IDE). Makefiles for BC v5.5 end with "._i_", and (like Borland C++ Builder) use ILINK32 rather than TLINK32. Be careful with linker response files (*.RSP) -- they must NOT end with a carriage return / line feed!
Borland programs always link with MGC32BCB.LIB.
Also refer to BORLAND.TXT.
Programs can be compiled using command line makefiles. All Borland (Win32) command line makefiles end with "._b_" (or "._i_" for Borland 5.5). To compile using a makefile, use the Borland MAKE utility. For example,
MAKE -f LATLON._B_
MAKE -f LATLON._I_
Win32 Borland users re-create create MGCBCB.LIB from MGC32.DLL by running the "IMPLIB" program in the Borland compiler \BIN directory.
implib mgcbcb.lib mgc32.dll
To create a new project, first turn off LINKER case sensitivities: Choose "Options",
"Projects", "Linker", "General". Turn off the "case sensitive link" and "case sensitive
exports and imports" boxes.
Next, choose "Project", then "New Project". Use the INS (Insert) key to pop up a dialog box into which the project file names are entered.
Select "GUI" or "Console" for the "Target Model:" Only "Runtime" and "Dynamic" should be checked for "Standard Libraries:"
NOTE1: If, after linking in the IDE, you get unresolved external references to the library functions in which each function name is all upper case, then you have NOT turned off case sensitivity as described above.
NOTE2: If you get errors compiling the windows header file "WINDOWS.H", turn on "Borland Extensions" in "Options", "Project", "Compiler", "Source".
Borland Turbo C/C++ for Windows does not have command line tools, so all programs must be compiled from the Turbo C/C++ integrated environment.
Follow the same directions as above (Borland IDE), except that the "Target Model:" can be any listed.
Borland C++ Builder does not have command line tools, so all programs must be compiled from the Borland C++ Builder integrated environment. Compile the BCB example program BCB_PRJ with BCB_PRJ.MAK if running BCB version 1 through 3, and compile with BCB_PRJ.BPR if running BCB version 4 or above.
To load the BCB_PRJ example project, Choose "File" / "Open Project" on the menu bar. Load BCB_PRJ.MAK (or BCB_PRJ.BPR). Then, choose "Build All" from "Project" to create the executable.
Note that MGCBCB.LIB is the LIB file used with Borland C++ Builder. MGCBCB .LIB can be created from MGC.DLL by using the Borland IMPLIB program:
IMPLIB MGCBCB.LIB MGC.DLL
Watcom C/C++ programs can be compiled from either the command line or from within the Watcom development environment.
Watcom v10.5and v10.6 do not recognize the "declspec" keyword, and there require "legacy DLL's", which can be downloaded from www.marshallsoft.com/mgc4c.htm
Programs can be compiled using command line makefiles. All Watcom command line makefiles end with "._w_" for (Win32) makefiles. Use WCC386.EXE to compile C programs and WPP386.EXE to compile C++ programs.
To compile using a makefile, use the Watcom WMAKE utility. For example,
WMAKE -f LATLON._W_
To create a new project, choose "File", then "New Project". Enter the project name and then choose Win32 as the target. Use the INS (Insert) key to pop up a dialog box into which the project file names are entered.
Select "Options" from the main window, then "C Compiler Switches", then "10". Memory Models and Processor Switches". Check "80386 Stack based calling [-3s]", then check "32-bit Flat model [-mf]".
Lcc-Win32 C/C++ programs can be compiled from either the command line or from within the development environment.
Lcc-Win32 is a freeware C compiler developed and distributed by Jacob Navia at
http://www.cs.virginia.edu/~lcc-win32/
To use our DLL's with Lcc-Win32, you must link with MGCLCC.LIB. This file can also be re-created using the Lcc-Win32 utility BUILDLIB.
buildlib mgc.lcc mgclcc.lib
Then, compile and link as normal. For example, to compile the MGCVER example program,
lcc -DWIN32 mgcver.c
lcclnk mgcver.obj mgc.lib -subsystem:console
To compile the GUI mode example LATLON,
lcc -DWIN32 latlon.c
lrc latlon.rc
lcclnk latlon.obj mgclcc.lib latlon.res -subsystem:windows
See MGCVER$.BAT for an example of a console mode command line batch file and LATLON$.BAT for an example of a GUI mode command line batch file.
Command files are used for Lcc-Win32 rather than makefiles since the makefile that comes with LCC-Win32 does not work well (unlike the actual compiler).
The MGC32.DLL has been compiled using Microsoft Visual C/C++ and is callable from applications written using Microsoft, Borland, or Watcom compilers. If you recompile MGC.C using Borland or Watcom compilers, then the resulting MGC32.DLL can only be used by applications compiled with the same compiler, unless the "_stdcall" and "_declspec" keywords are specified.
For Microsoft C, type:
NMAKE -f MGC._M_
For Borland C, type:
MAKE -f MGC._B_
For Watcom C, type:
WMAKE -f MGC._W_
There are makefiles provided for each of the example programs. For example, to compile LATLON:
For Microsoft C, type:
NMAKE -f LATLON._M_
For Borland C, type:
MAKE -f LATLON._B_
For Watcom C, type:
WMAKE -f LATLON._W_
There is also a Microsoft Developer Studio generated makefile for LATLON. See LATLON.MAK.
The registered user can also statically link with mgc.obj and wsc32mgc.obj, rather than making calls to the DLL's. To create an application that links MGC.OBJ statically:
For an example of linking with mgc.obj and wsc32mgc.obj, see LATLONS._M_ .
If using Microsoft Developer Studio, make these changes:
Alternatively, if source code has been purchased, MGC.C and WSC32GPS.C can be edited so that they can be compiled and linked in like any other program file. In order to do this, remove all code (from MGC.C) from
#ifndef STATIC_LIBRARY
to the matching
#endif
Many of the example programs are written in Win32 console mode. This was done in order to provide the clearest possible code, without the complication and complexity of GUI code. All console mode programs can be converted to GUI mode by adding the necessary Windows interface code. Example programs are located in the \APPS sub-directory created by SETUP.
Makefiles are classified as follows:
The first example program is the GUI program MGCVER (MGC Version) which displays the MGC library version number and registration string.
There are command line makefiles for Microsoft (MGCVER32._M_), Borland (MGCVER32._B_), and Watcom (MGCVER32._W_), as well as a Microsoft Developer Studio makefile (MGCVER32.MAK), and an Lcc-Win32 command file (LATLON32.BAT).
After compiling, from the command line, type:
MGCVER
The HELLO example program is similar to MGCVER except that it is written in C++ and uses the MGC class fMGC. See fmgc.cpp and fmgc.h.
COMPUTE is a console mode program that computes great circle distances and bearings from a pair of latitude/longitude values.
CONVERT is a console mode program that coverts latitude (or longitude) between (deg, min, min/1000), (deg, min, sec), and single integer encoding.
GPGGA is a console mode program that displays all NMEA GPGGA sentences.
GPGLL is a console mode program that displays all NMEA GPGLL sentences.
GPGSV is a console mode program that displays all NMEA GPGSV sentences.
GPRMC is a console mode program that displays all NMEA GPRMC sentences.
GPVTG is a console mode program that displays all NMEA GPVTG sentences.
GGA_RMC is a console mode program that displays all NMEA GPGGA and GPRMC sentences.
LATLON is a GUI mode example program that continuously displays latitude and longitude.
RAW is a console mode program that displays all NMEA sentences.
The BCB_PRJ project is a Borland C++ Builder (BCB) version of the LATLON example program. Load BCB_PRJ.MAK for BCB version_1.0 and BCB_PRJ.BPR for later version of BCB.
MFC_PGM is a Microsoft Foundations Class (MFC) version of the LATLON example program. Load MFC_PGM.MAK
The VC_VERS example program is the Visual C++ .NET equivalent of the MGCVER program.
The VC_GGA example program is the Visual C++ .NET equivalent of the GPGGA program.
The CS_VERS example program is the Visual C# .NET equivalent of the MGCVER program.
The CS_LATLON example program is the Visual C# .NET equivalent of the LATLON program.
The VC_LATLON example program is the Visual C++ .NET equivalent of the LATLON program.
The CALLBACK example console mode program demonstrates the use of the mgcCallback function.
The LoadLib example program demonstrates how to load MGC32.DLL from a specified directory.
Version 1.0: January 2, 2002.
Version 1.1: March 14, 2002.
Version 1.2: February 4, 2003
Version 1.3: August 9, 2004
Version 1.4: March 3, 2005
Version 2.0: June 22, 2007
The "Coded Integer" angles returned by MGC functions are now returned in units of hundred-thousandths of a degree rather than thousandths of a minute.