This repository has been archived by the owner on Feb 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
README.win
211 lines (147 loc) · 8.26 KB
/
README.win
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
Instructions on building and using CFITSIO on Windows platforms
for C programmers using Microsoft Visual Studio or Borland C++.
These instructions for building the CFITSIO library under Windows use
the CMake build system that is available from http://www.cmake.org.
===============================================================================
1. Build the CFITSIO dll library
a. If CMAKE is not already installed on your machine, download it
from http://www.cmake.org. It is recommended that you choose the
"Add CMake to the system PATH for current user" option during the
installation setup process for convenience when running CMake later on.
b. Install ZLIB: The compression library "zlib" is required in
order to build CFITSIO. Visit their site at
https://zlib.net
to download the latest distribution. Unpack it, then build and
install it from a parallel directory, for example:
mkdir zlib.build
cd zlib.build
cmake ..\zlib-1.2.11 -DCMAKE_INSTALL_PREFIX=c:\Users\myname\zlib
cmake --build . --config Release
cmake --install .
The cmake comands below will use the path "c:\Users\myname\zlib"
as an example for the installed zlib location.
c. Unzip the CFITSIO .zip file (e.g. cfit-4.0.0.zip) that was obtained from
the CFITSIO Web site (http://heasarc.gsfc.nasa.gov/fitsio). This will
create a new \cfitsio-4.0.0 subdirectory that contains the source code
and documentation files. It also contains a CMakeLists.txt file
that will be used during the CMake build process.
d. Open the Visual Studio Command Prompt window, likely using a desktop
icon with this same name, (or the equivalent Borland command window)
and cd (change directory) into the parent directory that is one level
above the directory containing the CFITSIO source files that was
created in the previous step.
e. Create a new subdirectory (for example, "cfitsio.build"), and cd
into it with the following commands:
mkdir cfitsio.build
cd cfitsio.build
When using Visual Studio, all the files that are generated during
the CMake process will be created in or under this subdirectory.
f. Create the CMake files necessary for the build:
To use the default Visual Studio compilers and architecture,
simply run (for example):
cmake ..\cfitsio-4.0.0 -DCMAKE_PREFIX_PATH=c:\Users\myname\zlib
Alternatively, you can specify the name of a CMake Generator
using the "-G" flag:
cmake -G "<cmake generator>" ..\cfitsio-4.0.0 -DCMAKE_PREFIX_PATH=c:\Users\myname\zlib
Where the string "<cmake generator>" designates your choice
of compiler. Some possible options are:
"Visual Studio 16 2019"
"Visual Studio 16 2019" -A Win32 (for 32-bit builds)
"Visual Studio 15 2017 Win64"
"Visual Studio 15 2017" (for 32-bit builds)
"Visual Studio 15 2017" -A Win32 (for 32-bit builds)
"MinGW Makefiles"
"Borland Makefiles"
"NMake Makefiles"
You can see a list of all the available CMake Generators by
executing the command
cmake /?
Note that these names are case-sensitive and must be entered
exactly as displayed.
Note that the "..\cfitsio-4.0.0" argument gives the relative
path to the directory that contains the CFITSIO source files
and the CMakeLists.txt file.
Some other optional flags are available to use during this
step, using this format:
cmake -G <generator> ..\cfitsio-4.0.0 -D<option>=<ON|OFF>" -DCMAKE_PREFIX_PATH=c:\Users\myname\zlib
Where the available flags are:
-DUSE_CURL=OFF (default is ON, but unavailable in MS Visual Studio)
Disable search for the curl library needed for remote file access
-DBUILD_SHARED_LIBS=OFF (default is ON)
Disable building a shared CFITSIO library (required in order
link the curl library into the cfitsio library; otherwise
you will need to link curl into your application)
-DUSE_PTHREADS=ON (default is OFF)
Enable a thread-safe build (using pthreads)
-DUSE_BZIP2=ON (default is OFF)
Enable bzip2 support
-DCFITSIO_USE_SSE2=ON (default is OFF)
Enable use of instructions in the SSE2 extended instruction set
-DCFITSIO_USE_SSSE3=ON (default is OFF)
Enable use of instructions in the SSSE3 extended instruction set
-DTESTS=ON (default is OFF)
Build test programs (Testprog and cookbook)
-DUTILS=ON (default is OFF)
Build FPack, Funpack, and Fitscopy executables
g. Execute the following command to build the CFITSIO library:
cmake --build . --config Release
The "." argument following "--build" here tells CMake to build
the files in the current directory (i.e., in "cfitsio.build").
If this process completes successfully, you should find the
CFITSIO library files in the "cfitsio.build\Release" subdirectory.
If you specified -DTESTS=ON in the previous step, you may verify
that CFITSIO is working correctly by executing Testprog in the
same Release directory. It should generate a long stream of
diagnostic messages ending with this line:
"Status = 0: OK - no error".
Similarly, running the cookbook program should end with a
message of success.
h. Other CMake options:
Refer to the CMake documentation for information about many
other build options.
For example, one can build a 'debug' version of the CFITSIO
library by executing the command "cmake --build ." instead of
the command listed above in section f.
The library file(s), header files, and utility programs can
also be installed in a default location (which is currently
C:/Program Files (x86)/CFITSIO/) by running
cmake --install .
This may require administrative privileges, so an alternate
install location may be used by specifying a prefix flag in
the first CMake command in step f), for example:
cmake -G "<generator>" ..\cfitsio-4.0.0
-DCMAKE_INSTALL_PREFIX=c:\Users\myname\cfitsio
-DCMAKE_PREFIX_PATH=c:\Users\myname\zlib
One can also make a thread safe version of CFITSIO using the
pthread library with the following procedure:
a. Download the precompiled files from the pthread-win32 project
(http://sourceware.org/pthreads-win32/). Put the files for your
specific platform (.h, .lib, .dll) into a folder 'pthread',
parallel to the cfitsio source folder.
b. For the compilation of cfitsio follow the cmake steps, but
use this as a replacement for the commands in step f:
cmake -G "<cmake generator>" ..\cfitsio-4.0.0 -DUSE_PTHREADS=1
-DCMAKE_INCLUDE_PATH=..\pthread -DCMAKE_LIBRARY_PATH=..\pthread
-DCMAKE_PREFIX_PATH=c:\Users\myname\zlib
You may need to adapt the paths for the directories used as
examples here.
============================================================================
2. Using CFITSIO when compiling and linking application programs
First, depending on your particular programming environment, it may be
necessary to copy the cfitsio.lib and cfitsio.dll files into another
directory where your compiler expects to find them. Or equivalently, you
may need to specify the directory path to the location of the CFITSIO
library files when creating a project that uses them. You may also need to
copy the fitsio.h and longnam.h include files from the \cfitsio source file
directory to a standard 'include' directory on your system.
When using the Visual Studio command line window, application programs can
be compiled and linked with CFITSIO using the following command:
cl /MD your_program.c cfitsio.lib
The /MD command line switch must be specified to force the compiler/linker
to use the appropriate runtime library. If this switch is omitted, then
the fits_report_error function in CFITSIO will likely crash.
When building programs in the Visual Studio graphical environment, one can
force the equivalent of the /MD switch by selecting 'Settings...' under the
'Project' menu, then click on the C/C++ tab and select the 'Code Generator'
category. Then under 'User Run-time Library' select 'Multithreaded DLL'.
===============================================================================