Conflict when static linking in external linker
lazarus / 67-Windows
----------------------------------------------------------------------
sollapse · 2024-03-08 13:53
I'm attempting to compile an test app using the PortMidi library. I've
compiled it statically using TDM64-GCC. When statically linking the
library along with the necessary MingW32 libs using the -Xe option,
the project compiles and runs normally as a bare bones console app.
When I attempt to compile the app including the LCL for GUI, the
external linker throws an error while attempting to link an object
file from the Windows API it seems. This external linker error also
occurs whether statically linking the library or not adding it to the
project at all. Why does it error out when linking LCL on Windows?
I've included a test project file with all the necessary static libs
also.
----------------------------------------------------------------------
Thaddy · 2024-03-08 18:28
I got a virus warning on the download. Please remove executables, but
not the libraries.
(and yes, ms defender can scan 7z in windows 11.)
Can obviously be a false positive.
[edit]
It is a positive. DO NOT DOWNLOAD
I checked it in clean room
----------------------------------------------------------------------
sollapse · 2024-03-08 18:46
I actually removed the exe from the file before posting to get within
the size limit. It's just the static libraries and project
files/source.
----------------------------------------------------------------------
Thaddy · 2024-03-08 18:53
I just found out the libraries are not safe. (I am CEH certified) Plz
remove all binaries and provide links to where to get them, As is,
nobody will download this. (except me, because I have a clean room,
Hotel California style: You can enter but never leave, or better
Sartre, Huit Clos, where the Eagles stole it from)
----------------------------------------------------------------------
sollapse · 2024-03-08 21:32
That's very odd. I just compiled the PortMidi library from the source
using the Github master. If I host them on my own Github, it'll be the
exact same static's. Can't you just test it in a sandbox environment?
The bug is not with static linking PortMidi per se, but linking with
the external linker option referencing LCL. It crashes while linking
the Windows API object files included with FPC. If you can compile
your own test application that links with LCL using the -Xe option,
you should see the explicit error(s) I'm speaking of. PortMidi isn't
necessary at all to replicate the issue. Are you also able to share
your endpoint threat assessment of the files with me for my own
reference?
----------------------------------------------------------------------
Tomas Hajny · 2024-03-08 21:39
Hi,
I removed the attachment to stay on the safe side. Please, provide
input containing just sources, not precompiled libraries. If external
binary libraries are necessary, reference their original source
location (just the source site, not URL of the binary file).
Tomas
(one of forum moderators)
----------------------------------------------------------------------
sollapse · 2024-03-08 22:00
Will do. I'll copy the project/source file once I get home sans the
PortMidi library.
----------------------------------------------------------------------
sollapse · 2024-03-11 21:30
Sorry for the delay. I've pasted the test code for a basic console app
which links LCL, and the project file.
project2.lpi
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i
project2.lpr
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i program
project2; {$mode objfpc}{$H+} usesSysUtils, Forms,
Interfaces; //{$linklib portmidi}//{$linklib msvcr120}//{$linklib
kernel32}//{$linklib winmm} //function Pm_CountDevices(): Integer ;
cdecl; external; beginWriteLn('Test');end.
project2.lps
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i
----------------------------------------------------------------------
sollapse · 2024-03-13 20:07
I've included the output from the compilation. It tends to freeze when
importing an object file from the Windows API.
Code: Pascal [Select][+][-]window.onload = function(){var x1 =
document.getElementById("main_content_section"); if (x1) { var x =
document.getElementsByClassName("geshi");for (var i = 0; i
(C:\fpcupdeluxe\fpc\units\x86_64-win64\winunits-
base\libimpcommctrl.a)impcommctrl1t75.oattempt to open
C:\fpcupdeluxe\fpc\units\x86_64-win64\rtl\libimpdos.a succeededattempt
to open
C:\fpcupdeluxe\lazarus\lcl\units\x86_64-win64\win32\libimpwin32int.a
succeededattempt to open
C:\fpcupdeluxe\lazarus\lcl\units\x86_64-win64\win32\libimpwin32extra.a
succeededattempt to open C:\fpcupdeluxe\fpc\units\x86_64-
C:\fpcupdeluxe\projects\project2\project2.lpr(18,1) Error: (9013)
Error while linkingC:\fpcupdeluxe\projects\project2\project2.lpr(18,1)
Fatal: (10026) There were 1 errors compiling module, stoppingFatal:
(1018) Compilation abortedError:
C:\fpcupdeluxe\fpc\bin\x86_64-win64\ppcx64.exe returned an error
exitcode
----------------------------------------------------------------------
tetrastes · 2024-03-18 13:15
I've downloaded your .lpi and .lpr and compiled in Lazarus 3.2 without
any problem, except an enormous size of the resulting binary.
Just out of curiosity, I've successfully compiled the simplest default
one-form GUI project with -Xe option also.
----------------------------------------------------------------------
sollapse · 2024-03-18 16:43
Quote from: tetrastes on March 18, 2024, 02:15:13 pmI've downloaded
your .lpi and .lpr and compiled in Lazarus 3.2 without any problem,
except an enormous size of the resulting binary.
Just out of curiosity, I've successfully compiled the simplest default
one-form GUI project with -Xe option also.
Are you able to say which version of the compiler you're running? I'm
using a trunk version compiled with FPCUPDeluxe.
----------------------------------------------------------------------
tetrastes · 2024-03-18 18:42
I use stable fpc 3.2.2 installed from official Lazarus distribution ht
tps://sourceforge.net/projects/lazarus/files/Lazarus%20Windows%2064%20
bits/Lazarus%203.2/.
----------------------------------------------------------------------
tetrastes · 2024-03-18 21:05
It seems that the issue is related to Lazarus version. With Lazarus
2.2.2 fpc 3.2.2 I get similar error.
----------------------------------------------------------------------
sollapse · 2024-03-22 15:18
Quote from: tetrastes on March 18, 2024, 10:05:28 pmIt seems that the
issue is related to Lazarus version. With Lazarus 2.2.2 fpc 3.2.2 I
get similar error.
I've recompiled FPC and Lazarus from the latest trunk versions under
Gitlab and it seems that static linking works correctly with the
internal linker now. The external linker still fails with LCL, but the
internal one will work fine for my needs.