<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
color:black;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";
color:black;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
color:black;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:Consolas;
color:black;}
span.EmailStyle21
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body bgcolor=white lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='color:windowtext'>Is the static linking issue just with Windows, and it works on Linux, or it isn’t working with FPC at all on either?<o:p></o:p></span></p><p class=MsoNormal><span style='color:windowtext'><o:p> </o:p></span></p><div><p class=MsoNormal><span style='color:windowtext'>James<o:p></o:p></span></p></div><p class=MsoNormal><span style='color:windowtext'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='color:windowtext'>From:</span></b><span style='color:windowtext'> fpc-pascal <fpc-pascal-bounces@lists.freepascal.org> <b>On Behalf Of </b>Jean SUZINEAU<br><b>Sent:</b> Thursday, August 8, 2019 5:40 AM<br><b>To:</b> fpc-pascal@lists.freepascal.org<br><b>Subject:</b> Re: [fpc-pascal] USB Human Interface Devices<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>Static linking :<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Le 05/08/2019 à 21:38, Johann Glaser a écrit :<o:p></o:p></p></div><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><div><p class=MsoNormal>Referring to your EMail to James, it seems that Vitaly even got it working with static linking. Especially "$LINKLIB msvcrt" and "$LINKLIB usb-1.0.dll.a" look promising. Hmm, OTOH he writes of dynamically linked, I don't know.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Could you please also have a look at his comments in that Github issue?<o:p></o:p></p></div></blockquote><p>For now I couldn't achieve static linking.<o:p></o:p></p><p>I couldn't find a reliable way to find the dependencies of libusb-1.0 on other libraries, may be I would have to dig into the makefile and autoconf files of libusb sources, but it seems difficult.<o:p></o:p></p><p>I used MSYS2 (<a href="https://www.msys2.org/">https://www.msys2.org/</a>) in which I installed the following packages:<o:p></o:p></p><pre> pacman -S mingw64/mingw-w64-x86_64-libusb<o:p></o:p></pre><pre> pacman -S mingw-w64-x86_64-headers-git<o:p></o:p></pre><pre> pacman -S mingw-w64-x86_64-crt-git<o:p></o:p></pre><pre> pacman -S mingw-w64-x86_64-gcc<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>In LibUsb.pas I changed the $LINKLIBs to (the errors removed by a particular $LINKLIB are after //Error: ) : <o:p></o:p></pre><pre>{$LINKLIB usb-1.0}<o:p></o:p></pre><pre>{$ifdef windows}<o:p></o:p></pre><pre> {$LINKLIB mingwex} //Error: Undefined symbol: __mingw_vsnprintf, __mingw_vsprintf, __mingw_vsscanf<o:p></o:p></pre><pre> //{$LINKLIB mingw32} //doesn't improve anything<o:p></o:p></pre><pre> {$LINKLIB kernel32} // Error: Undefined symbol: __imp_TlsGetValue, __imp_EnterCriticalSection, __imp_LeaveCriticalSection, ... +41 others<o:p></o:p></pre><pre> {$LINKLIB advapi32} // Error: Undefined symbol: __imp_OpenSCManagerA, __imp_OpenServiceA, __imp_CloseServiceHandle<o:p></o:p></pre><pre> //{$LINKLIB winpthread} //doesn't improve anything<o:p></o:p></pre><pre> //{$LINKLIB stdc++} //doesn't improve anything<o:p></o:p></pre><pre> {$LINKLIB gcc} //Error: Undefined symbol: ___chkstk_ms<o:p></o:p></pre><pre> {$LINKLIB crtdll} //Error: malloc, memcpy, ... + 37 others<o:p></o:p></pre><pre> //{$LINKLIB msvcrt} //same as crtdll, Error: malloc, memcpy, ... + 37 others{$else}<o:p></o:p></pre><pre> {$LINKLIB c}<o:p></o:p></pre><pre>{$endif}<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>Here are the errors of the compilation, it's the minimu I could obtain:<o:p></o:p></pre><pre><o:p> </o:p></pre><pre>Hint: (11030) Start of reading config file C:\lazarus\fpc\3.0.4\bin\x86_64-win64\fpc.cfg<o:p></o:p></pre><pre>Hint: (11031) End of reading config file C:\lazarus\fpc\3.0.4\bin\x86_64-win64\fpc.cfg<o:p></o:p></pre><pre>Free Pascal Compiler version 3.0.4 [2019/02/03] for x86_64<o:p></o:p></pre><pre>Copyright (c) 1993-2017 by Florian Klaempfl and others<o:p></o:p></pre><pre>(1002) Target OS: Win64 for x64<o:p></o:p></pre><pre>(3104) Compiling test1library.pas<o:p></o:p></pre><pre>(9015) Linking E:\03_travail\libusb\pas-libusb\src\examples\test1library.exe<o:p></o:p></pre><pre>Error: Multiple defined symbol .refptr.usbi_backend<o:p></o:p></pre><pre>Error: Multiple defined symbol .refptr.usbi_backend<o:p></o:p></pre><pre>Error: Multiple defined symbol .refptr.usbi_default_context<o:p></o:p></pre><pre>Error: Multiple defined symbol .refptr.INVALID_WINFD<o:p></o:p></pre><pre>Error: Multiple defined symbol .refptr.pCancelIoEx<o:p></o:p></pre><pre>Error: Multiple defined symbol .refptr.__tens_D2A<o:p></o:p></pre><pre>Error: Multiple defined symbol .refptr.__hexdig_D2A<o:p></o:p></pre><pre>Error: Undefined symbol: atexit<o:p></o:p></pre><pre>Fatal: (10026) There were 8 errors compiling module, stopping<o:p></o:p></pre><pre>Fatal: (1018) Compilation aborted<o:p></o:p></pre><pre>Error: C:\lazarus\fpc\3.0.4\bin\x86_64-win64\ppcx64.exe returned an error exitcode<o:p></o:p></pre><p class=MsoNormal><o:p> </o:p></p></div></body></html>