
Step-by-step build instructions for Windows (gcc/MinGW environment).
contact j.chamberlain at opendap.org for additional help

Introduction:

If you are programming in Windows you can use the DLL provided with no build requirements at all. You may want to build the OCAPI from scratch either to avoid having to redistribute this DLL or perhaps because you need to make a change in the functionality. In any case there is a dependency on the cURL DLL that you may to distribute anyway.

The OCAPI was developed under Windows using a MinGW Unix environment along with Eclipse as an IDE. This methodology was done to be able to use gcc to ensure that the Windows and Unix builds were as similar as possible. The source files can be built using any C compiler since they are all pure C with no C++ or other alien constructs. The Windows API references are minimal and are confined to the Interactive sub project which is an optional component.

The instructions below describe in detail how to setup a MinGW/MSys environment and build the OCAPI from scratch.

1. Choose a base location for your unix/gcc environment

- The folder path should not have a space in it
- example: D:\dev\unixenv

2. Install MSYS

- Go to the MinGW SourceForge page (currently at: http://sourceforge.net/project/showfiles.php?group_id=2435)
- Find and download the current MSys binary (currently MSYS-1.0.11-2004.04.30-1.exe)
- Run exe and install into your base folder created in step 1
- you should now have a folder "msys" in your base folder

3. Add the MSYS bin folder to your path

- Your MSYS bin folder will be [base folder]\msys\1.0\bin (assuming you are using version 1.0)
- Go to Settings, Control Panel, System, Advanced tab, Environment Variables
- One of your System variables should be "Path"
- Edit the path variable by adding a semicolon followed by your MSYS bin folder at the end

4. Test that 'make' is now functional on your system

- open a new command window (Start / Run... / "cmd")
- give the command "make"
- make should run, give an error ("no targets specified"), and exit

5. Make a folder named MinGW in your base folder

6. Install the gcc core to the MinGW folder you created in step 5

- Go to the MinGW SourceForge page (currently at: http://sourceforge.net/project/showfiles.php?group_id=2435)
- Download the i386 gcc binary core (currently called "gcc-core-3.4.2-20040916-1.tar.gz)
- either use command line tools from MSYS or a program like WinZip to unzip and untar
- if you use WinZip turn off the automatic CR/LF conversion
- Preserve the paths in the tar file and install to the folder created in step 5

7. Add the bin [base directory]\MinGW\bin directory to your path as in step 3

8. Download the MinGW runtime and install to your [base directory]\MingGW directory

- this runtime contains the system headers like stdio.h
- the headers are placed in a folder called "include" under your MinGW directory

9. Download and install the MinGW binutils package to your [base directory]\MinGW directory

- this file is currently called binutils-2.16.91-20060119-1.tar.gz
- it contains the assembler binary gcc needs which is called "as"

10. Download and install the MinGW WinAPI package to your [base directory]\MinGW directory

- this file is currently called w32api-3.5.tar.gz
- it contains winsock headers which are needed by cURL to do ip communications

11. Download and install the MinGW gdb package to your [base directory]\MinGW directory

- this file is currently called gdb-6.3-2.exe (or unzip the tar)
- it allows you to debug an executable

12. Download and install the i386 setups for Flex and Bison from the GnuWin32 project on Sourceforge.

- flex is required to generate the lexical scanner for the ocapi
- bison is required to generate the parser for the ocapi; it uses the scanner generated by flex
- GnuWin32 can be found currently at: http://sourceforge.net/projects/gnuwin32

13. Add the GnuWin32 bin folder created in step 12 to your path

14. Build the OCAPI's scanner from dds.lex file

- open a command console (Start, run, cmd)
- change directory to your OCAPI source directory (where the dds.lex file is located)
- give the command "flex dds.lex", the file dds.lex.c should have been created
- this needs to be done in the future only if the file dds.lex changes

15. Build the OCAPI's parser from dds.y file

- open a command console (Start, run, cmd)
- change directory to your OCAPI source directory (where the dds.y file is located)
- give the command "bison -d --debug --name-prefix=dds dds.y", the files dds.tab.c and dds.tab.h should have been created
- the debug option is necessary to generate a debugging symbol referenced in the OCAPI source code
- the prefix changer option "--name-prefix=dds" is necessary because the lexer uses symbols with a "dds" prefix
- this needs to be done in the future only if the file dds.y changes

16. If you have dependencies or object files present, run 'make clean'

- check the [OCAPI]\win32 directory, if there are .o or .d files there you should clean the directory
- open up a console window (Start / Run... / "cmd")
- change directory to [OCAPI]\win32
- give the command: make clean

17. Run the makefile in the win32 folder

- open up a console window (Start / Run... / "cmd")
- change directory to [OCAPI]\win32
- give the command: make
- the project should build Ocapi.exe and Ocapi.dll with no errors or warnings

18. Add the folder containing libcurl-3.dll to your path or program directory

- the OCAPI depends on the libcurl-3.dll to run in a windows environment
- the file is usually located in the [OCAPI]\win32\curl_7.12.1\lib directory
- you can add the file to the exe directory to avoid putting it in your path

19. Add the folder containing pthreadGC2.dll to your path or program directory

- the OCAPI depends on the pthreadGC2.dll to run in a windows environment
- the file is usually located in the [OCAPI]\win32\pthreads-win32\lib directory
- you can add the file to the exe directory to avoid putting it in your path


--------------------------------------------------------------------
Notes for Eclipse
--------------------------------------------------------------------

If you are using Eclipse to build the OCAPI there are several things to watch for in setting up your environment all of which can be accessed from the Project Properties dialog:

- select the project from the project pane
- activate the Project Properties dialog
- in Make Project settings customize the make command to point to the win32 subdirectory: 
	EXAMPLE: make -f D:\work\OPeNDAP\src\OCAPI\win32\makefile
- the build directory in the Make Project tab must be set to the win32 directory
- on the Binary Parser tab the PE parsers should be selected

