32
1 SASC/C++ Cross-Platform Software SAS Institute Inc.

SASC/C++ Cross-Platform Software

  • Upload
    floria

  • View
    36

  • Download
    0

Embed Size (px)

DESCRIPTION

SASC/C++ Cross-Platform Software. SAS Institute Inc. Introduction. The tutorial is designed to help you implement the sascc370 driver in either the MS-DOS shell or the Microsoft Visual C++ IDE, not to replace the online Help. - PowerPoint PPT Presentation

Citation preview

Page 1: SASC/C++ Cross-Platform Software

1

SASC/C++ Cross-Platform Software

SAS Institute Inc.

Page 2: SASC/C++ Cross-Platform Software

2

Introduction• The tutorial is designed to help you implement the

sascc370 driver in either the MS-DOS shell or the Microsoft Visual C++ IDE, not to replace the online Help.

• Please read the online Help for detailed topical information on all aspects of the SAS/C Cross-Platform Software.

Page 3: SASC/C++ Cross-Platform Software

3

Topics Covered• Implementing the SASC/C++ driver in an MS-

DOS shell.• Implementing the SASC/C++ driver in the

Microsoft Visual C++ IDE.

Page 4: SASC/C++ Cross-Platform Software

4

Topic OneThe sascc370 compiler driver controls the compilation of your C and C++ source code. Invoke the compiler at the DOS prompt with the following command:

C:\> sascc370 [options] [filename1 [filename2…]]

If specified, the options argument can be one or more of the compiler options described in the SAS/C Cross-Platform Compiler and SAS/C Cross-Platform C++ Development System Usage and Reference guide in Chapter 3, Compiling C and C++ Programs, or the cool options described in Chapter 6, Pre-Linking C and C++ Programs. Some of the compiler options (e.g., -v) are particular to the sascc370 driver, whereas others alter the compilation phases in some manner. The compiler driver processes these options during the phases of compilation, passing them to the appropriate executable file as necessary. If you do not specify any options, the cross-platform compiler will generate pre-linked, non-reentrant code by default. Pre-linking is accomplished by cool, which is normally invoked by the compiler driver.

Page 5: SASC/C++ Cross-Platform Software

5

Command-line invocation of SAS/C

An example showing the sascc370 driver executed within an MS-DOS shell at the command-line, with and without the verbose option -v. The -v returns detailed messages during the compilation.

You can also set up batch files to execute SAS/C in MS-DOS

Page 6: SASC/C++ Cross-Platform Software

6

Batch Files

Compiling C/C++ Source Code

The sample compile batch file on the next slide accepts a .c file and compiles the code to produce only an object deck ( -c ), allowing reentrant modification of static and external data ( -Krent ), and defining a section name as the source code filename ( -Ksname ). The –v option specifies that both driver messages and the command lines that execute each phase of the cross-platform compiler are echoed to the %LOG% file. If the source file is not in the current working directory, the quoted, qualified pathname should be entered as the second command-line argument.

Page 7: SASC/C++ Cross-Platform Software

7

Batch Files

set NAME=%1

set PATHNAME=

if NOT ‘%2’ == ‘’ set PATHNAME=%2\

set SOURCE=%PATHNAME%%NAME%.c

set OBJECT=%NAME%.obj

set LOG=%NAME%.clg

set C_OPTS=-c –v –Krent –Ksname=%NAME%

erase %LOG%

erase %OBJECT%

sascc370 %C_OPTS% %SOURCE% -o %OBJECT% > %LOG%

echo done with %NAME%

The correct syntax to invoke this sample compile.bat file would be:

C:\compile sourcename [pathname]

For example, to compile the file d:\program files\sasc\samples\c\ftoc.c and produce ftoc.obj in the current working directory, the command line invocation would be:

C:\compile ftoc “d:\program files\sasc\samples\c”

Where ftoc on the command line is the source code filename without an extension.

Page 8: SASC/C++ Cross-Platform Software

8

Batch Files

Pre-Linking Object Code

The sample pre-link batch file on the next slide accepts as input the previously compiled object code filename (without the .o extension ) and produces pre-linked output from cool. The –v option specifies that any driver messages, and the command lines that execute cool, are echoed to the %LOG% file. If the object file is not in the current working directory, the quoted, qualified pathname should be entered as the second command-line argument.

Page 9: SASC/C++ Cross-Platform Software

9

Batch Files

set NAME=%1

set PATHNAME=

if NOT ‘%2’ == ‘’ set PATHNAME=%2\

set OBJECT=%PATHNAME%%NAME%.obj

set OUTPUT=%NAME%

set LOG=%NAME%.llg

set L_OPTS=-v

erase %LOG%

erase %OUTPUT%

sascc370 %L_OPTS% %OBJECT% -o %OUTPUT% > %LOG%

echo done with %NAME%

The correct syntax to invoke this sample link.bat file would be:

C:\link objectname [pathname]

For example, to pre-link the object file ftoc.obj and generate ftoc, the command line invocation would be:

C:\link ftoc

Where ftoc on the command line is the object code filename without the .obj

extension.

Page 10: SASC/C++ Cross-Platform Software

10

Batch Files

Building Source Code

To compile and then pre-link source code in one step, you could execute the batch file on the next slide. The sascc370 driver would execute the SAS/C C and C++ Cross-Platform Compiler and then produce pre-linked output generated by cool. In this example, the compiler options specify reentrant code, extended names processing ( -Kextname ), a section name, run-time type identification ( -Krtti ), and automatic instantiation of class templates ( -Kautoinst ). A quoted include pathname is added for user-defined header files. The command line that executes each phase of the cross-platform compiler is displayed in the %LOG% file.

Page 11: SASC/C++ Cross-Platform Software

11

Batch Files

REM Assumes a C++ source file with .cxx extension

set NAME=%1

set PATHNAME=

if NOT ‘%2’ == ‘’ set PATHNAME=%2\

set SOURCE=%PATHNAME%%NAME%.cxx

set OUTPUT=%NAME%

set LOG=%NAME%.log

set BLD_OPTS=-v –Krent –Kextname –Ksname=%NAME% -Krtti –Kautoinst

set INCL= -I“d:\program files\sasc\samples\h”

erase %LOG%

erase %OUTPUT%

sascc370 %BLD_OPTS% %INCL% %SOURCE% -o %OUTPUT% > %LOG%

echo done with %NAME%

The correct syntax to invoke this sample build.bat file is: C:\build sourcename [pathname]

For example, to compile and pre-link the file d:\program files\sasc\samples\cxx\tsttmpl.cxx,

the command line invocation would be: C:\build tsttmpl “d:\program files\sasc\samples\cxx”

Where tsttmpl on the command line is the C++ source code filename without the .cxx

extension. The compiler will generate the object file, tsttmpl.obj.

Page 12: SASC/C++ Cross-Platform Software

12

NMAKE and make files

MS-DOS and Microsoft Visual C++ IDE can be bridged by a MAKE file ...

The Microsoft IDE automatically generates a MAKE file with extension .mak during the building of a project and all sub-projects. You can also export a current MAKE file within the IDE by selecting the Project pulldown menu and then choosing the Export Makefile… option.

By editing the .mak file associated with your project, you can determine the execution process by which the Microsoft IDE builds the project configuration. By invoking NMAKE from within the MS-DOS shell, the appropriate .mak file can be executed accordingly.

In addition, you can select the Project pulldown menu and select Settings… Then under the Post-build step tab you can enter the nmake command. (Microsoft Visual C++ Version 5.0 only)

Page 13: SASC/C++ Cross-Platform Software

13

NMAKE and make filesFollowing is an example .mak file generated by the Microsoft IDE:

# Microsoft Developer Studio Generated NMAKE File, Based on ftoc.dsp

!IF "$(CFG)" == ""

FG=ftoc - Win32 Release

!MESSAGE No configuration specified. Defaulting to ftoc - Win32 Release.

!ENDIF

!IF "$(CFG)" != "ftoc - Win32 Release" && "$(CFG)" != "ftoc - Win32 Debug"

!MESSAGE Invalid configuration "$(CFG)" specified.

!MESSAGE You can specify a configuration when running NMAKE

!MESSAGE by defining the macro CFG on the command line. For example:

!MESSAGE NMAKE /f "ftoc.mak" CFG="ftoc - Win32 Debug”

!MESSAGE Possible choices for configuration are:

!MESSAGE "ftoc - Win32 Release" (based on "Win32 (x86) Console Application")

!MESSAGE "ftoc - Win32 Debug" (based on "Win32 (x86) Console Application")

!ERROR An invalid configuration is specified.

ENDIF

Page 14: SASC/C++ Cross-Platform Software

14

NMAKE and make files!IF "$(OS)" == "Windows_NT"

ULL=

!ELSE

NULL=nul

!ENDIF

!IF "$(CFG)" == "ftoc - Win32 Release"

OUTDIR=.

INTDIR=.

!IF "$(RECURSE)" == "0"

ALL : ".\ftoc.out"

!ELSE

ALL : ".\ftoc.out"

!ENDIF

CLEAN :

-@erase "$(INTDIR)\ftoc.obj"

-@erase ".\ftoc.out"

"$(OUTDIR)" :

Page 15: SASC/C++ Cross-Platform Software

15

NMAKE and make filesif not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"

CPP=c:\keith\host\wnt\bin\sascl.exe

CPP_PROJ=/ML /Fo"$(INTDIR)\\" -v

CPP_OBJS=./

CPP_SBRS=.

.c{$(CPP_OBJS)}.obj::

$(CPP) @<<

$(CPP_PROJ) $<

<<

.cpp{$(CPP_OBJS)}.o::

$(CPP) @<<

$(CPP_PROJ) $<

<<

.cxx{$(CPP_OBJS)}.obj::

$(CPP) @<<

$(CPP_PROJ) $<

Page 16: SASC/C++ Cross-Platform Software

16

NMAKE and make filesRSC=rc.exe

BSC32=bscmake.exe

BSC32_FLAGS=/nologo /o"$(OUTDIR)\ftoc.bsc"

BSC32_SBRS= \

LINK32=c:\keith\host\wnt\bin\slink.exe

LINK32_FLAGS=ftoc.obj /incremental:no /pdb:"$(OUTDIR)\ftoc.pdb" /machine:IX86\

/out:"ftoc.out" -Tcms370 -v

LINK32_OBJS= \

"$(INTDIR)\ftoc.obj"

".\ftoc.out" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)

$(LINK32) @<<

$(LINK32_FLAGS) $(LINK32_OBJS)

!ELSEIF "$(CFG)" == "ftoc - Win32 Debug”

!ENDIF

Page 17: SASC/C++ Cross-Platform Software

17

Topic TwoIn order to execute the SAS/C Cross-Platform software from within the Microsoft Visual C++ Integrated Development Environment it is necessary to have integrated the software into the Registry during the installation process. If you are unsure, type the following in an MS-DOS shell:

C:\sashelp.hlp

This opens the online Help. Select the article “Updating the Registry after Installation” under the “Installation” topic. This process updates the Registry so that you are able to execute the sascc370 driver from within the IDE.

Currently only Versions 4.2 and 5.0 of the Microsoft Visual C++ IDE are supported.

Page 18: SASC/C++ Cross-Platform Software

18

Layout#.reg file

• Open a Regedit session– Start | Run | Regedit

• Open Registry pulldown menu item

• Select Import Registry File… and Browse to the “layout#.reg” file in the installed SAS/C software host\wnt\bin directory where # is either 50 or 60, reflecting the version of the Microsoft Visual C++ IDE installed on your PC.

Page 19: SASC/C++ Cross-Platform Software

19

sascc370 in MSVC++ After the installation of the SASC/C++ Cross-Platform software with Microsoft integration, the Registry is updated, enabling additional Menu Bar options in the Microsoft Visual C++ Integrated Development Environment.

These Menu Bar changes are:

Compiler OptionsSAS/C Help Filesunder three menus on the Toolbar

SAS/C

Help

Tools

1

2

3

MSVC++ Version 4.2 option 3 onlyMSVC++ Versions 5.0 and 6.0 All three options

Page 20: SASC/C++ Cross-Platform Software

20

Compiler Options Dialog Box

This dialog is accessed on the Menu Bar by opening the SAS/C menu and the Compiler options item. The online help files and tutorial are available. You can create a diagnostic file for Technical Support and force cool to call the libcxx.a archive.

Page 21: SASC/C++ Cross-Platform Software

21

Compiler Options dialog Box

Dialog box online Help and PowerPoint tutorial

The Compiler Options dialog box offers the user a choice between implementing the sascc370 compiler driver, generating a pre-linked output file, and the Microsoft compiler and linker.

A comprehensive diagnostic log file for use by SAS Institute Inc. Technical Support can be generated. You can force the utility cool to call the archive libcxx.a in theevent that a project containing both C and C++ source files fails to do so.

Page 22: SASC/C++ Cross-Platform Software

22

SAS/C Help Dialog Box

The SAS/C Help dialog box accesses a comprehensive suite of online help files arranged into a logical library of books. You can find the appropriate subject matter by selecting a Contents tab, an alphabetically arranged Index tab or by typing in the first few letters of a subject in the Find tab. For easy navigation, there are helpful links between the topics. All pages may be printed.

Page 23: SASC/C++ Cross-Platform Software

23

SAS/C Help Dialog Box

• This dialog is accessed on the Menu Bar, by opening the SAS/C menu and the SAS/C Help Files item.

Page 24: SASC/C++ Cross-Platform Software

24

sascc370 IDE project options

• In the Project Settings dialog box, select the General tab and delete the Microsoft entries in the Output directories text boxes.

• Under the C/C++ tab select General in the Category drop-down menu, and delete all the Microsoft Project Options.

• Enter any sascc370 compiler options in the Project Options text box.

• Under the C/C++ tab select Preprocessor in the Category drop-down menu, and enter any additional include directories and preprocessor definitions.

• Under the Link tab select General in the Category drop-down menu, and delete all the Microsoft Project Options.

• Enter any sascc370 pre-linker options in the Project Options text box. Only options intended for the pre-linker cool are to be placed here.

• The Post-build tab allows you to enter any applications that you wish to run after the build process, such as ftp_mvs.bat to transfer files to the mainframe.

Page 25: SASC/C++ Cross-Platform Software

25

sascc370 in MSVC++

It is necessary to delete both entries in the Output directories text boxes.

Page 26: SASC/C++ Cross-Platform Software

26

Project level settings for C/C++

• After deleting ALL the Microsoft Project Options, you enter the sascc370 compiler options that are applicable at the project level.

Page 27: SASC/C++ Cross-Platform Software

27

Project level settings for Link

• After deleting ALL the Microsoft Project Options, you enter the sascc370 pre-linker (cool) options that are applicable at the project level.

Page 28: SASC/C++ Cross-Platform Software

28

sascc370 IDE source file options

• For each source file in the Settings For text box in the Project Settings dialog box, you can set options at the source file level:

– Select the C/C++ tab and General from the Category drop-down menu, and enter any preprocessor definitions.

– Select Preprocessor from the Category drop-down menu, and enter any additional include directories.

– In the Undefined symbols text box you enter any sascc370 options for the compiler that are to be allocated to the selected source file. These driver options are not defined by the Microsoft IDE, and are only applicable to sascc370. A /U will prefix any options entered in this area when viewed in the Source File Options text box. The sascc370 driver ignores the /U, and passes any associated options to the appropriate phases of compilation.

The next two slides show an example defining source file level options for ftoc.cpp. Note the additional options in the Source File Options text box.

Page 29: SASC/C++ Cross-Platform Software

29

sascc370 IDE source file options

Note that all section names greater than seven characters are truncated; hence “thisisa” would be the section name assigned to the file ftoc.cpp

Page 30: SASC/C++ Cross-Platform Software

30

sascc370 IDE source file options

• You can enter any compiler options that are pertinent to particular source files, such as -Ksname, in Undefined symbols. Such options are not defined by Microsoft.

Page 31: SASC/C++ Cross-Platform Software

31

Executing an FTP batch file

• You can execute a post-build application, such as the process of transferring files to the mainframe for final linking and load module generation. Only available in Versions 5.0 and 6.0 of the Microsoft Visual C++ IDE.

Page 32: SASC/C++ Cross-Platform Software

32

Uninstall Process

There are two major steps to uninstalling the SAS/C product:

– Execute the appropriate

“uninstall#.exe” file if the software was integrated into the Microsoft IDE PRIOR to the next step.

(# = 42, 50 or 60)

– Start | Settings | Control Panel | Add/Remove Programs and select the SASC 6.50.03 software.