![]() |
Hamlib 4.7.1
|
This page contains the scripts/README.build-Windows instructions and the scripts/build-w32.sh and scripts/build-w64.h files that describe cross-compiling Hamlib for MS Windows 32 and 64 bit versions on Debian GNU/Linux.
This file is a HOWTO for the cross-compiling of Windows 32 and 64 bit
binary DLLs built from a tarball generated by 'make dist' in a Git
checkout. The resulting DLLs are built with a cdecl interface compatible
with MS VC++.
Prerequisites
=============
In these steps the release or daily snapshot tarball is unpacked in
$HOME/builds for the Windows build and all operations are done from there
unless otherwise noted.
Under Linux you need at least the following packages:
mingw-w64 cross-compiler
zip create the archive
tofrodos convert to DOS text format (CR/LF)
groff convert nroff manual pages to HTML
On Debian 8 (Jessie) and later versions the mingw-w64 package works and is
being used to build the daily Windows 32/64 snapshots and stable releases.
The release and daily snapshots are built in a Debian 10 (Buster) virtual
machine.
Finally, the Windows version of libusb 1.0 must be available for the USB
backends to be built. Download the latest libusb-1.0 from:
https://sourceforge.net/projects/libusb/files/libusb-1.0/
and unzip the archive in $HOME/builds.
libusb 1.0.20 is known to work. Presumably, any 1.X.X version should work.
Several variables may need to be set differently at the top of the script file
depending on your system.
The script now relies on a pair of environment variables to locate the needed
libusb files.
The script generates HTML documents for the included .EXE files using groff
to convert the nroff formatted man pages.
Build for Windows 32/64, cross-compile on Linux:
================================================
Extract the Hamlib tarball into $HOME/builds (if you prefer another directory
be sure to edit the BUILD_DIR variable in the build-w[32|64].sh script):
$ tar xvfz $HOME/Downloads/hamlib-4.2~git-???????-20210214.tar.gz
Invoke the build-w[32|64].sh script (either requires a Bourne compatible
shell, e.g. bash, dash, etc.) with the name of the directory/Hamlib version to
build (you need not cd into the hamlib directory, although it won't hurt. The
build-w[32|64].sh script uses absolute paths):
$ build-w32.sh hamlib-4.2~git
or:
$ build-w64.sh hamlib-4.2~git
Release Info
============
The structure of the archive is:
$ tree -d
.
|-- bin
|-- doc
|-- include
| `-- hamlib
|-- lib
|-- gcc
`-- msvc
8 directories
The bin/ directory is where the executables and DLL files are placed. Header
files are under include/Hamlib/ and compiler specific files are under lib/*.
HTML documents for the .EXE programs are in doc/ while text documents
(READMEs and such) are in the main archive directory. The doc/ directory
contains the classic Unix manual pages converted to HTML. The embedded
README.w[32|64]-bin.txt file generated by the build-w[32|64].sh script
describes setting the PATH environment variable in Windows 2000, Windows XP,
and Windows 7.
73, Nate, N0NB
001: #!/bin/sh
002:
003: # Builds Hamlib 4.x W32 binary distribution.
004:
005: # A script to build a set of W32 binary DLLs and executables from a Hamlib
006: # source tarball. This script assumes that the Hamlib source tarball has been
007: # extracted to the directory specified in $BUILD_DIR and that libusb-1.x.y has
008: # also been extracted to $BUILD_DIR.
009:
010: # See README.build-Windows for complete details.
011:
012: # running 'file' against the resulting .DLL should return the following or similar:
013: # file libhamlib-4.dll
014: # libhamlib-4.dll: PE32 executable for MS Windows 4.00 (DLL), Intel i386 (stripped to external PDB), 10 sections
015:
016:
017: # Set this to a desired directory
018: BUILD_DIR=~/builds
019:
020: # Set this to LibUSB archive extracted in $BUILD_DIR
021: LIBUSB_VER=libusb-1.0.24
022:
023: # Set to the correct HOST_ARCH= line for your MinGW installation
024: HOST_ARCH=i686-w64-mingw32
025:
026: # Set to the strip name for your version of MinGW
027: HOST_ARCH_STRIP=i686-w64-mingw32-strip
028:
029: # Set to the dlltool name for your version of MinGW
030: HOST_ARCH_DLLTOOL=i686-w64-mingw32-dlltool
031:
032: # Error return codes. See /usr/include/sysexits.h
033: EX_USAGE=64
034: EX_NOINPUT=66
035:
036:
037: # Pass name of Hamlib archive extracted in $BUILD_DIR
038: if test $# -ne 1
039: then
040: echo
041: echo "Usage: $(basename $0) hamlib-version"
042: echo "See README.build-Windows for more information."
043: echo
044:
045: exit ${EX_USAGE}
046: fi
047:
048: # Make sure the Hamlib archive is where we expect
049: if test -d ${BUILD_DIR}/$1
050: then
051: echo
052: echo "Building W32 binaries in ${BUILD_DIR}/$1"
053: echo
054:
055: cd ${BUILD_DIR}/$1
056: else
057: echo
058: echo "Build directory, ${BUILD_DIR}/$1 not found!"
059: echo "Check path for $1 or correct the version number."
060: echo
061:
062: exit ${EX_NOINPUT}
063: fi
064:
065: RELEASE=$(/usr/bin/awk 'BEGIN{FS="["; RS="]"} /\[4\./ {print $2;exit}' ./configure.ac)
066: HL_FILENAME=hamlib-w32-${RELEASE}
067: INST_DIR=$(pwd)/mingw32-inst
068: ZIP_DIR=$(pwd)/${HL_FILENAME}
069: LIBUSB_1_0_BIN_PATH=${BUILD_DIR}/${LIBUSB_VER}
070:
071:
072: # Create W32 specific README.w32-bin file
073: cat > README.w32-bin <<END_OF_README
074: What is it?
075: ===========
076:
077: This ZIP archive or Windows installer contains a build of Hamlib-${RELEASE}
078: cross-compiled for MS Windows 32 bit using MinGW under Debian GNU/Linux 13
079: (nice, heh!).
080:
081: This software is copyrighted. The library license is LGPL, and the *.EXE files
082: licenses are GPL. Hamlib comes WITHOUT ANY WARRANTY. See the LICENSE.txt,
083: COPYING.txt, and COPYING.LIB.txt files.
084:
085: Supporting documentation in the form of Unix manual pages have also been
086: included after being converted to HTML.
087:
088:
089: Installation and Configuration
090: ==============================
091:
092: Extract the ZIP archive into a convenient location, C:\Program Files is a
093: reasonable choice.
094:
095: The archive directory structure is:
096:
097: hamlib-w32-4.7~git
098: ├── bin
099: ├── doc
100: ├── include
101: │ └── hamlib
102: └── lib
103: ├── gcc
104: └── msvc
105:
106: The 'bin' and 'doc' directories will be of interest to users while developers
107: will be interested in the 'include' and 'lib' directories as well.
108:
109: Make sure *all* the .DLL files are in your PATH (leave them in the 'bin'
110: directory and set the PATH). To set the PATH environment variable in Windows
111: 2000, Windows XP, and Windows 7 (need info on Vista and Windows 8/10) do the
112: following:
113:
114: * W2k/XP: Right-click on "My Computer"
115: Win7: Right-click on "Computer"
116:
117: * W2k/XP: Click the "Advanced" tab of the "System Properties" dialog
118: Win7: Click the "Advanced system settings" link in the System dialog
119:
120: * Click the "Environment Variables" button of the pop-up dialog
121:
122: * Select "Path" in the "System variables" box of the "Environment Variables"
123: dialog
124:
125: NB: If you are not the administrator, system policy may not allow editing
126: the path variable. The complete path to an executable file will need to be
127: given to run one of the Hamlib programs.
128:
129: * Click the Edit button
130:
131: * Now add the Hamlib path in the "Variable Value:" edit box. Be sure to put
132: a semi-colon ';' after the last path before adding the Hamlib path (NB. The
133: entire path is highlighted and will be erased upon typing a character so
134: click in the box to unselect the text first. The PATH is important!!)
135: Append the Hamlib path, e.g. C:\Program Files\hamlib-w32-${RELEASE}\bin
136:
137: * Click OK for all three dialog boxes to save your changes.
138:
139:
140: Testing with the Hamlib Utilities
141: =================================
142:
143: To continue, be sure you have read the README.betatester file, especially the
144: "Testing Hamlib" section. The primary means of testing is by way of the
145: rigctl utility for radios, the rotctl utility for rotators and the ampctl
146: utility for amplifiers. Each is a command line program that is interactive
147: or can act on a single command and exit.
148:
149: Documentation for each utility can be found as an HTML file in the doc
150: directory.
151:
152: In short, the command syntax is of the form:
153:
154: rigctl -m 1020 -r COM1 -vvvvv
155:
156: -m -> Radio model 1020, or Yaesu FT-817 (use 'rigctl -l' for a list)
157: -r -> Radio device, in this case COM1
158: -v -> Verbosity level. For testing four or five v characters are required.
159: Five 'v's set a debug level of TRACE which generates a lot of screen
160: output showing communication to the radio and values of important
161: variables. These traces are vital information for Hamlib rig backend
162: development.
163:
164: To run rigctl or rotctl open a cmd window (Start|Run|enter 'cmd' in the
165: dialog). If text scrolls off the screen, you can scroll back with the mouse.
166: To copy output text into a mailer or editor (Notepad++, a free editor also
167: licensed under the GPL is recommended), highlight the text as a rectangle in
168: the cmd window, press <Enter> (or right-click the window icon in the upper left
169: corner and select Edit, then Copy), and paste it into your editor with Ctl-V
170: (or Edit|Paste from the typical GUI menu).
171:
172: All feedback is welcome to the mail address below.
173:
174:
175: Uninstall
176: =========
177:
178: To uninstall, simply delete the Hamlib directory. You may wish to edit the
179: PATH as above to remove the Hamlib bin path, if desired.
180:
181:
182: Information for w32 Programmers
183: =================================
184:
185: The DLL has a cdecl interface.
186:
187: There is a libhamlib-4.def definition file for MS Visual C++/Visual Studio in
188: lib\msvc. Refer to the recipe below to generate a local libhamlib-4.lib file
189: for use with the VC++/VS linker.
190:
191: Simply '#include <hamlib/rig.h>' (or any other header) (add directory to
192: include path), include libhamlib-4.lib in your project and you are done. Note:
193: VC++/VS cannot compile all the Hamlib code, but the API defined by rig.h has
194: been made MSVC friendly :-)
195:
196: As the source code for the library DLLs is licensed under the LGPL, your
197: program is not considered a "derivative work" when using the published Hamlib
198: API and normal linking to the front-end library, and may be of a license of
199: your choosing.
200:
201: As of 04 Aug 2025 a .lib file is generated using the MinGW dlltool utility.
202: This file is now installed to the lib\gcc directory. As it is generated
203: by the MinGW dlltool utility, it is only suitable for use with MinGW/GCC.
204:
205: For developers using Microsoft Visual Studio, the following recipe is
206: provided by Phil Rose, GM3ZZA:
207:
208: My secret sauce is:
209:
210: Open "Developer PowerShell for VS2022" in administrator mode. This adds the
211: correct directory to the path and allows update of "C:\Program Files" with the
212: .dll.
213:
214: Then (in my case).
215:
216: cd "C:\Program Files\hamlib-w32-${RELEASE}\lib\msvc"
217: lib /def:libhamlib-4.def /machine:x86
218:
219: If you use any other terminal then the full path to lib.exe is needed
220: (today it is
221: "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\bin\Hostx64\x64\lib.exe",
222: but is dependent on the version of MSVC which gets updated every few weeks).
223:
224: NOTE: feedback is requested on Phil's example! Please let know if this works
225: for you.
226:
227: The published Hamlib API may be found at:
228:
229: http://hamlib.sourceforge.net/manuals/4.1/index.html
230:
231:
232: Thank You!
233: ==========
234:
235: Patches, feedback, and contributions are welcome.
236:
237: Please report problems or success to hamlib-developer@lists.sourceforge.net
238:
239: Cheers,
240: Stephane Fillod - F8CFE
241: Mike Black - W9MDB (SK)
242: Nate Bargmann - N0NB
243: http://www.hamlib.org
244:
245: END_OF_README
246:
247:
248: # Configure and build hamlib for i686-w64-mingw32, with libusb-1.0
249:
250: ./configure --host=${HOST_ARCH} \
251: --prefix=${INST_DIR} \
252: --without-cxx-binding \
253: --disable-static \
254: CPPFLAGS="-I${LIBUSB_1_0_BIN_PATH}/include" \
255: LDFLAGS="-L${LIBUSB_1_0_BIN_PATH}/MinGW32/dll" \
256: LIBUSB_CFLAGS="-I${LIBUSB_1_0_BIN_PATH}/include/libusb-1.0" \
257: LIBUSB_LIBS="-lusb-1.0"
258:
259:
260:
261: make -j 4 --no-print-directory install
262:
263: mkdir -p ${ZIP_DIR}/bin ${ZIP_DIR}/lib/msvc ${ZIP_DIR}/lib/gcc ${ZIP_DIR}/include ${ZIP_DIR}/doc
264: cp -a src/libhamlib.def ${ZIP_DIR}/lib/msvc/libhamlib-4.def
265: todos ${ZIP_DIR}/lib/msvc/libhamlib-4.def
266: cp -a ${INST_DIR}/include/hamlib ${ZIP_DIR}/include/.
267: todos ${ZIP_DIR}/include/hamlib/*.h
268:
269: # C++ binding is useless on w32 because of ABI
270: for f in *class.h
271: do
272: rm ${ZIP_DIR}/include/hamlib/${f}
273: done
274:
275: for f in AUTHORS ChangeLog COPYING COPYING.LIB LICENSE README.md README.betatester README.w32-bin THANKS
276: do
277: cp -a ${f} ${ZIP_DIR}/${f}.txt
278: todos ${ZIP_DIR}/${f}.txt
279: done
280:
281: # Generate HTML documents from nroff formatted man files
282: for f in doc/man1/*.1 doc/man7/*.7
283: do
284: /usr/bin/groff -mandoc -Thtml >${f}.html ${f}
285: cp -a ${f}.html ${ZIP_DIR}/doc/.
286: done
287:
288: cd ${BUILD_DIR}/$1
289:
290: # Copy build files into specific locations for Zip file
291: for f in *.exe
292: do
293: cp -a ${INST_DIR}/bin/${f} ${ZIP_DIR}/bin/.
294: done
295:
296: cp -a ${INST_DIR}/bin/libhamlib-?.dll ${ZIP_DIR}/bin/.
297: cp -a ${INST_DIR}/lib/libhamlib.dll.a ${ZIP_DIR}/lib/gcc/.
298:
299: # NB: Strip Hamlib DLLs and EXEs
300: ${HOST_ARCH_STRIP} ${ZIP_DIR}/bin/*.exe ${ZIP_DIR}/bin/*hamlib-*.dll
301:
302: # Copy needed third party DLLs
303: cp -a /usr/i686-w64-mingw32/lib/libwinpthread-1.dll ${ZIP_DIR}/bin/.
304: cp -a ${LIBUSB_1_0_BIN_PATH}/MinGW32/dll/libusb-1.0.dll ${ZIP_DIR}/bin/libusb-1.0.dll
305:
306: # Required for MinGW with GCC 6.3 (Debian 9)
307: FILE="/usr/lib/gcc/i686-w64-mingw32/6.3-posix/libgcc_s_sjlj-1.dll"
308: if test -f "$FILE"
309: then
310: cp -a ${FILE} ${ZIP_DIR}/bin/.
311: fi
312:
313: # Required for MinGW with GCC 8.3 (Debian 10)
314: FILE="/usr/lib/gcc/i686-w64-mingw32/8.3-posix/libgcc_s_sjlj-1.dll"
315: if test -f "$FILE"
316: then
317: cp -a ${FILE} ${ZIP_DIR}/bin/.
318: fi
319:
320: # Required for MinGW with GCC 10 (Debian 11)
321: FILE="/usr/lib/gcc/i686-w64-mingw32/10-posix/libgcc_s_dw2-1.dll"
322: if test -f "$FILE"
323: then
324: cp -a ${FILE} ${ZIP_DIR}/bin/.
325: fi
326:
327: # Required for MinGW with GCC 12 (Debian 12)
328: FILE="/usr/lib/gcc/i686-w64-mingw32/12-posix/libgcc_s_dw2-1.dll"
329: if test -f "$FILE"
330: then
331: cp -a ${FILE} ${ZIP_DIR}/bin/.
332: fi
333:
334: # Required for MinGW with GCC 14 (Debian 13)
335: FILE="/usr/lib/gcc/i686-w64-mingw32/14-posix/libgcc_s_dw2-1.dll"
336: if test -f "$FILE"
337: then
338: cp -a ${FILE} ${ZIP_DIR}/bin/.
339: fi
340:
341: # Generate .lib file for GCC on MinGW per Jonathan Yong from mingw-w64
342: # https://sourceforge.net/p/mingw-w64/discussion/723798/thread/e23dceba20/?limit=25#51dd/3df2/3708/e62b
343: ${HOST_ARCH_DLLTOOL} --input-def ${ZIP_DIR}/lib/msvc/libhamlib-4.def --output-lib ${ZIP_DIR}/lib/gcc/libhamlib-4.lib
344:
345: /usr/bin/zip -r ${HL_FILENAME}.zip $(basename ${ZIP_DIR})
346:
001: #!/bin/sh
002:
003: # Builds Hamlib 4.x W64 binary distribution.
004:
005: # A script to build a set of W64 binary DLLs and executables from a Hamlib
006: # source tarball. This script assumes that the Hamlib source tarball has been
007: # extracted to the directory specified in $BUILD_DIR and that libusb-1.x.y has
008: # also been extracted to $BUILD_DIR.
009:
010: # See README.build-Windows for complete details.
011:
012: # running 'file' against the resulting .DLL should return the following or similar:
013: # file libhamlib-4.dll
014: # libhamlib-4.dll: PE32+ executable for MS Windows 5.02 (DLL), x86-64 (stripped to external PDB), 11 sections
015:
016:
017: # Set this to a desired directory
018: BUILD_DIR=~/builds
019:
020: # Set this to LibUSB archive extracted in $BUILD_DIR
021: LIBUSB_VER=libusb-1.0.24
022:
023: # Set to the correct HOST_ARCH= line for your MinGW installation
024: HOST_ARCH=x86_64-w64-mingw32
025:
026: # Set to the strip name for your version of MinGW
027: HOST_ARCH_STRIP=x86_64-w64-mingw32-strip
028:
029: # Set to the dlltool name for your version of MinGW
030: HOST_ARCH_DLLTOOL=x86_64-w64-mingw32-dlltool
031:
032: # Error return codes. See /usr/include/sysexits.h
033: EX_USAGE=64
034: EX_NOINPUT=66
035:
036:
037: # Pass name of Hamlib archive extracted in $BUILD_DIR
038: if test $# -ne 1
039: then
040: echo
041: echo "Usage: $(basename $0) hamlib-version"
042: echo "See README.build-Windows for more information."
043: echo
044:
045: exit ${EX_USAGE}
046: fi
047:
048: # Make sure the Hamlib archive is where we expect
049: if test -d ${BUILD_DIR}/$1
050: then
051: echo
052: echo "Building W64 binaries in ${BUILD_DIR}/$1"
053: echo
054:
055: cd ${BUILD_DIR}/$1
056: else
057: echo
058: echo "Build directory, ${BUILD_DIR}/$1 not found!"
059: echo "Check path for $1 or correct the version number."
060: echo
061:
062: exit ${EX_NOINPUT}
063: fi
064:
065: RELEASE=$(/usr/bin/awk 'BEGIN{FS="["; RS="]"} /\[4\./ {print $2;exit}' ./configure.ac)
066: HL_FILENAME=hamlib-w64-${RELEASE}
067: INST_DIR=$(pwd)/mingw64-inst
068: ZIP_DIR=$(pwd)/${HL_FILENAME}
069: LIBUSB_1_0_BIN_PATH=${BUILD_DIR}/${LIBUSB_VER}
070:
071:
072: # Create W64 specific README.w64-bin file
073: cat > README.w64-bin <<END_OF_README
074: What is it?
075: ===========
076:
077: This ZIP archive or Windows installer contains a build of Hamlib-${RELEASE}
078: cross-compiled for MS Windows 64 bit using MinGW under Debian GNU/Linux 13
079: (nice, heh!).
080:
081: This software is copyrighted. The library license is LGPL, and the *.EXE files
082: licenses are GPL. Hamlib comes WITHOUT ANY WARRANTY. See the LICENSE.txt,
083: COPYING.txt, and COPYING.LIB.txt files.
084:
085: Supporting documentation in the form of Unix manual pages have also been
086: included after being converted to HTML.
087:
088:
089: Installation and Configuration
090: ==============================
091:
092: Extract the ZIP archive into a convenient location, C:\Program Files is a
093: reasonable choice.
094:
095: The archive directory structure is:
096:
097: hamlib-w64-4.7~git
098: ├── bin
099: ├── doc
100: ├── include
101: │ └── hamlib
102: └── lib
103: ├── gcc
104: └── msvc
105:
106: The 'bin' and 'doc' directories will be of interest to users while developers
107: will be interested in the 'include' and 'lib' directories as well.
108:
109: Make sure *all* the .DLL files are in your PATH (leave them in the 'bin'
110: directory and set the PATH). To set the PATH environment variable in Windows
111: 2000, Windows XP, and Windows 7 (need info on Vista and Windows 8/10) do the
112: following:
113:
114: * W2k/XP: Right-click on "My Computer"
115: Win7: Right-click on "Computer"
116:
117: * W2k/XP: Click the "Advanced" tab of the "System Properties" dialog
118: Win7: Click the "Advanced system settings" link in the System dialog
119:
120: * Click the "Environment Variables" button of the pop-up dialog
121:
122: * Select "Path" in the "System variables" box of the "Environment Variables"
123: dialog
124:
125: NB: If you are not the administrator, system policy may not allow editing
126: the path variable. The complete path to an executable file will need to be
127: given to run one of the Hamlib programs.
128:
129: * Click the Edit button
130:
131: * Now add the Hamlib path in the "Variable Value:" edit box. Be sure to put
132: a semi-colon ';' after the last path before adding the Hamlib path (NB. The
133: entire path is highlighted and will be erased upon typing a character so
134: click in the box to unselect the text first. The PATH is important!!)
135: Append the Hamlib path, e.g. C:\Program Files\hamlib-w64-${RELEASE}\bin
136:
137: * Click OK for all three dialog boxes to save your changes.
138:
139:
140: Testing with the Hamlib Utilities
141: =================================
142:
143: To continue, be sure you have read the README.betatester file, especially the
144: "Testing Hamlib" section. The primary means of testing is by way of the
145: rigctl utility for radios, the rotctl utility for rotators and the ampctl
146: utility for amplifiers. Each is a command line program that is interactive
147: or can act on a single command and exit.
148:
149: Documentation for each utility can be found as an HTML file in the doc
150: directory.
151:
152: In short, the command syntax is of the form:
153:
154: rigctl -m 1020 -r COM1 -vvvvv
155:
156: -m -> Radio model 1020, or Yaesu FT-817 (use 'rigctl -l' for a list)
157: -r -> Radio device, in this case COM1
158: -v -> Verbosity level. For testing four or five v characters are required.
159: Five 'v's set a debug level of TRACE which generates a lot of screen
160: output showing communication to the radio and values of important
161: variables. These traces are vital information for Hamlib rig backend
162: development.
163:
164: To run rigctl or rotctl open a cmd window (Start|Run|enter 'cmd' in the
165: dialog). If text scrolls off the screen, you can scroll back with the mouse.
166: To copy output text into a mailer or editor (Notepad++, a free editor also
167: licensed under the GPL is recommended), highlight the text as a rectangle in
168: the cmd window, press <Enter> (or right-click the window icon in the upper left
169: corner and select Edit, then Copy), and paste it into your editor with Ctl-V
170: (or Edit|Paste from the typical GUI menu).
171:
172: All feedback is welcome to the mail address below.
173:
174:
175: Uninstall
176: =========
177:
178: To uninstall, simply delete the Hamlib directory. You may wish to edit the
179: PATH as above to remove the Hamlib bin path, if desired.
180:
181:
182: Information for w64 Programmers
183: =================================
184:
185: The DLL has a cdecl interface.
186:
187: There is a libhamlib-4.def definition file for MS Visual C++/Visual Studio in
188: lib\msvc. Refer to the recipe below to generate a local libhamlib-4.lib file
189: for use with the VC++/VS linker.
190:
191: Simply '#include <hamlib/rig.h>' (or any other header) (add directory to
192: include path), include libhamlib-4.lib in your project and you are done. Note:
193: VC++/VS cannot compile all the Hamlib code, but the API defined by rig.h has
194: been made MSVC friendly :-)
195:
196: As the source code for the library DLLs is licensed under the LGPL, your
197: program is not considered a "derivative work" when using the published Hamlib
198: API and normal linking to the front-end library, and may be of a license of
199: your choosing.
200:
201: As of 04 Aug 2025 a .lib file is generated using the MinGW dlltool utility.
202: This file is now installed to the lib\gcc directory. As it is generated
203: by the MinGW dlltool utility, it is only suitable for use with MinGW/GCC.
204:
205: For developers using Microsoft Visual Studio, the following recipe is
206: provided by Phil Rose, GM3ZZA:
207:
208: My secret sauce is:
209:
210: Open "Developer PowerShell for VS2022" in administrator mode. This adds the
211: correct directory to the path and allows update of "C:\Program Files" with the
212: .dll.
213:
214: Then (in my case).
215:
216: cd "C:\Program Files\hamlib-w64-${RELEASE}\lib\msvc"
217: lib /def:libhamlib-4.def /machine:x64
218:
219: If you use any other terminal then the full path to lib.exe is needed
220: (today it is
221: "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\bin\Hostx64\x64\lib.exe",
222: but is dependent on the version of MSVC which gets updated every few weeks).
223:
224: NOTE: feedback is requested on Phil's example! Please let know if this works
225: for you.
226:
227: The published Hamlib API may be found at:
228:
229: http://hamlib.sourceforge.net/manuals/4.1/index.html
230:
231:
232: Thank You!
233: ==========
234:
235: Patches, feedback, and contributions are welcome.
236:
237: Please report problems or success to hamlib-developer@lists.sourceforge.net
238:
239: Cheers,
240: Stephane Fillod - F8CFE
241: Mike Black - W9MDB (SK)
242: Nate Bargmann - N0NB
243: http://www.hamlib.org
244:
245: END_OF_README
246:
247:
248: echo $PKG_CONFIG_PATH
249:
250: # Configure and build hamlib for x86_64-w64-mingw32, with libusb-1.0
251:
252: ./configure --host=${HOST_ARCH} \
253: --build=$(uname -m) \
254: --target=${HOST_ARCH} \
255: --prefix=${INST_DIR} \
256: --without-cxx-binding \
257: --disable-static \
258: CPPFLAGS="-I${LIBUSB_1_0_BIN_PATH}/include" \
259: LDFLAGS="-L${LIBUSB_1_0_BIN_PATH}/MinGW64/dll" \
260: LIBUSB_CFLAGS="-I${LIBUSB_1_0_BIN_PATH}/include/libusb-1.0" \
261: LIBUSB_LIBS="-lusb-1.0"
262:
263:
264: make -j 4 --no-print-directory install
265:
266: mkdir -p ${ZIP_DIR}/bin ${ZIP_DIR}/lib/msvc ${ZIP_DIR}/lib/gcc ${ZIP_DIR}/include ${ZIP_DIR}/doc
267: cp -a src/libhamlib.def ${ZIP_DIR}/lib/msvc/libhamlib-4.def
268: todos ${ZIP_DIR}/lib/msvc/libhamlib-4.def
269: cp -a ${INST_DIR}/include/hamlib ${ZIP_DIR}/include/.
270: todos ${ZIP_DIR}/include/hamlib/*.h
271:
272: # C++ binding is useless on w64 because of ABI
273: for f in *class.h
274: do
275: rm ${ZIP_DIR}/include/hamlib/${f}
276: done
277:
278: for f in AUTHORS ChangeLog COPYING COPYING.LIB LICENSE README.md README.betatester README.w64-bin THANKS
279: do
280: cp -a ${f} ${ZIP_DIR}/${f}.txt
281: todos ${ZIP_DIR}/${f}.txt
282: done
283:
284: # Generate HTML documents from nroff formatted man files
285: for f in doc/man1/*.1 doc/man7/*.7
286: do
287: /usr/bin/groff -mandoc -Thtml >${f}.html ${f}
288: cp -a ${f}.html ${ZIP_DIR}/doc/.
289: done
290:
291: cd ${BUILD_DIR}/$1
292:
293: # Copy build files into specific locations for Zip file
294: for f in *.exe
295: do
296: cp -a ${INST_DIR}/bin/${f} ${ZIP_DIR}/bin/.
297: done
298:
299: cp -a ${INST_DIR}/bin/libhamlib-?.dll ${ZIP_DIR}/bin/.
300: cp -a ${INST_DIR}/lib/libhamlib.dll.a ${ZIP_DIR}/lib/gcc/.
301:
302: # NB: Strip Hamlib DLLs and EXEs
303: ${HOST_ARCH_STRIP} ${ZIP_DIR}/bin/*.exe ${ZIP_DIR}/bin/*hamlib-*.dll
304:
305: # Copy needed third party DLLs
306: cp -a /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll ${ZIP_DIR}/bin/.
307: cp -a ${LIBUSB_1_0_BIN_PATH}/MinGW64/dll/libusb-1.0.dll ${ZIP_DIR}/bin/libusb-1.0.dll
308:
309: # Required for MinGW with GCC 6.3 (Debian 9)
310: FILE="/usr/lib/gcc/i686-w64-mingw32/6.3-posix/libgcc_s_sjlj-1.dll"
311: if test -f "$FILE"
312: then
313: cp -a ${FILE} ${ZIP_DIR}/bin/.
314: fi
315:
316: # Required for MinGW with GCC 8.3 (Debian 10)
317: FILE="/usr/lib/gcc/i686-w64-mingw32/8.3-posix/libgcc_s_sjlj-1.dll"
318: if test -f "$FILE"
319: then
320: cp -a ${FILE} ${ZIP_DIR}/bin/.
321: fi
322:
323: # Required for MinGW with GCC 10 (Debian 11)
324: FILE="/usr/lib/gcc/i686-w64-mingw32/10-posix/libgcc_s_dw2-1.dll"
325: if test -f "$FILE"
326: then
327: cp -a ${FILE} ${ZIP_DIR}/bin/.
328: fi
329:
330: # Required for MinGW with GCC 12 (Debian 12)
331: FILE="/usr/lib/gcc/i686-w64-mingw32/12-posix/libgcc_s_dw2-1.dll"
332: if test -f "$FILE"
333: then
334: cp -a ${FILE} ${ZIP_DIR}/bin/.
335: fi
336:
337: # Required for MinGW with GCC 14 (Debian 13)
338: FILE="/usr/lib/gcc/x86_64-w64-mingw32/14-posix/libgcc_s_seh-1.dll"
339: if test -f "$FILE"
340: then
341: cp -a ${FILE} ${ZIP_DIR}/bin/.
342: fi
343:
344: # Generate .lib file for GCC on MinGW per Jonathan Yong from mingw-w64
345: # https://sourceforge.net/p/mingw-w64/discussion/723798/thread/e23dceba20/?limit=25#51dd/3df2/3708/e62b
346: ${HOST_ARCH_DLLTOOL} --input-def ${ZIP_DIR}/lib/msvc/libhamlib-4.def --output-lib ${ZIP_DIR}/lib/gcc/libhamlib-4.lib
347:
348: /usr/bin/zip -r ${HL_FILENAME}.zip $(basename ${ZIP_DIR})
349: