Author Topic: newbie here, need help in compiling to 64-bit  (Read 3284 times)

jbk

  • Full Member
  • ***
  • Posts: 226
    • View Profile
newbie here, need help in compiling to 64-bit
« on: February 02, 2020, 06:25:21 PM »
after some trial an error I managed to compile to 32-bit, but how do I compile for 64-bit?
specifically this web app here https://bcxbasiccoders.com/smf/index.php?topic=94.msg340#msg340
I have Mingw32 and Mingw64 (msys2), PellesC x64 and lcc x64 installed
I edited PW.bat replacing x86 with x64 but I get the error "BCX_SlideShow.c(443): error #2206: No support for inline assembly code on this target machine."
PW.bat modified
Code: [Select]
setlocal
@rem Created with Bldbat v.3.0.0 for PellesC (GUI)
@ECHO OFF
IF NOT EXIST %1.c GOTO usage
CALL "C:\Program Files\PellesC\Bin\povars64.bat"
IF EXIST %1.res GOTO res
IF NOT EXIST "res\%~1.rc" GOTO nores
ECHO Compiling resources.....
"C:\Program Files\PellesC\Bin\porc.exe" "res\%~1.rc" /i res /fo "%~1.res"
:res
IF EXIST %1.res SET PRES="%~1.res"
:nores
ECHO Compiling "%~1.c"..........
"C:\Program Files\PellesC\Bin\pocc.exe" /W0 /Ot /Go /Gd /Ze /Zx /Tx64-coff "%~1.c"
ECHO Linking ................
"C:\Program Files\PellesC\Bin\polink.exe" /release /machine:x64 /subsystem:windows "%~1.obj" %PRES% %2 %3 %4 %5 %6 %7 %8 %9 /out:"%~1.exe"
ECHO Finished!
IF EXIST "%~1.obj" del "%~1.obj"
GOTO done
:usage
ECHO **************************************************************
ECHO  Usage:  PW.BAT MainFile  ExtraFile1 ExtraFile2 ExtraFile3
ECHO  Note:   ExtraFiles can be .libs, .res , .obj
ECHO          Compile a GUI mode program with Pelle's C.
ECHO **************************************************************
:done
endlocal
« Last Edit: February 02, 2020, 06:31:04 PM by jbk »

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 2104
    • View Profile
Re: newbie here, need help in compiling to 64-bit
« Reply #1 on: February 02, 2020, 07:01:51 PM »
Any BCX code that you find that uses Dynaload can only be compiled for 32-bit. 

For example, inside BCX_Browser.bi you will find several examples of this, such as :

 AtlAxWinInit (LIB DllPath$)   ... the LIB tells you that BCX is using Dynaload, part of the BCX runtime library.



Below is my batch file for compiling a 64-bit GUI app using Pelles C 9.0

You might need to edit the PATHS


Code: [Select]
@ECHO off
IF NOT EXIST %1.c GOTO Usage

SET  PellesCDir=C:\PellesC
SET  PATH=%PellesCDir%\Bin;%PATH%
SET  INCLUDE=%PellesCDir%\Include;%PellesCDir%\Include\Win;%INCLUDE%
SET  LIB=%PellesCDir%\Lib;%PellesCDir%\Lib\Win64;%LIB%

SET  PoccOPTS=/Go /Gn /W1 /Gd /Ze /Zx -Tamd64-coff /D_WIN32_WINNT=0x501  /std:c17
SET  PolinkOPTS=/release /machine:X64 /subsystem:windows,5.01 /STACK:10485760               
SET  PolinkLIBS=kernel32.lib advapi32.lib delayimp.lib user32.lib gdi32.lib comctl32.lib comdlg32.lib ole32.lib oleaut32.lib
 

ECHO Pelles C is compiling %1 as a 64-bit Gui app
call c:\pellesc\bin\pocc   %PoccOPTS%    %1.c
call c:\pellesc\bin\polink %PolinkLIBS%  %PolinkOPTS%    %1.obj %2 %3 %4 %5 %6 %7 %8 %9
ECHO Completed ...
GOTO done


:Usage
ECHO **************************************************************
ECHO  For building 64-bit Gui apps using Pelles C Compiler
ECHO  Usage:   PW64   "C" FileName  [Optional Linker Files: 2-9]
ECHO  Example: PW64    MyGuiApp      MyIcons.res   MyManifest.res
ECHO **************************************************************
:done






jbk

  • Full Member
  • ***
  • Posts: 226
    • View Profile
Re: newbie here, need help in compiling to 64-bit
« Reply #2 on: February 02, 2020, 07:10:43 PM »
thanks MrBcx  :)

Cran0g

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: newbie here, need help in compiling to 64-bit
« Reply #3 on: August 23, 2023, 04:57:17 PM »
Hi MrBCX,

I tried thid with BCX-Win.  It worked just fine.  Many thanks for that!

An interesting point, though - I noticed that the UPX packer won't compress the exe:  "Unexpected value in PE header".  And if you try to use the --force flag, it gives a different message - ".NET files (win32/net) are not yet supported" - but still won't compress.

Any thoughts on this?

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 2104
    • View Profile
Re: newbie here, need help in compiling to 64-bit
« Reply #4 on: August 23, 2023, 06:23:25 PM »
Hi MrBCX,

I tried this with BCX-Win.  It worked just fine.  Many thanks for that!

An interesting point, though - I noticed that the UPX packer won't compress the exe:  "Unexpected value in PE header".  And if you try to use the --force flag, it gives a different message - ".NET files (win32/net) are not yet supported" - but still won't compress.

Any thoughts on this?


Patient:  Doctor, it hurts when I do this.

Doctor:  Don't do that.

-- it seems clear that users of various exe packers have been reporting that error literally for decades.

It's definitely not a BCX problem and almost certainly not a problem caused by any of the popular c\c++ compilers.
If you're dead set on using UPX, one thing you can try is to first create a self-extracting exe and then
use UPX on that.  I know, that sounds silly, but I'll bet you a can of chicken beaks that it would work.

Ref: Unexpected value in PE

https://www.google.com/search?q=%22Unexpected+value+in+PE+header%22&newwindow=1&client=firefox-b-1-d&sca_esv=559545509&sxsrf=AB5stBivlo2UWe0U0Rx-0tgFeRSzxIoICQ:1692836545169&filter=0&biw=1222&bih=583&dpr=1.4
« Last Edit: August 23, 2023, 10:36:56 PM by MrBcx »

Cran0g

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: newbie here, need help in compiling to 64-bit
« Reply #5 on: August 24, 2023, 04:46:16 AM »
LOL

I (clearly) didn't know that.  But, for the record, I didn't think it was a BCX issue.

I'm not "dead set" on UPX, although I've found it useful in the past when I've been programming in assembly.

But, as a matter of fact, I discovered as a result of your reply, that I hadn't updated UPX in a while.  I downloaded their most recent one from sourceforge and it now works just fine when you choose the 64-bit variant.

So ... result.

Many thanks.

MrBcx

  • Administrator
  • Hero Member
  • *****
  • Posts: 2104
    • View Profile
Re: newbie here, need help in compiling to 64-bit
« Reply #6 on: August 24, 2023, 07:09:56 AM »
LOL

I (clearly) didn't know that.  But, for the record, I didn't think it was a BCX issue.

I'm not "dead set" on UPX, although I've found it useful in the past when I've been programming in assembly.

But, as a matter of fact, I discovered as a result of your reply, that I hadn't updated UPX in a while.  I downloaded their most recent one from sourceforge and it now works just fine when you choose the 64-bit variant.

So ... result.

Many thanks.


Glad you got it sorted out. I stopped using UPX more than a decade ago. 

In this age of multi-terabyte SSD's and the like, UPX seems (mostly) pointless to me.