Is the static linking issue just with Windows, and it works on Linux, or it 
isn’t working with FPC at all on either?

 

James

 

From: fpc-pascal <fpc-pascal-boun...@lists.freepascal.org> On Behalf Of Jean 
SUZINEAU
Sent: Thursday, August 8, 2019 5:40 AM
To: fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] USB Human Interface Devices

 

Static linking :

 

Le 05/08/2019 à 21:38, Johann Glaser a écrit :

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.

 

Could you please also have a look at his comments in that Github issue?

For now I couldn't achieve static linking.

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.

I used MSYS2 (https://www.msys2.org/) in which I installed the following 
packages:

 pacman -S mingw64/mingw-w64-x86_64-libusb
 pacman -S mingw-w64-x86_64-headers-git
 pacman -S mingw-w64-x86_64-crt-git
 pacman -S mingw-w64-x86_64-gcc
 
In LibUsb.pas I changed the $LINKLIBs to (the errors removed by a particular 
$LINKLIB are after //Error: ) :  
{$LINKLIB usb-1.0}
{$ifdef windows}
  {$LINKLIB mingwex} //Error: Undefined symbol: __mingw_vsnprintf, 
__mingw_vsprintf, __mingw_vsscanf
  //{$LINKLIB mingw32} //doesn't improve anything
  {$LINKLIB kernel32} // Error: Undefined symbol: __imp_TlsGetValue,  
__imp_EnterCriticalSection, __imp_LeaveCriticalSection, ... +41 others
  {$LINKLIB advapi32}   // Error: Undefined symbol: __imp_OpenSCManagerA, 
__imp_OpenServiceA, __imp_CloseServiceHandle
  //{$LINKLIB winpthread} //doesn't improve anything
  //{$LINKLIB stdc++} //doesn't improve anything
  {$LINKLIB gcc} //Error: Undefined symbol: ___chkstk_ms
  {$LINKLIB crtdll} //Error: malloc, memcpy, ... + 37 others
  //{$LINKLIB msvcrt} //same as crtdll, Error: malloc, memcpy, ... + 37 
others{$else}
  {$LINKLIB c}
{$endif}
 
Here are the errors of the compilation, it's the minimu I could obtain:
 
Hint: (11030) Start of reading config file 
C:\lazarus\fpc\3.0.4\bin\x86_64-win64\fpc.cfg
Hint: (11031) End of reading config file 
C:\lazarus\fpc\3.0.4\bin\x86_64-win64\fpc.cfg
Free Pascal Compiler version 3.0.4 [2019/02/03] for x86_64
Copyright (c) 1993-2017 by Florian Klaempfl and others
(1002) Target OS: Win64 for x64
(3104) Compiling test1library.pas
(9015) Linking E:\03_travail\libusb\pas-libusb\src\examples\test1library.exe
Error: Multiple defined symbol .refptr.usbi_backend
Error: Multiple defined symbol .refptr.usbi_backend
Error: Multiple defined symbol .refptr.usbi_default_context
Error: Multiple defined symbol .refptr.INVALID_WINFD
Error: Multiple defined symbol .refptr.pCancelIoEx
Error: Multiple defined symbol .refptr.__tens_D2A
Error: Multiple defined symbol .refptr.__hexdig_D2A
Error: Undefined symbol: atexit
Fatal: (10026) There were 8 errors compiling module, stopping
Fatal: (1018) Compilation aborted
Error: C:\lazarus\fpc\3.0.4\bin\x86_64-win64\ppcx64.exe returned an error 
exitcode

 

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to