How to compile the minrtl304 example for 64bit windows ? lazarus / 62-General ---------------------------------------------------------------------- 440bx · 2018-11-05 23:49 Hello, I'm trying to compile (and run) the test program found in "minrtl304.zip" of the following thread https://forum.lazarus.freepascal.org/index.php/topic,41722.msg290584.h tml#msg290584 I've left everything exactly the way it was, with two exceptions.  I changed the command found in a.bat as shown below: Code: [Select]Original command line (found in a.bat) fpc.exe -va -Xs -XX -Os1 .\test.pas changed to compile for 64bit to fpc.exe -va -Xs -XX -Os1 -TWin64 -Px86_64 .\test.pas The other "change" is that I copied ppcrossx64.exe into the directory where test.pas is (thereby matching the 32bit setup/configuration.) When compiling for 32bit, everything works great.  When compiling for 64bit, I get the following: Code: [Select]lots and lots of information above... [0.266] Reading object system.o [0.269] Number of unresolved externals in objects 3 [0.270] Number of unresolved externals after static libraries 3 [0.271] Number of unresolved externals after defining symbols provided by link script 3 [0.274] Number of unresolved externals after defining COMMON symbols 3 vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv [0.276] test.pas(3,1) Error: Entrypoint _mainCRTStartup not defined ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [0.277] Number of unresolved externals after DLL imports 0 [0.278] test.pas(3,1) Fatal: There were 1 errors compiling module, stopping [0.280] Fatal: Compilation aborted Error: Z:\Training\freepascal - minrtl304\minrtl304\ppcrossx64.exe returned an error exitcode When compiling for 32bit, the compiler (and linker) seems to find _mainCRTStartup just fine. When compiling for 64bit, the compiler/linker complains about not finding _mainCRTStartup even though it is defined in sysinitpas.pas. My question is: what do I have to do to make the linker find _mainCRTStartup so, the linker and I can both be happy ;-) Thank you for your help. ---------------------------------------------------------------------- engkin · 2018-11-06 19:45 Warning: I don't use 64bit. Quote from: 440bx on November 06, 2018, 12:49:02 amWhen compiling for 64bit, the compiler/linker complains about not finding _mainCRTStartup even though it is defined in sysinitpas.pas. Regarding sysinitpas, let me quote the compiler source code (for Windows): 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 //compiler\systems\t_win.pas  Procedure GlobalInitSysInitUnitName(Linker : TLinker);...      if cs_profile in current_settings.moduleswitches then        linker.sysinitunit:='sysinitgprof'      else if linkcygwin or (Linker.SharedLibFiles.Find('cygwin')<>nil) or (Linker.StaticLibFiles.Find('cygwin')<>nil) then        linker.sysinitunit:='sysinitcyg'      else        linker.sysinitunit:='sysinitpas';    end; As you can see, the name of the unit that contains _mainCRTStartup (or its equivalent) is not necessarily sysinitpas. I guess you can find the name of the unit if you check the produced compiler script (adding -s, I believe). Probably the last unit in the INPUT section. If my guess is right, then giving sysinitpas the expected name should solve finding _mainCRTStartup issue. ---------------------------------------------------------------------- 440bx · 2018-11-06 21:15 Quote from: engkin on November 06, 2018, 08:45:41 pmI guess you can find the name of the unit if you check the produced compiler script (adding -s, I believe). Probably the last unit in the INPUT section. If my guess is right, then giving sysinitpas the expected name should solve finding _mainCRTStartup issue. Engkin, thank you!  ... that looks like enough information for me to make it work.  I appreciate it.