Files
epics-base/documentation
Marty Kraimer 3cece37c92 add new notes
2003-11-06 17:11:02 +00:00
..
2003-11-06 17:11:02 +00:00
2003-09-23 16:15:08 +00:00
2003-04-23 15:41:26 +00:00
2003-09-03 14:19:11 +00:00
2003-09-23 16:15:08 +00:00
2002-07-17 01:41:24 +00:00
2002-07-16 20:36:07 +00:00
2003-08-05 19:02:25 +00:00

Compiling EPICS and Building IOC Applications on win32-x86 (Windows95/NT) 
---------------------------------------------------------------------

Original port of EPICS base build system to WIN32 (Windows95/NT)
was done by Kay-Uwe Kasemir 11/96

please mail questions, comments, corrections, additional examples, etc 
	to johill@lanl.gov

0) what you will get
--------------------

Right now this port of EPICS to win32-x86 should allow you to

* compile all of EPICS base using {Tornado, MS Visual C, perl,
  GNU make} (only {MS Visual C, perl, GNU make} if you prefer
  to compile only the host portions of EPICS base).
* load EPICS on an IOC (486, pentium, 68k, ...),
  load databases
  (no drivers/devices for real I/O available, yet.
   Some Greenspring IP support [Relay, Dig, ADC, DAC] is in progress)
* build and use ca.dll on NT or Win95 to access all IOCs,
  as well as the Com-library, gdd-library, cas-library,
  and all other EPICS base libraries as DLLs.
* build gdd, cas and a demo of the new portable CA server on win32-x86.

To build only for win32-x86 and not cross compile for IOC development type 
"make win32-x86" or in your configure/CONFIG_SITE file set 
"CROSS_COMPILER_HOST_ARCHS="

1) see what you have
--------------------

To compile EPICS on win32-x86, we need

	WindRiver System's Tornado (used: 1.0)  (not required if host only build)
	Microsoft's Visual C/C++   (used: 6.0)  (borland C++ rumored to work also)

and some tools:

	gnu make - www.gnu.org (we used 3.76)
	perl - www.perl.org (we used 5.003)

The perl interpreter and gnu make are available 'on the net'
as sources which compile with MS Visual C++.
If you cannot/don't want to find them, contact me, please!

2) set environment variables

(Setting env. vars. is different: for NT, use Settings/System,
for Win95 use autoexec.bat)

When setting paths in the EPICS CONFIG files for win32-x86 the following
are hints in case you have trouble. You should not need to worry about 
this unless you type a path into one of the EPICS config files that 
includes a "\". In most situations gnu make, windows NT, the MS compiler,
and the MS linker will accept "/" and this will result in less trouble.

	** Note that that each "\" in any path variables you set
		must be replaced with a "\\" (this is because GNU make treats
		all "\" characters as line continuation)

	** Note that that each space in any file name or 
        path name variable you set must be replaced with 
        a "\ " (this is because GNU make treats all " " separated
        input as independent tokens in the input stream.

	** win32-x86 will generally allow "/" and "\" interchangeably in file paths,
		but the DOS shell only accepts "\".

    ** Certain command line utilities such as the MS linker are known to in rare
        situations confuse "/" in a path with command line options, and it may
        be necessary to replace a "/" in a path that configured with "\\", but
        the bulk of our experience indicates that this is not the necessary.

Your path should include:
- The EPICS-binaries that we are about to build in <EPICS>base/bin/win32-x86
- The System (for me it's in NT40...)
- The MS Visual C compiler binaries

Check with e.g.:

>echo %Path%
C:\WINNT35.0\system32;
C:\WINNT35.0;
c:\msdev\bin;
c:\perl5\bin;
c:\make-3.75\WinRel;
c:\epics\base\bin\win32 (really where INSTALL_LOCATION specifies)

On NT, "Path" is defined by the operating system, on Win95, it's "PATH" instead.

MS Visual C and Tornado should be installed properly with
these env. variables set:

WIND_BASE=c:\Tornado		(required for cross development only)
WIND_HOST_TYPE=x86-win32	(required for cross development only)

This way the EPICS makesystem can locate Tornado 
without any changes to the files in base/config.
So for pc486 the settings in CONFIG_SITE where
you specify the location of VxWorks are ignored,
this information is taken from WIND_BASE and _HOST_TYPE!!

MSDevDir=C:\MSDEV
include=c:\msdev\include;c:\msdev\mfc\include
lib=c:\msdev\lib;c:\msdev\mfc\lib

Select host arch to build:
EPICS_HOST_ARCH=win32-x86			(used by the make system)

Set the "TMP" environment variable if you need to specify where 
temporary files are created.

Directory Used For Temporary Files   Conditions
----------------------------------   ----------
Directory specified by TMP           TMP environment variable is set, 
                                     and directory specified by TMP exists.	
dir argument to _tempnam             TMP environment variable is not set, or 
                                     directory specified by TMP does not exist.	
P_tmpdir in STDIO.H                  dir argument is NULL, or dir is name of 
                                     nonexistent directory.	
Current working directory            P_tmpdir does not exist.	

On my system I see in stdio.h that _P_tmpdir is "/". Here is a common
setting for "TMP" (the C:\TEMP directory must exist).

TMP=C:\TEMP

3) building EPICS
-----------------

Prepare apx. 2 ltr. Tee and type:

	cd <epics>/base
	make 			(use gnu make)

Watch for errors and send them to me.

Known problems:
* gnumake seems to be faster than win32-x86 sometimes
  which results in warnings/errors like
  "file has modification date in the future"
  for newly created things.
  Very seldom this is fatal, so you have to
  stop gnumake and restart it.
* This is strange because Windows95/NT doesn't care
  about upper/lower case:
  WIN32 is WIN32, not win32. Gnumake fails
  if e.g. base/src/include/os/WIN32 is ...win32.

4) Creating EPICS IOC applications under win32-x86

o create application development folder
	
o start a DOS window and change your working directory to the folder
	created above (with the DOS "cd" command)

o to create an example application type:
	"perl c:\epics\bin\win32\makeBaseApp.pl -b c:\\epics -e

	** Note that that each "\" above in any path arguments to makeBaseApp.pl
		must be replaced with a "\\" (this is because GNU make treats
		all "\" characters as line continuation)

	** Note that that each space in any file name or 
        path name argument to makeBaseApp.pl must be replaced with 
        a "\ " (this is because GNU make treats all " " separated
        input as independent tokens in the input stream.

	** Note that c:\epics above must be replaced by the path
		to your epics source installation (or where INSTALL_LOCATION 
		specifies)

o General information on EPICS IOC application development can be found in
	the "EPICS IOC Application Developers Guide". To see all of the options 
	supported by makeBaseApp.pl type "perl c:\epics\bin\win32\makeBaseApp.pl"

5) EPICS GNU make makefiles can be executed from within a Visual C++ "makefile"
style project. This allows EPICS programs to be developed directly inside of
the visual C++ environment. To do this create a "makefile" project and place your 
gnu make command in the build configuration (accessed from the project/settings menu). 
You will also need to add GNU make and <EPICS>/bin/win32 into the Visual C++ 
executable search path (from the tools/options menu). 
In visual C++ it is possible to double click on the compiler 
error messages generated within an EPICS "makefile" style project and have visual 
C++ immediately position the cursor on the corresponding line in the source. I
have found that this works correctly with Makefile projects if the project is in a 
directory just below the source code. The following build command works well
in a visual C++ make file project: "kill caRepeater.exe&make -C ..". Be careful 
not to introduce additional spaces around the &. The kill.exe command is in the
NT resource kit.

6) Issues that you should be aware of if you are building code that 
calls EPICS, but you are not using the EPICS build system.

6a) You will need to include header files from the following paths.
    <epics>\base\include
    <epics>\base\include\os\win32
6b) You will need to link with the following path in effect.
    <epics>\base\lib\win32-x86. 
6c) If the visual C++ /Za option is not used then you will also need to define 
    __STDC__ to be zero on the command line so that EPICS headers will know that
    a ANSI standard C compiler is in use. 
6d) If you link with EPICS object libraries then specify /MT or /MTd
    depending on whether EPICS base and your code are built for debugging. 
    This specifies the multithreaded operating environment required by EPICS.
    This will also not define _DLL and therefore the EPICS header files will
    not specify that sharable libraries are being called. EPICS object library 
    names follow the convention "xxxObj.lib".
6e) If you link with EPICS shareable libraries (with DLLs) then you must 
    use /MDd or /MD depending on whether EPICS base and your code are 
    built for debugging. This specifies the multithreaded operating environment 
    required by EPICS. This will also define _DLL and therefore the EPICS header 
    files will specify an optimized calling convention for shareable libraries. 
    EPICS shareable libraries (DLL) names follow the convention "xxx.lib"
    and "xxx.dll".