HP Visualize J5000 hp workstations - hp-ux 10.20 graphics administration guide - Page 15

Examples, Compiling HP-PHIGS Applications, Compiling with Shared Libraries

Page 15 highlights

By default, the linker program ld(1) looks for a shared library driver first and then the archive library driver if a shared library was not found. By using "-Wl,-a,archive" (or exporting the LDOPTS variable), the -l option will refer only to archive drivers. Because the archive library libhpgfx1.a references functionality in libXext.a, it is necessary to explicitly link libXext.a with your program. Otherwise, the linker will have undefined references. Examples Assuming you are using ksh(1), to compile and link a C program for use with this driver, use the forms below. The "-l:libdld.sl" below specifies the dynamic loader, which is available only in shared-library form. cc example.c -I -Wl,-a,archive -L -L \ -ldd -lXwindow lhpgfx1 -lhpgfx2 -lXhp11 \ -lXext -lX11 -Wl,-E -Wl,+n -l:libdld.sl -lm -o example For FORTRAN, use: fort77 example.f -I -Wl,-a,archive -L \ -L-ldd lXwindow -lhpgfx1 -lhpgfx2 \ -lXhp11 -lXext -lX11 -Wl,-E -Wl,+n -l:libdld.sl -lm \ -o example For Pascal, use: pc example.p -I -Wl,-a,archive -Wl,-L \ -Wl,-L -ldd lXwindow -lhpgfx1 \ -lhpgfx2 -lXhp11 -lXext -lX11 -Wl,-E -Wl,+n \ -l:libdld.sl -lm -o example Compiling HP-PHIGS Applications Compiling with Shared Libraries If you are using shared libraries, as we recommend, linking is device-independent. To compile a C program using shared libraries, you would use the following command: cc example.c -I -L/lib -L \-I/Motif1.2_R6 lXwindow -lphigs -ldl \ -lhpgfx -ldld -lXhp11 -lXi -lXext -lX11 -lm -o example FORTRAN users can simply replace cc with fort77 in the above command. Also, if you are a FORTRAN user and prefer using the f77 command, you can replace cc with f77 and change linking options that are specified as follows: -L to -Wl,-L For more information on compiling and linking, read the section "PHIGS PLUS Differences Between HP-PHIGS 2.2/2.3 and 3.0" in the chapter "Functional Overview" in the HP-PHIGS Graphics Techniques manual. Page 15 Graphics Administration Guide for HP-UX 10.20

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171

By default, the linker program ld(1) looks for a shared library driver first and then the archive library
driver if a shared library was not found. By using "-Wl,-a,archive" (or exporting the LDOPTS variable),
the -l option will refer only to archive drivers.
Because the archive library libhpgfx1.a references functionality in
libXext.a
, it is necessary to explicitly
link
libXext.a
with your program. Otherwise, the linker will have undefined references.
Examples
Assuming you are using ksh(1), to compile and link a C program for use with this driver, use the forms
below.
The "-l:libdld.sl" below specifies the dynamic loader, which is available only in shared-library form.
cc example.c –I<sb-incl> -Wl,-a,archive –L<common> -L<sb-lib> \ -ldd<device_driver> -lXwindow -
lhpgfx1 -lhpgfx2 -lXhp11 \ -lXext -lX11 -Wl,-E -Wl,+n -l:libdld.sl -lm -o example
For FORTRAN, use:
fort77 example.f –I<sb-incl> -Wl,-a,archive –L<common> \ -L<sb-lib>-ldd<device_driver> -
lXwindow -lhpgfx1 -lhpgfx2 \ -lXhp11 -lXext -lX11 -Wl,-E -Wl,+n -l:libdld.sl -lm \ -o example
For Pascal, use:
pc example.p –I<sb-incl> -Wl,-a,archive -Wl,-L<common> \ -Wl,-L<sb-lib> -ldd<device_driver> -
lXwindow -lhpgfx1 \ -lhpgfx2 -lXhp11 -lXext -lX11 -Wl,-E -Wl,+n \ -l:libdld.sl -lm -o example
Compiling HP-PHIGS Applications
Compiling with Shared Libraries
If you are using shared libraries, as we recommend, linking is device-independent. To compile a C
program using shared libraries, you would use the following command:
cc example.c –I<phigs-incl> -L<common>/lib –L<phigs-lib> \-I<phigs-widget>/Motif1.2_R6 -
lXwindow -lphigs -ldl \ -lhpgfx -ldld -lXhp11 -lXi -lXext -lX11 -lm -o example
FORTRAN users can simply replace cc with fort77 in the above command. Also, if you are a
FORTRAN user and prefer using the f77 command, you can replace cc with f77 and change linking
options that are specified as follows:
-L<pathname>
to
-Wl,-L<pathname>
For more information on compiling and linking, read the section "PHIGS PLUS Differences Between
HP-PHIGS 2.2/2.3 and 3.0" in the chapter "Functional Overview" in the HP-PHIGS Graphics
Techniques manual.
Graphics Administration Guide for HP-UX 10.20
Page 15