Skip to content

cross-compiling on Linux to Win32/64 target #281

Open
@efa

Description

@efa

hi,
I downloaded the nightly:
harbour-nightly-win.7z | 2022-10-17
and extracted to /home/efa/c/harbour_win32

I'm using this script to cross-build:

if (test "" = "$1") then
   echo ERROR: harbour need a PRG file name
   echo "Syntax: $ harbour <source.prg> [win [32]]|[mac [arm]]"
   exit
fi

deps="hbct.hbc xhb.hbc"
if (test "$2" = "win") then
   # set env vars for mingw ...
   if (test "$3" = "32") then
      echo "Cross-building for Win32 ..."
      export HOST=i686-w64-mingw32
   else
      echo "Cross-building for Win64 ..."
      export HOST=x86_64-w64-mingw32
   fi
   export CROSS=${HOST}-
   export CC=${CROSS}gcc

   # set env vars for harbour ...
   export HB_WITH_CURSES=no
   export HB_BUILD_3RDEXT=no
   export HB_BUILD_CONTRIBS=no
   export HB_BUILD_DYN=no
   export HB_BUILD_NAME=$HOST
   export HB_CCPATH=/usr/bin/
   export HB_CCPREFIX=$CROSS
   export HB_COMPILER=mingw64 # or mingw, clang
   export HB_CPU=x86-64 # or x86
   if (test "$3" = "32") then
      export HB_COMPILER=mingw # or mingw, clang
      export HB_CPU=x86
   fi
   export HB_HOST_BIN=$HOME/c/harbour-core/bin/linux/gcc
   export HB_PLATFORM=win
  #export HB_USER_CFLAGS=--sysroot=%SYSROOT%
   export HB_USER_LDFLAGS="-L$HOME/c/harbour_win32/lib/win/mingw"
fi
echo "Running: $HOME/c/harbour-core/bin/linux/gcc/hbmk2 -workdir=. -inc $1 $deps"
$HOME/c/harbour-core/bin/linux/gcc/hbmk2 -workdir=. -inc $1 $deps

while build to Win32 work:

$ harbour SNATOTAP.PRG win 32
Cross-building for Win32 ...
Running: /home/efa/c/harbour-core/bin/linux/gcc/hbmk2 -workdir=. -inc SNATOTAP.PRG hbct.hbc xhb.hbc
hbmk2: Processing environment options: -plat=win -comp=mingw -cpu=x86
       -build=i686-w64-mingw32
hbmk2: Compiling Harbour sources...
Harbour 3.2.0dev (r-2084736466)
Copyright (c) 1999-2021, https://harbour.github.io/
Compiling 'SNATOTAP.PRG'...
Lines 951, Functions/Procedures 4
Generating C source output to './SNATOTAP.c'... Done.
hbmk2: Compiling...
hbmk2: Linking... SNATOTAP.exe

I got linking error targeting 64 bit Windows:

$ harbour SNATOTAP.PRG win
Cross-building for Win64 ...
Running: /home/efa/c/harbour-core/bin/linux/gcc/hbmk2 -workdir=. -inc SNATOTAP.PRG hbct.hbc xhb.hbc
hbmk2: Processing environment options: -plat=win -comp=mingw64 -cpu=x86-64
       -build=x86_64-w64-mingw32
hbmk2: Compiling Harbour sources...
Harbour 3.2.0dev (r-2084736466)
Copyright (c) 1999-2021, https://harbour.github.io/
Compiling 'SNATOTAP.PRG'...
Lines 951, Functions/Procedures 4
Generating C source output to './SNATOTAP.c'... Done.
hbmk2: Compiling...
hbmk2: Linking... SNATOTAP.exe
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /home/efa/c/harbour_win32/lib/win/mingw/libhbct.a when searching for -lhbct
....
/usr/bin/x86_64-w64-mingw32-ld: skipping incompatible /home/efa/c/harbour_win32/lib/win/mingw/libhbmainstd.a when searching for -lhbmainstd
collect2: error: ld returned 1 exit status
hbmk2: Error: Running linker. 1
/usr/bin//x86_64-w64-mingw32-gcc ./SNATOTAP.o ./_hbmkaut_SNATOTAP.o   -L/home/efa/c/harbour_win32/lib/win/mingw -mconsole -Wl,--start-group -lhbct -lxhb -lhbtip -lhbfship -lhbxpp -lhbwin -lpng -lhbextern -lhbdebug -lhbvm -lhbrtl -lhblang -lhbcpage -lgtcgi -lgtpca -lgtstd -lgtwin -lgtwvt -lgtgui -lhbrdd -lhbuddall -lhbusrrdd -lrddntx -lrddcdx -lrddnsx -lrddfpt -lhbrdd -lhbhsx -lhbsix -lhbmacro -lhbcplr -lhbpp -lhbcommon -lhbmainstd -lwinmm -lkernel32 -luser32 -lgdi32 -ladvapi32 -lws2_32 -liphlpapi -lwinspool -lcomctl32 -lcomdlg32 -lshell32 -luuid -lole32 -loleaut32 -lmpr -lmapi32 -limm32 -lmsimg32 -lwininet   -Wl,--end-group -oSNATOTAP.exe  -L/home/efa/c/harbour-core/lib

Is the nightly package 32 bit only?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions