Skip to content

Conversation

@rboy1
Copy link
Contributor

@rboy1 rboy1 commented Aug 18, 2025

In raising this pull request, I confirm the following (please check boxes):

  • [X ] I have read and understood the contributors guide.
  • [X ] I have checked that another pull request for this purpose does not exist.
  • [X ] I have considered, and confirmed that this submission will be valuable to others.
  • [X ] I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
  • [X ] I give this submission freely, and claim no ownership to its content.
  • [X ] I have mentioned this change in the changelog.

My familiarity with the project is as follows (check one):

  • I have never used CCExtractor.
  • I have used CCExtractor just a couple of times.
  • I absolutely love CCExtractor, but have not contributed previously.
  • [X ] I am an active contributor to CCExtractor.

Fixed build script for cross compiling using MinGW-w64
Some file path's and headers are specific to VS, MinGW provides them natively, updated CMakeFile and source code to differentiate between MS/VS environments and MinGW environments.

@rboy1
Copy link
Contributor Author

rboy1 commented Aug 18, 2025

Tested cross compilation with Ubuntu 22.04 and MinGW-w64 x86_64 and MXE

@rboy1
Copy link
Contributor Author

rboy1 commented Aug 20, 2025

@cfsmp3

@steel-bucket
Copy link
Contributor

Hi, can you rebase, push the rebase, and run the command(this could be found in the format directory as well)

find src/ -type f -not -path "src/thirdparty/*" -not -path "src/lib_ccx/zvbi/*" -name '*.c' -not -path "src/GUI/icon_data.c" | xargs clang-format -i
          git diff-index --quiet HEAD -- || (git diff && exit 1)

in the root directory(./ccextractor).
And then push again.
This will automatically fix the 2 failing CI tests.

@rboy1
Copy link
Contributor Author

rboy1 commented Aug 22, 2025

The pull request was done directly via github web, I've resynced the fork with the latest master and hopefully that should be enough

@rboy1
Copy link
Contributor Author

rboy1 commented Aug 22, 2025

Hi, can you rebase, push the rebase, and run the command(this could be found in the format directory as well)

find src/ -type f -not -path "src/thirdparty/*" -not -path "src/lib_ccx/zvbi/*" -name '*.c' -not -path "src/GUI/icon_data.c" | xargs clang-format -i
          git diff-index --quiet HEAD -- || (git diff && exit 1)

in the root directory(./ccextractor). And then push again. This will automatically fix the 2 failing CI tests.

What exactly is this format test? The formatting was for the changes matched the formatting for the existing file.

@steel-bucket
Copy link
Contributor

steel-bucket commented Aug 22, 2025

What exactly is this format test?

Actually it just runs a better version of CLANG format.
The formatting still isn't correct.
You could just run this

git clone https://github.com/rboy1/ccextractor -b patch-4
find ...(the command from before)
git add -A && git commit -m "..."
//git remote set-url origin using ssh
git push origin patch-4

@rboy1
Copy link
Contributor Author

rboy1 commented Aug 22, 2025

It's making a LOT of changes to the formatting of the existing code unrelated to this patch. Maybe that should be handled separately to avoid confusion.

formatting changes a recommended by the clang test
@rboy1
Copy link
Contributor Author

rboy1 commented Aug 22, 2025

What exactly is this format test?

Actually it just runs a better version of CLANG format. The formatting still isn't correct. You could just run this

git clone https://github.com/rboy1/ccextractor -b patch-4
find ...(the command from before)
git add -A && git commit -m "..."
//git remote set-url origin using ssh
git push origin patch-4

I've made the one correction to the formatting of the changes as recommended by the script you provided above related to the changes made in this patch. The rest of the formatting changes recommended aren't related to this patch.

@steel-bucket
Copy link
Contributor

steel-bucket commented Aug 22, 2025

Works now. 🎉

@prateekmedia prateekmedia requested a review from Copilot August 24, 2025 16:07
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes cross-compilation issues when using MINGW-w64 by adding proper conditional compilation directives to handle differences between MSVC and MINGW build environments.

  • Adds conditional includes for iconv.h to use native MINGW headers instead of bundled win_iconv
  • Prevents redefinition of ssize_t type that is natively provided by MINGW
  • Updates CMake configuration to exclude MSVC-specific include directories for MINGW builds

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/lib_ccx/ts_tables_epg.c Adds MINGW-specific iconv header inclusion
src/lib_ccx/ccx_encoders_common.h Adds MINGW-specific iconv header inclusion
src/lib_ccx/ccx_common_platform.h Guards ssize_t typedef to prevent redefinition in MINGW
src/CMakeLists.txt Excludes MSVC-specific include directory for MINGW builds
docs/CHANGES.TXT Documents the MINGW-w64 cross-compilation fix

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@ccextractor-bot
Copy link
Collaborator

CCExtractor CI platform finished running the test files on windows. Below is a summary of the test results, when compared to test for commit a34ba0f...:
Report Name Tests Passed
Broken 13/13
CEA-708 14/14
DVB 4/7
DVD 3/3
DVR-MS 2/2
General 27/27
Hauppage 3/3
MP4 3/3
NoCC 10/10
Options 86/86
Teletext 21/21
WTV 10/13
XDS 34/34

NOTE: The following tests have been failing on the master branch as well as the PR:

  • ccextractor --stdout --quiet --no-fontcolor 79a51f3500..., Last passed:

    Never

  • ccextractor --stdout --quiet --no-fontcolor 767b546f96..., Last passed:

    Never

  • ccextractor --autoprogram --out=srt --latin1 --quant 0 85271be4d2..., Last passed:

    Never

  • ccextractor --out=srt --latin1 f23a544ba8..., Last passed:

    Never

  • ccextractor --out=srt --latin1 10f0f77cf4..., Last passed:

    Test 5993

  • ccextractor --out=srt --latin1 df3b4d62d3..., Last passed:

    Never


All tests passing on the master branch were passed completely.

Check the result page for more info.

@rboy1
Copy link
Contributor Author

rboy1 commented Aug 25, 2025

@steel-bucket is something amiss here or is it good to commit? I see the test have passed but the Linux build was aborted.

@steel-bucket
Copy link
Contributor

For the linux regression not running, it's most probably an issue with the sample platform and not your PR.

@ccextractor-bot
Copy link
Collaborator

CCExtractor CI platform finished running the test files on linux. Below is a summary of the test results, when compared to test for commit 4b5f68a...:
Report Name Tests Passed
Broken 13/13
CEA-708 14/14
DVB 7/7
DVD 3/3
DVR-MS 2/2
General 27/27
Hauppage 3/3
MP4 3/3
NoCC 10/10
Options 86/86
Teletext 21/21
WTV 13/13
XDS 34/34

All tests passing on the master branch were passed completely.

Check the result page for more info.

@rboy1
Copy link
Contributor Author

rboy1 commented Aug 26, 2025

Looks like it's good now

@rboy1
Copy link
Contributor Author

rboy1 commented Aug 30, 2025

@hrideshmg these are the changes needed to build using MinGW

@rboy1
Copy link
Contributor Author

rboy1 commented Sep 2, 2025

@prateekmedia is this good for a commit? It's the only way to build a static version of ccextractor for windows ATM

@prateekmedia
Copy link
Member

@rboy1 can you confirm if the steps you used for verifying this is similar to our build windows workflow or you used different commands?

Like did you used Visual Studio along with vcpkg to build on Windows?

@rboy1
Copy link
Contributor Author

rboy1 commented Sep 2, 2025

Yes it's a similar workflow, except using MinGW-w64 (vs MsBuild or VS) and MXE (vs vcpkg) to build it and the dependencies. Essentially cross compiling for windows in Ubuntu.

@prateekmedia
Copy link
Member

@rboy1 This seems interesting workflow, could you also add this to compilation steps and in wiki? I will merge this after that. Seems like a good addition and something we don't do.

Copy link
Member

@prateekmedia prateekmedia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! We can later add more docs regarding this method.

@prateekmedia prateekmedia merged commit 1c7e2a0 into CCExtractor:master Sep 13, 2025
17 checks passed
@rboy1
Copy link
Contributor Author

rboy1 commented Sep 30, 2025

@rboy1 This seems interesting workflow, could you also add this to compilation steps and in wiki? I will merge this after that. Seems like a good addition and something we don't do.

Here's a script you can use to cross build a static windows release using MXE on Ubuntu 22.04 with the GUI. This doesn't use RUST, so it may need to tweaked to build with RUST

#!/bin/bash

# CCExtractor Windows 64-bit Cross-Compilation Script for Ubuntu 22.04
# Features enabled: OCR, Hardsubx
# Features disabled: FFmpeg, Rust, GUI, Sharing

set -e  # Exit on any error

# Color codes for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color

# Function to print colored output
print_status() {
    echo -e "${BLUE}[INFO]${NC} $1"
}

print_success() {
    echo -e "${GREEN}[SUCCESS]${NC} $1"
}

print_warning() {
    echo -e "${YELLOW}[WARNING]${NC} $1"
}

print_error() {
    echo -e "${RED}[ERROR]${NC} $1"
}

# Configuration
WORK_DIR="$HOME/ccextractor-build"
MXE_DIR="$WORK_DIR/mxe"
CCEXTRACTOR_DIR="$WORK_DIR/CCExtractor"
TARGET="x86_64-w64-mingw32.static"

print_status "Starting CCExtractor Windows cross-compilation setup..."

# Step 1: Update system and install dependencies
print_status "Step 1: Installing system dependencies..."
sudo apt-get update
sudo apt-get install -y \
    autoconf \
    autoconf-archive \
    automake \
    autopoint \
    autotools-dev \
    bash \
    bison \
    build-essential \
    cmake \
    cmake-data \
    flex \
    g++ \
    g++-multilib \
    gettext \
    git \
    gperf \
    intltool \
    libc6-dev-i386 \
    libgdk-pixbuf2.0-dev \
    libltdl-dev \
    libssl-dev \
    libtool-bin \
    libxml-parser-perl \
    lzip \
    make \
    python3-mako \
    openssl \
    p7zip-full \
    patch \
    perl \
    pkg-config \
    python3 \
    ruby \
    sed \
    unzip \
    wget \
    xz-utils

print_status "Checking for python link"
if [ ! -f "$(which python)" ]; then
    sudo ln -sf "$(which python3)" "/usr/bin/python"
    print_status "Created link for /usr/bin/python to $(which python3)"
fi

# Step 2: Create working directory
print_status "Step 2: Setting up working directory..."
mkdir -p "$WORK_DIR"
cd "$WORK_DIR"

# Step 3: Clone and setup MXE
print_status "Step 3: Cloning and setting up MXE..."
if [ ! -d "$MXE_DIR" ]; then
    git clone https://github.com/mxe/mxe.git
    cd "$MXE_DIR"
else
    print_warning "MXE directory already exists, updating..."
    cd "$MXE_DIR"
    git pull
fi

# Step 4: Build MXE dependencies
print_status "Step 4: Building MXE cross-compilation toolchain..."
print_warning "This step can take 30-60 minutes depending on your system..."

# Build the cross-compiler and essential libraries
print_status "Building MXE cross-compiler toolchain and libraries..."
MXE_BUILD_LIBS=(
    "cc"
    "cmake"
    "pkgconf"
    "zlib"
    "libpng"
    "jpeg"
    "tiff"
    "freetype"
    "fontconfig"
    "ffmpeg"
    "libiconv"
)
for MXE_LIB in "${MXE_BUILD_LIBS[@]}"; do
    if make -j$(nproc) MXE_TARGETS="$TARGET" "$MXE_LIB" 2>/dev/null; then
        print_success "$MXE_LIB built successfully with MXE"
    else
        print_warning "$MXE_LIB not available in MXE"
        exit 1
    fi
done

# Check if GPAC is available in MXE
print_status "Checking for GPAC in MXE..."
if make MXE_TARGETS="$TARGET" gpac 2>/dev/null; then
    print_success "GPAC built successfully with MXE"
    BUILD_GPAC_MANUALLY=false
else
    print_warning "GPAC not available in MXE, will build manually"
    BUILD_GPAC_MANUALLY=true
fi

# Check if tesseract is available in MXE, if not we'll build OCR dependencies manually
print_status "Checking for Tesseract in MXE..."
if make MXE_TARGETS="$TARGET" tesseract 2>/dev/null; then
    print_success "Tesseract built successfully with MXE"
else
    print_warning "Tesseract not available in MXE, will build leptonica and tesseract manually"
    BUILD_OCR_MANUALLY=true
fi

# Step 5: Build OCR dependencies manually if needed
if [ "$BUILD_OCR_MANUALLY" = true ]; then
    # Set up cross-compilation environment before building
    export PATH="$MXE_DIR/usr/bin:$PATH"
    export PKG_CONFIG_PATH="$MXE_DIR/usr/$TARGET/lib/pkgconfig"
    export CC="$TARGET-gcc"
    export CXX="$TARGET-g++"
    export AR="$TARGET-ar"
    export STRIP="$TARGET-strip"
    export RANLIB="$TARGET-ranlib"
    export DLLTOOL="$TARGET-dlltool"
    export WINDRES="$TARGET-windres"
    export LD="$TARGET-ld"
    export NM="$TARGET-nm"
    export OBJDUMP="$TARGET-objdump"
    export PKG_CONFIG="$TARGET-pkg-config"
    
    # Check if Leptonica is already built and installed
    if [ ! -f "$MXE_DIR/usr/$TARGET/lib/libleptonica.a" ]; then
        print_status "Step 5a: Building Leptonica manually..."
        cd "$WORK_DIR"
        
        # Download and build Leptonica
        if [ ! -d "leptonica" ]; then
            git clone https://github.com/DanBloomberg/leptonica.git
        fi
        cd leptonica
        
        # Clean previous build if it exists
        if [ -f "Makefile" ]; then
            make distclean || true
        fi
        
        # Configure and build Leptonica with proper cross-compilation flags
        ./autogen.sh
        CFLAGS="-I$MXE_DIR/usr/$TARGET/include" \
        CPPFLAGS="-I$MXE_DIR/usr/$TARGET/include" \
        LDFLAGS="-L$MXE_DIR/usr/$TARGET/lib" \
        PKG_CONFIG_PATH="$MXE_DIR/usr/$TARGET/lib/pkgconfig" \
        ./configure \
            --host="$TARGET" \
            --prefix="$MXE_DIR/usr/$TARGET" \
            --enable-static \
            --disable-shared \
            --without-libwebp \
            --without-libopenjpeg \
            --with-zlib \
            --with-libpng \
            --with-jpeg \
            --with-libtiff \
            --disable-programs
        
        make -j$(nproc)
        make install
        print_success "Leptonica built and installed"
    else
        print_success "Leptonica already built and installed"
    fi
    
    # Check if Tesseract is already built and installed
    if [ ! -f "$MXE_DIR/usr/$TARGET/lib/libtesseract.a" ]; then
        print_status "Step 5b: Building Tesseract manually..."
        cd "$WORK_DIR"
        
        # Download and build Tesseract
        if [ ! -d "tesseract" ]; then
            git clone https://github.com/tesseract-ocr/tesseract.git
            cd tesseract
            # Use a stable version instead of latest
            git checkout 5.3.4
        else
            cd tesseract
        fi
        
        # Clean previous build if it exists
        if [ -f "Makefile" ]; then
            make distclean || true
        fi
        
        # Configure and build Tesseract with proper cross-compilation flags
        ./autogen.sh
        CFLAGS="-I$MXE_DIR/usr/$TARGET/include" \
        CPPFLAGS="-I$MXE_DIR/usr/$TARGET/include" \
        CXXFLAGS="-I$MXE_DIR/usr/$TARGET/include" \
        LDFLAGS="-L$MXE_DIR/usr/$TARGET/lib" \
        PKG_CONFIG_PATH="$MXE_DIR/usr/$TARGET/lib/pkgconfig" \
        LEPTONICA_CFLAGS="-I$MXE_DIR/usr/$TARGET/include/leptonica" \
        LEPTONICA_LIBS="-L$MXE_DIR/usr/$TARGET/lib -lleptonica -lpng -ljpeg -ltiff -lz -lm" \
        ./configure \
            --host="$TARGET" \
            --prefix="$MXE_DIR/usr/$TARGET" \
            --enable-static \
            --disable-shared \
            --disable-openmp \
            --disable-doc
        
        make -j$(nproc)
        make install
        
        # Create a pkg-config file for Tesseract with proper C++ linking flags
        mkdir -p "$MXE_DIR/usr/$TARGET/lib/pkgconfig"
        cat > "$MXE_DIR/usr/$TARGET/lib/pkgconfig/tesseract.pc" << EOF
prefix=$MXE_DIR/usr/$TARGET
exec_prefix=\${prefix}
libdir=\${exec_prefix}/lib
includedir=\${prefix}/include

Name: tesseract
Description: An OCR Engine that was developed at HP Labs between 1985 and 1995... and now at Google.
Version: 5.3.4
Requires: lept
Libs: -L\${libdir} -ltesseract -lstdc++
Cflags: -I\${includedir}
EOF
        
        print_success "Tesseract built and installed with pkg-config file"
    else
        print_success "Tesseract already built and installed"
    fi
fi

# Step 5c: Build GPAC manually if needed
if [ "$BUILD_GPAC_MANUALLY" = true ]; then
    # Set up cross-compilation environment if not already set
    export PATH="$MXE_DIR/usr/bin:$PATH"
    export PKG_CONFIG_PATH="$MXE_DIR/usr/$TARGET/lib/pkgconfig"

    # Check if GPAC is already built and installed
    if [ ! -f "$MXE_DIR/usr/$TARGET/lib/libgpac.a" ]; then
        print_status "Step 5c: Building GPAC manually..."
        cd "$WORK_DIR"
        
        # Download and build GPAC
        if [ ! -d "gpac" ]; then
            git clone https://github.com/gpac/gpac.git
            cd gpac
            git checkout v2.4.0
        else
            cd gpac
        fi
        
        # Clean previous build
        if [ -f "Makefile" ]; then
            make distclean || true
        fi
        rm -f config.mak
        
        # Configure GPAC
        print_status "Configuring GPAC for mingw-w64 cross-compilation..."
        ./configure \
            --target-os=mingw64 \
            --cc="$MXE_DIR/usr/bin/$TARGET-gcc" \
            --cxx="$MXE_DIR/usr/bin/$TARGET-g++" \
            --prefix="$MXE_DIR/usr/$TARGET" \
            --extra-cflags="-I$MXE_DIR/usr/$TARGET/include" \
            --extra-ldflags="-L$MXE_DIR/usr/$TARGET/lib" \
            --static-bin \
            --cpu=x86_64
        
        # Build and install GPAC
        print_status "Building GPAC..."
        make -j$(nproc) lib
        make install-lib
        
        # Copy libgpac_static.a to libgpac.a for CMake compatibility
        if [ -f "$MXE_DIR/usr/$TARGET/lib/libgpac_static.a" ]; then
            cp "$MXE_DIR/usr/$TARGET/lib/libgpac_static.a" "$MXE_DIR/usr/$TARGET/lib/libgpac.a"
        else
            print_error "Building GPAC failed, cannot find $MXE_DIR/usr/$TARGET/lib/libgpac_static.a"
            exit 1
        fi
        
        print_success "GPAC built and installed successfully"
    else
        print_success "GPAC already built and installed"
    fi
fi

# Step 6: Set up environment variables
print_status "Step 6: Setting up cross-compilation environment..."
export PATH="$MXE_DIR/usr/bin:$PATH"
export PKG_CONFIG_PATH="$MXE_DIR/usr/$TARGET/lib/pkgconfig"
export CC="$TARGET-gcc"
export CXX="$TARGET-g++"
export AR="$TARGET-ar"
export STRIP="$TARGET-strip"
export RANLIB="$TARGET-ranlib"
export DLLTOOL="$TARGET-dlltool"
export WINDRES="$TARGET-windres"

# Step 7: Clone CCExtractor
print_status "Step 7: Cloning CCExtractor source code..."
cd "$WORK_DIR"
if [ ! -d "$CCEXTRACTOR_DIR" ]; then
    git clone https://github.com/CCExtractor/ccextractor.git CCExtractor
    cd "$CCEXTRACTOR_DIR"
    git reset --hard 25a447d42ee589db0257c1e91846700502b5cf58 # last working working of C only with SHARED features enabled
else
    print_status "CCExtractor directory already exists"
    cd "$CCEXTRACTOR_DIR"
fi

# Step 8: Prepare CCExtractor build
print_status "Step 8: Preparing CCExtractor build configuration..."

# Find the correct source directory with CMakeLists.txt
SRC_DIR="$(pwd)/src"

# Create a custom CMake toolchain file
cat > windows-cross-compile.cmake << EOF
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR x86_64)

# Specify the cross compiler for mingw-w64
set(CMAKE_C_COMPILER $TARGET-gcc)
set(CMAKE_CXX_COMPILER $TARGET-g++)

# Where is the target environment (mingw-w64)
set(CMAKE_FIND_ROOT_PATH $MXE_DIR/usr/$TARGET)

# Search for programs in the build host directories
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# For libraries and headers in the target directories
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

# Set pkg-config for mingw-w64
set(PKG_CONFIG_EXECUTABLE $TARGET-pkg-config)
EOF

# Step 9: Configure and build CCExtractor
print_status "Step 9: Configuring CCExtractor build..."
mkdir -p build-windows
cd build-windows

# Use MXE CMake if available, otherwise use system CMake with proper toolchain
CMAKE_CMD="cmake"
if [ -f "$MXE_DIR/usr/bin/$TARGET-cmake" ]; then
    CMAKE_CMD="$MXE_DIR/usr/bin/$TARGET-cmake"
    print_status "Using MXE CMake: $CMAKE_CMD"
elif [ -f "$MXE_DIR/usr/$TARGET/bin/cmake" ]; then
    CMAKE_CMD="$MXE_DIR/usr/$TARGET/bin/cmake"
    print_status "Using MXE CMake: $CMAKE_CMD"
else
    print_status "Using system CMake with cross-compilation toolchain"
fi

print_status "Source directory: $SRC_DIR"
print_status "Build directory: $(pwd)"

# Check for available bcrypt library and create a symlink to fix the naming issue
print_status "Checking for bcrypt library..."
if [ -f "$MXE_DIR/usr/$TARGET/lib/libbcrypt.a" ]; then
    print_status "Found libbcrypt.a at: $MXE_DIR/usr/$TARGET/lib/libbcrypt.a"
    
    # Create a symlink with the expected name if it doesn't exist
    if [ ! -f "$MXE_DIR/usr/$TARGET/lib/libBcrypt.a" ]; then
        print_status "Creating symlink libBcrypt.a -> libbcrypt.a to fix linker name mismatch"
        ln -sf libbcrypt.a "$MXE_DIR/usr/$TARGET/lib/libBcrypt.a"
    fi
else
    print_warning "bcrypt library not found at expected location"
    exit 1
fi

# Configure CCExtractor with CMake
CMAKE_ARGS=(
    "$SRC_DIR"
    -DCMAKE_TOOLCHAIN_FILE="$CCEXTRACTOR_DIR/windows-cross-compile.cmake"
    -DCMAKE_BUILD_TYPE=Release
    -DWITH_FFMPEG=OFF
    -DWITH_SHARING=OFF
    -DWITH_OCR=ON
    -DWITH_HARDSUBX=ON
    -DWITHOUT_RUST=ON
    -DCMAKE_C_FLAGS="-D__MINGW32__ -D__MINGW64__"
    -DCMAKE_CXX_FLAGS="-D__MINGW32__ -D__MINGW64__"
    -DCMAKE_FIND_ROOT_PATH="$MXE_DIR/usr/$TARGET"
    -DPKG_CONFIG_EXECUTABLE="$MXE_DIR/usr/bin/$TARGET-pkg-config"
    -DCMAKE_EXE_LINKER_FLAGS="-Wl,--allow-multiple-definition"
    -DCMAKE_LIBRARY_PATH="$MXE_DIR/usr/$TARGET/lib"
    -DCMAKE_PREFIX_PATH="$MXE_DIR/usr/$TARGET"
)

$CMAKE_CMD "${CMAKE_ARGS[@]}"

print_status "Step 10: Building CCExtractor..."
print_warning "This may take several minutes..."

# Build the project
make -j$(nproc)

print_success "Build completed!"

# Step 11: Check the output
print_status "Step 11: Checking build output..."
if [ -f "ccextractor.exe" ]; then
    print_success "CCExtractor Windows executable created successfully!"
    echo "Location: $(pwd)/ccextractor.exe"
    
    print_status "Stripping debug information from executable to make it smaller"
    "$MXE_DIR/usr/bin/$TARGET-strip" --strip-debug ccextractor.exe
    
    # Get file info
    file ccextractor.exe
    ls -lh ccextractor.exe
    
    print_status "Testing executable format..."
    "$TARGET-objdump" -f ccextractor.exe | head -5
else
    print_error "Build failed - ccextractor.exe not found"
    exit 1
fi

# Step 12: Create distribution package
print_status "Step 12: Creating distribution package..."
DIST_DIR="$WORK_DIR/ccextractor-windows-dist"
mkdir -p "$DIST_DIR"
cp ccextractor.exe "$DIST_DIR/ccextractorwinfull.exe"

print_success "Distribution package created in: $DIST_DIR"
print_success "Cross-compilation completed successfully!"
print_status "You can find your Windows executable at: $DIST_DIR/ccextractorwinfull.exe"
print_success "All done! Your Windows CCExtractor executable is ready."

steel-bucket added a commit to steel-bucket/ccextractor that referenced this pull request Dec 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants