3 # Builds Hamlib 4.x W32 binary distribution.
5 # A script to build a set of W32 binary DLLs and executables from a Hamlib
6 # source tarball. This script assumes that the Hamlib source tarball has been
7 # extracted to the directory specified in $BUILD_DIR and that libusb-1.x.y has
8 # also been extracted to $BUILD_DIR.
10 # See README.build-Windows for complete details.
13 # Set this to a desired directory
16 # Set this to LibUSB archive extracted in $BUILD_DIR
17 LIBUSB_VER=libusb-1.0.22
19 # Set to the correct HOST_ARCH= line for your minGW installation
20 HOST_ARCH=i686-w64-mingw32
22 # Set to the strip name for your version of minGW
23 HOST_ARCH_STRIP=i686-w64-mingw32-strip
25 # Error return codes. See /usr/include/sysexits.h
30 # Pass name of Hamlib archive extracted in $BUILD_DIR
34 echo "Usage: $(basename $0) hamlib-version"
35 echo "See README.build-Windows for more information."
41 # Make sure the Hamlib archive is where we expect
42 if test -d ${BUILD_DIR}/$1
45 echo "Building W32 binaries in ${BUILD_DIR}/$1"
51 echo "Build directory, ${BUILD_DIR}/$1 not found!"
52 echo "Check path for $1 or correct the version number."
58 RELEASE=$(/usr/bin/awk 'BEGIN{FS="["; RS="]"} /\[4\./ {print $2;exit}' ./configure.ac)
59 HL_FILENAME=hamlib-w32-${RELEASE}
60 INST_DIR=$(pwd)/mingw32-inst
61 ZIP_DIR=$(pwd)/${HL_FILENAME}
62 LIBUSB_1_0_BIN_PATH=${BUILD_DIR}/${LIBUSB_VER}
65 # Create W32 specific README.w32-bin file
66 cat > README.w32-bin <<END_OF_README
70 This ZIP archive or Windows installer contains a build of Hamlib-$RELEASE
71 cross-compiled for MS Windows 32 bit using MinGW under Debian GNU/Linux 10
74 This software is copyrighted. The library license is LGPL, and the *.EXE files
75 licenses are GPL. Hamlib comes WITHOUT ANY WARRANTY. See the LICENSE.txt,
76 COPYING.txt, and COPYING.LIB.txt files.
78 Supporting documentation in the form of Unix manual pages have also been
79 included after being converted to HTML.
82 Installation and Configuration
83 ==============================
85 Extract the ZIP archive into a convenient location, C:\Program Files is a
88 Make sure *all* the .DLL files are in your PATH (leave them in the bin
89 directory and set the PATH). To set the PATH environment variable in Windows
90 2000, Windows XP, and Windows 7 (need info on Vista and Windows 8/10) do the
93 * W2k/XP: Right-click on "My Computer"
94 Win7: Right-click on "Computer"
96 * W2k/XP: Click the "Advanced" tab of the "System Properties" dialog
97 Win7: Click the "Advanced system settings" link in the System dialog
99 * Click the "Environment Variables" button of the pop-up dialog
101 * Select "Path" in the "System variables" box of the "Environment Variables"
104 NB: If you are not the administrator, system policy may not allow editing
105 the path variable. The complete path to an executable file will need to be
106 given to run one of the Hamlib programs.
108 * Click the Edit button
110 * Now add the Hamlib path in the "Variable Value:" edit box. Be sure to put
111 a semi-colon ';' after the last path before adding the Hamlib path (NB. The
112 entire path is highlighted and will be erased upon typing a character so
113 click in the box to unselect the text first. The PATH is important!!)
114 Append the Hamlib path, e.g. C:\Program Files\hamlib-w32-4.0~git\bin
116 * Click OK for all three dialog boxes to save your changes.
119 Testing with the Hamlib Utilities
120 =================================
122 To continue, be sure you have read the README.betatester file, especially the
123 "Testing Hamlib" section. The primary means of testing is by way of the
124 rigctl utility for radios and rotctl utility for rotators. Each is a command
125 line program that is interactive or can act on a single command and exit.
127 Documentation for each utility can be found as an HTML file in the doc
130 In short, the command syntax is of the form:
132 rigctl -m 120 -r COM1 -vvvvv
134 -m -> Radio model 120, or Yaesu FT-817 (use 'rigctl -l' for a list)
135 -r -> Radio device, in this case COM1
136 -v -> Verbosity level. For testing four or five v characters are required.
137 Five 'v's set a debug level of TRACE which generates a lot of screen
138 output showing communication to the radio and values of important
139 variables. These traces are vital information for Hamlib rig backend
142 To run rigctl or rotctl open a cmd window (Start|Run|enter 'cmd' in the
143 dialog). If text scrolls off the screen, you can scroll back with the mouse.
144 To copy output text into a mailer or editor (I recommend Notepad++, a free
145 editor also licensed under the GPL), highlight the text as a rectangle in the
146 cmd window, press <Enter> (or right-click the window icon in the upper left
147 corner and select Edit, then Copy), and paste it into your editor with Ctl-V
148 (or Edit|Paste from the typical GUI menu).
150 All feedback is welcome to the mail address below.
156 To uninstall, simply delete the Hamlib directory. You may wish to edit the
157 PATH as above to remove the Hamlib bin path, if desired.
160 Information for w32 Programmers
161 =================================
163 The DLL has a cdecl interface.
165 There is a libhamlib-4.def definition file for MS Visual C++/Visual Studio in
166 lib/msvc. Refer to the sample commands below to generate a local
167 libhamlib-4.lib file for use with the VC++/VS linker.
169 Simply #include <hamlib/rig.h> (add directory to include path), include
170 libhamlib-4.lib in your project and you are done. Note: VC++/VS cannot
171 compile all the Hamlib code, but the API defined by rig.h has been made MSVC
174 As the source code for the library DLLs is licensed under the LGPL, your
175 program is not considered a "derivative work" when using the published Hamlib
176 API and normal linking to the front-end library, and may be of a license of
179 For linking the library with MS Visual C++ 2003, from the directory you
180 installed Hamlib run the following commands to generate the libhamlib-4.lib
181 file needed for linking with your MSVC project:
184 c:\Program Files\Microsoft Visual C++ Toolkit 2003\bin\link.exe /lib /machine:i386 /def:libhamlib-4.def
186 To do the same for Visual Studio 2017:
189 c:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Tools\MSVC\14.16.27023\bin\Hostx64\x86\bin\link.exe /lib /machine:i386 /def:libhamlib-4.def
194 c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\bin\Hostx64\x86\bin\link.exe /lib /machine:i386 /def:libhamlib-4.def
196 NOTE: feedback is requested on the previous two command examples!
198 The published Hamlib API may be found at:
200 http://hamlib.sourceforge.net/manuals/4.1/index.html
206 Patches, feedback, and contributions are welcome.
208 Please report problems or success to hamlib-developer@lists.sourceforge.net
211 Stephane Fillod - F8CFE
213 http://www.hamlib.org
218 # Configure and build hamlib for i686-w64-mingw32, with libusb-1.0
220 ./configure --host=${HOST_ARCH} \
221 --prefix=${INST_DIR} \
222 --without-cxx-binding \
224 CPPFLAGS="-I${LIBUSB_1_0_BIN_PATH}/include" \
225 LDFLAGS="-L${LIBUSB_1_0_BIN_PATH}/MinGW32/dll"
230 mkdir -p ${ZIP_DIR}/bin ${ZIP_DIR}/lib/msvc ${ZIP_DIR}/lib/gcc ${ZIP_DIR}/include ${ZIP_DIR}/doc
231 cp -a src/libhamlib.def ${ZIP_DIR}/lib/msvc/libhamlib-4.def
232 todos ${ZIP_DIR}/lib/msvc/libhamlib-4.def
233 cp -a ${INST_DIR}/include/hamlib ${ZIP_DIR}/include/.
234 todos ${ZIP_DIR}/include/hamlib/*.h
236 # C++ binding is useless on w32 because of ABI
239 rm ${ZIP_DIR}/include/hamlib/${f}
242 for f in AUTHORS ChangeLog COPYING COPYING.LIB LICENSE README README.betatester README.w32-bin THANKS
244 cp -a ${f} ${ZIP_DIR}/${f}.txt
245 todos ${ZIP_DIR}/${f}.txt
248 # Generate HTML documents from nroff formatted man files
249 for f in doc/man1/*.1 doc/man7/*.7
251 /usr/bin/groff -mandoc -Thtml >${f}.html ${f}
252 cp -a ${f}.html ${ZIP_DIR}/doc/.
257 # Copy build files into specific locations for Zip file
260 cp -a ${INST_DIR}/bin/${f} ${ZIP_DIR}/bin/.
263 cp -a ${INST_DIR}/bin/libhamlib-?.dll ${ZIP_DIR}/bin/.
264 cp -a ${INST_DIR}/lib/libhamlib.dll.a ${ZIP_DIR}/lib/gcc/.
266 # NB: Strip Hamlib DLLs and EXEs
267 ${HOST_ARCH_STRIP} ${ZIP_DIR}/bin/*.exe ${ZIP_DIR}/bin/*hamlib-*.dll
269 # Copy needed third party DLLs
270 cp -a /usr/i686-w64-mingw32/lib/libwinpthread-1.dll ${ZIP_DIR}/bin/.
271 cp -a ${LIBUSB_1_0_BIN_PATH}/MinGW32/dll/libusb-1.0.dll ${ZIP_DIR}/bin/libusb-1.0.dll
273 # Required for MinGW with GCC 6.3 (Debian 9)
274 FILE="/usr/lib/gcc/i686-w64-mingw32/6.3-posix/libgcc_s_sjlj-1.dll"
277 cp -a ${FILE} ${ZIP_DIR}/bin/.
280 # Required for MinGW with GCC 8.3 (Debian 10)
281 FILE="/usr/lib/gcc/i686-w64-mingw32/8.3-posix/libgcc_s_sjlj-1.dll"
284 cp -a ${FILE} ${ZIP_DIR}/bin/.
287 /usr/bin/zip -r ${HL_FILENAME}.zip $(basename ${ZIP_DIR})
3 # Builds Hamlib 4.x W64 binary distribution.
5 # A script to build a set of W64 binary DLLs and executables from a Hamlib
6 # source tarball. This script assumes that the Hamlib source tarball has been
7 # extracted to the directory specified in $BUILD_DIR and that libusb-1.x.y has
8 # also been extracted to $BUILD_DIR.
10 # See README.build-Windows for complete details.
13 # Set this to a desired directory
16 # Set this to LibUSB archive extracted in $BUILD_DIR
17 LIBUSB_VER=libusb-1.0.22
19 # Set to the correct HOST_ARCH= line for your minGW installation
20 HOST_ARCH=x86_64-w64-mingw32
22 # Set to the strip name for your version of minGW
23 HOST_ARCH_STRIP=x86_64-w64-mingw32-strip
25 # Error return codes. See /usr/include/sysexits.h
30 # Pass name of Hamlib archive extracted in $BUILD_DIR
34 echo "Usage: $(basename $0) hamlib-version"
35 echo "See README.build-Windows for more information."
41 # Make sure the Hamlib archive is where we expect
42 if test -d ${BUILD_DIR}/$1
45 echo "Building W64 binaries in ${BUILD_DIR}/$1"
51 echo "Build directory, ${BUILD_DIR}/$1 not found!"
52 echo "Check path for $1 or correct the version number."
58 RELEASE=$(/usr/bin/awk 'BEGIN{FS="["; RS="]"} /\[4\./ {print $2;exit}' ./configure.ac)
59 HL_FILENAME=hamlib-w64-${RELEASE}
60 INST_DIR=$(pwd)/mingw64-inst
61 ZIP_DIR=$(pwd)/${HL_FILENAME}
62 LIBUSB_1_0_BIN_PATH=${BUILD_DIR}/${LIBUSB_VER}
65 # Create W64 specific README.w64-bin file
66 cat > README.w64-bin <<END_OF_README
70 This ZIP archive or Windows installer contains a build of Hamlib-$RELEASE
71 cross-compiled for MS Windows 64 bit using MinGW under Debian GNU/Linux 10
74 This software is copyrighted. The library license is LGPL, and the *.EXE files
75 licenses are GPL. Hamlib comes WITHOUT ANY WARRANTY. See the LICENSE.txt,
76 COPYING.txt, and COPYING.LIB.txt files.
78 Supporting documentation in the form of Unix manual pages have also been
79 included after being converted to HTML.
82 Installation and Configuration
83 ==============================
85 Extract the ZIP archive into a convenient location, C:\Program Files is a
88 Make sure *all* the .DLL files are in your PATH (leave them in the bin
89 directory and set the PATH). To set the PATH environment variable in Windows
90 2000, Windows XP, and Windows 7 (need info on Vista and Windows 8/10) do the
93 * W2k/XP: Right-click on "My Computer"
94 Win7: Right-click on "Computer"
96 * W2k/XP: Click the "Advanced" tab of the "System Properties" dialog
97 Win7: Click the "Advanced system settings" link in the System dialog
99 * Click the "Environment Variables" button of the pop-up dialog
101 * Select "Path" in the "System variables" box of the "Environment Variables"
104 NB: If you are not the administrator, system policy may not allow editing
105 the path variable. The complete path to an executable file will need to be
106 given to run one of the Hamlib programs.
108 * Click the Edit button
110 * Now add the Hamlib path in the "Variable Value:" edit box. Be sure to put
111 a semi-colon ';' after the last path before adding the Hamlib path (NB. The
112 entire path is highlighted and will be erased upon typing a character so
113 click in the box to unselect the text first. The PATH is important!!)
114 Append the Hamlib path, e.g. C:\Program Files\hamlib-w64-4.0~git\bin
116 * Click OK for all three dialog boxes to save your changes.
119 Testing with the Hamlib Utilities
120 =================================
122 To continue, be sure you have read the README.betatester file, especially the
123 "Testing Hamlib" section. The primary means of testing is by way of the
124 rigctl utility for radios and rotctl utility for rotators. Each is a command
125 line program that is interactive or can act on a single command and exit.
127 Documentation for each utility can be found as an HTML file in the doc
130 In short, the command syntax is of the form:
132 rigctl -m 120 -r COM1 -vvvvv
134 -m -> Radio model 120, or Yaesu FT-817 (use 'rigctl -l' for a list)
135 -r -> Radio device, in this case COM1
136 -v -> Verbosity level. For testing four or five v characters are required.
137 Five 'v's set a debug level of TRACE which generates a lot of screen
138 output showing communication to the radio and values of important
139 variables. These traces are vital information for Hamlib rig backend
142 To run rigctl or rotctl open a cmd window (Start|Run|enter 'cmd' in the
143 dialog). If text scrolls off the screen, you can scroll back with the mouse.
144 To copy output text into a mailer or editor (I recommend Notepad++, a free
145 editor also licensed under the GPL), highlight the text as a rectangle in the
146 cmd window, press <Enter> (or right-click the window icon in the upper left
147 corner and select Edit, then Copy), and paste it into your editor with Ctl-V
148 (or Edit|Paste from the typical GUI menu).
150 All feedback is welcome to the mail address below.
156 To uninstall, simply delete the Hamlib directory. You may wish to edit the
157 PATH as above to remove the Hamlib bin path, if desired.
160 Information for w64 Programmers
161 =================================
163 The DLL has a cdecl interface.
165 There is a libhamlib-4.def definition file for MS Visual C++/Visual Studio in
166 lib/msvc. Refer to the sample commands below to generate a local
167 libhamlib-4.lib file for use with the VC++/VS linker.
169 Simply #include <hamlib/rig.h> (add directory to include path), include
170 libhamlib-4.lib in your project and you are done. Note: VC++/VS cannot
171 compile all the Hamlib code, but the API defined by rig.h has been made MSVC
174 As the source code for the library DLLs is licensed under the LGPL, your
175 program is not considered a "derivative work" when using the published Hamlib
176 API and normal linking to the front-end library, and may be of a license of
179 For linking the library with MS Visual C++ 2003, from the directory you
180 installed Hamlib run the following commands to generate the libhamlib-4.lib
181 file needed for linking with your MSVC project:
184 c:\Program Files\Microsoft Visual C++ Toolkit 2003\bin\link.exe /lib /machine:amd64 /def:libhamlib-4.def
186 To do the same for Visual Studio 2017:
189 c:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x86\bin\link.exe /lib /machine:i386 /def:libhamlib-4.def
194 c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\bin\Hostx64\x86\bin\link.exe /lib /machine:i386 /def:libhamlib-4.def
196 NOTE: feedback is requested on the previous two command examples as these do
197 not appear to be correct to generate a 64 bit libhamlib-4.lib file!
199 The published Hamlib API may be found at:
201 http://hamlib.sourceforge.net/manuals/4.1/index.html
207 Patches, feedback, and contributions are welcome.
209 Please report problems or success to hamlib-developer@lists.sourceforge.net
212 Stephane Fillod - F8CFE
214 http://www.hamlib.org
219 # Configure and build hamlib for x86_64-w64-mingw32, with libusb-1.0
221 ./configure --host=${HOST_ARCH} \
222 --prefix=${INST_DIR} \
223 --without-cxx-binding \
225 CPPFLAGS="-I${LIBUSB_1_0_BIN_PATH}/include" \
226 LDFLAGS="-L${LIBUSB_1_0_BIN_PATH}/MinGW64/dll"
231 mkdir -p ${ZIP_DIR}/bin ${ZIP_DIR}/lib/msvc ${ZIP_DIR}/lib/gcc ${ZIP_DIR}/include ${ZIP_DIR}/doc
232 cp -a src/libhamlib.def ${ZIP_DIR}/lib/msvc/libhamlib-4.def
233 todos ${ZIP_DIR}/lib/msvc/libhamlib-4.def
234 cp -a ${INST_DIR}/include/hamlib ${ZIP_DIR}/include/.
235 todos ${ZIP_DIR}/include/hamlib/*.h
237 # C++ binding is useless on w64 because of ABI
240 rm ${ZIP_DIR}/include/hamlib/${f}
243 for f in AUTHORS ChangeLog COPYING COPYING.LIB LICENSE README README.betatester README.w64-bin THANKS
245 cp -a ${f} ${ZIP_DIR}/${f}.txt
246 todos ${ZIP_DIR}/${f}.txt
249 # Generate HTML documents from nroff formatted man files
250 for f in doc/man1/*.1 doc/man7/*.7
252 /usr/bin/groff -mandoc -Thtml >${f}.html ${f}
253 cp -a ${f}.html ${ZIP_DIR}/doc/.
258 # Copy build files into specific locations for Zip file
261 cp -a ${INST_DIR}/bin/${f} ${ZIP_DIR}/bin/.
264 cp -a ${INST_DIR}/bin/libhamlib-?.dll ${ZIP_DIR}/bin/.
265 cp -a ${INST_DIR}/lib/libhamlib.dll.a ${ZIP_DIR}/lib/gcc/.
267 # NB: Strip Hamlib DLLs and EXEs
268 ${HOST_ARCH_STRIP} ${ZIP_DIR}/bin/*.exe ${ZIP_DIR}/bin/*hamlib-*.dll
270 # Copy needed third party DLLs
271 cp -a /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll ${ZIP_DIR}/bin/.
272 cp -a ${LIBUSB_1_0_BIN_PATH}/MinGW64/dll/libusb-1.0.dll ${ZIP_DIR}/bin/libusb-1.0.dll
274 # Required for MinGW with GCC 6.3 (Debian 9)
275 FILE="/usr/lib/gcc/i686-w64-mingw32/6.3-posix/libgcc_s_sjlj-1.dll"
278 cp -a ${FILE} ${ZIP_DIR}/bin/.
281 # Required for MinGW with GCC 8.3 (Debian 10)
282 FILE="/usr/lib/gcc/i686-w64-mingw32/8.3-posix/libgcc_s_sjlj-1.dll"
285 cp -a ${FILE} ${ZIP_DIR}/bin/.
288 /usr/bin/zip -r ${HL_FILENAME}.zip $(basename ${ZIP_DIR})