RE: ffmpeg-4.4
Andrew Wu DJGPP CROSS COMPILER, GCC v12.2.0
Host Macbook Pro, macOS Monterey

Click Here

DJGPP Cross Compiler 12.2.0 Fails to Recognize "certain" Parameters in FFmpeg Source Code
Hi,
I am using the DJGPP cross compiler 12.2.0, developed by Andrew Wu, github, to build the FFmpeg source code, and it's failing to recognize certain parameters and the script I used to build FFmpeg source code follows:

#!/usr/bin/env bash

# Path to DJGPP cross compiler
export DJGPP_PREFIX="/Users/owner/djcc"
# export DJGPP_PREFIX=${DJGPP_PREFIX-/Users/owner/djcc}
export DJGPP_PREFIX2=${DJGPP_PREFIX2-/Users/owner/ffcc}
# export 
DJGPP_PREFIX3=${DJGPP_PREFIX3-/Users/owner/Documents/DOSBox/NET/watt}
# system path
export PATH="$DJGPP_PREFIX/bin:$PATH"

# Your cross compilation target
TARGET_ARCH="$DJGPP_PREFIX/bin/i586-pc-msdosdjgpp"
# set C_INCLUDE_PATH environment variable
export C_INCLUDE_PATH="#DJGPP_PREFIX/i586-pc-msdosdjgpp/sys-include"

# Download FFmpeg source code
FFMPEG_VERSION="4.4"
FFMPEG_ARCHIVE="https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.gz"
FFMPEG_SOURCE_DIR="ffmpeg-${FFMPEG_VERSION}"

# Download FFmpeg source
echo "Downloading FFmpeg source..."
wget -c "$FFMPEG_ARCHIVE" || exit 1
tar -xf "ffmpeg-${FFMPEG_VERSION}.tar.gz" || exit 1
cd "$FFMPEG_SOURCE_DIR" || exit 1

# clean debri
gmake clean

# Redirect both stdout and stderr to separate .err files
exec > >(tee -ia gcca.txt) 2> >(tee -ia gcc_err.err >&2)

# Configure FFmpeg for cross-compilation
echo "Configuring FFmpeg for cross-compilation..."
./configure --enable-cross-compile \
           --prefix="$DJGPP_PREFIX2" \
           --target-os=ms-dos \
           --arch=i486 \
           --cross-prefix="$TARGET_ARCH-" \
           --extra-cflags="-I$DJGPP_PREFIX/i586-pc-msdosdjgpp/sys-include -I$DJGPP_PREFIX/include -I$DJGPP_PREFIX3/inc2 -I$DJGPP_PREFIX3/inc3" \
           --extra-ldflags="-L$DJGPP_PREFIX/i586-pc-msdosdjgpp/lib -L$DJGPP_PREFIX/lib -L$DJGPP_PREFIX3/lib2 -L$DJGPP_PREFIX3/lib3" \
           --enable-debug \
           --disable-shared \
           --enable-static \
           --disable-doc \
           --disable-programs \
           || exit 1

# Compile a hello world program for testing
echo "Compiling hello world program for testing..."
cat > helloai.c <<EOF
#include <stdio.h>

int main() {
    printf("Hello, world!\\n");
    return 0;
}
EOF

"$TARGET_ARCH-gcc" helloai.c -o helloai || exit 1

# Compile FFmpeg
echo "Compiling FFmpeg..."
gmake CC="$DJGPP_PREFIX/bin/i586-pc-msdosdjgpp-gcc" || exit 1 
# gmake install || exit 1

echo "Compilation complete."

The following 36 issues surfaced compiling FFmpeg DJGPP 'make' cross compile, stating, "error: declaration for parameter 'XX_XXXX_XX_XXXX' but no such parameter:".

`

  1. ff_log_net_error

  2. ff_socket

  3. ff_http_match_no_proxy

  4. ff_listen_connect

  5. ff_accept

  6. ff_listen

  7. ff_listen_bind

  8. ff_is_multicast_address

  9. ff_gai_strerror

  10. ff_getnameinfo

  11. ff_freeaddrinfo

  12. ff_getaddrinfo

  13. sockaddr_union

  14. ff_network_sleep_interruptible

  15. ff_network_wait_fd_timeout

  16. ff_network_wait_fd

  17. ff_tls_deinit

  18. ff_tls_init

  19. ff_network_close

  20. ff_network_init

  21. ff_socket_nonblock

  22. ff_connect_parallel

  23. ff_log_net_error

  24. ff_socket

  25. ff_http_match_no_proxy

  26. ff_listen_connect

  27. ff_accept

  28. ff_listen

  29. ff_listen_bind

  30. ff_is_multicast_address

  31. ff_gai_strerror

  32. ff_getnameinfo

  33. ff_freeaddrinfo

  34. ff_getaddrinfo

  35. sockaddr_union

  36. ff_network_sleep_interruptible`

The "no such parameter", observed in "libavformat/network.h", has now shown up in
"/libavformat/avio.c", giving credence to starting this thread:

`libavformat/avio.c:57:23: error: declaration for parameter "options" but no such parameter

libavformat/avio.c:64:15: error: declaration for parameter "ffurl_context_class" but no such parameter`

// libavformat/avio.c
#include "libavutil/avstring.h"
#include "libavutil/dict.h"
#include "libavutil/opt.h"
#include "libavutil/time.h"
#include "libavutil/avassert.h"
#include "os_support.h"
#include "avformat.h"
#include "internal.h"
#if CONFIG_NETWORK
#include "network.h"
#endif
#include "url.h"

/** @name Logging context. */
/*@{*/
static const char *urlcontext_to_name(void *ptr)
{
    URLContext *h = (URLContext *)ptr;
    if (h->prot)
        return h->prot->name;
    else
        return "NULL";
}

static void *urlcontext_child_next(void *obj, void *prev)
{
    URLContext *h = obj;
    if (!prev && h->priv_data && h->prot->priv_data_class)
        return h->priv_data;
    return NULL;
}

#define OFFSET(x) offsetof(URLContext,x)
#define E AV_OPT_FLAG_ENCODING_PARAM
#define D AV_OPT_FLAG_DECODING_PARAM
static const AVOption options[] = { // L57:23
    {"protocol_whitelist", "List of protocols that are allowed to be used", OFFSET(protocol_whitelist), AV_OPT_TYPE_STRING, { .str = NULL },  0, 0, D },
    {"protocol_blacklist", "List of protocols that are not allowed to be used", OFFSET(protocol_blacklist), AV_OPT_TYPE_STRING, { .str = NULL },  0, 0, D },
    {"rw_timeout", "Timeout for IO operations (in microseconds)", offsetof(URLContext, rw_timeout), AV_OPT_TYPE_INT64, { .i64 = 0 }, 0, INT64_MAX, AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_DECODING_PARAM },
    { NULL }
};

const AVClass ffurl_context_class = { // L64:15
    .class_name       = "URLContext",
    .item_name        = urlcontext_to_name,
    .option           = options,
    .version          = LIBAVUTIL_VERSION_INT,
    .child_next       = urlcontext_child_next,
#if FF_API_CHILD_CLASS_NEXT
    .child_class_next = ff_urlcontext_child_class_next,
#endif
    .child_class_iterate = ff_urlcontext_child_class_iterate,
};
/*@}*/

Therefore, since this source code compiled like a charm on macOS Monterey, please explain the root cause, thanks?

I can't offer any suggestions other than to just download the compiled app for your system instead of building it yourself.

Here's another problem. When we change the OS not only must we setup the compiler, environment and such but sometimes an OS API could be deprecated or removed. You made mention of a possible OS change so that's a possibility.

You obtained this code from somewhere. Go back there and see if they updated it for your new OS.

While I haven't used DJGPP for a couple decades, I decided to install the ffmpeg library and do a test program another way.
For me, the declarations worked changing:

#include "os_support.h"
#include "avformat.h"
#include "internal.h"
#if CONFIG_NETWORK
#include "network.h"
#endif
#include "url.h"

To:

#include "libavformat/os_support.h"
#include "libavformat/avformat.h"
#include "libavformat/internal.h"
#if CONFIG_NETWORK
#include "libavformat/network.h"
#endif
#include "libavformat/url.h"

This program reads and prints the information of a mp4 file.

extern "C" {
#include <libavformat/avformat.h>
#include <libavformat/avio.h>
}

int main() {
    AVFormatContext* fmt_ctx = NULL;
    int ret;

    // read the header of input stream.
    ret = avformat_open_input(&fmt_ctx, "snow.mp4", NULL, NULL);
    if (ret < 0) {
        av_log(NULL, AV_LOG_ERROR, "Cannot open input file\n");
        return -1;
    }

    // find stream information.
    ret = avformat_find_stream_info(fmt_ctx, NULL);
    if (ret < 0) {
        av_log(NULL, AV_LOG_ERROR, "Cannot find stream information\n");
        return -1;
    }

    // dump info on input or output format.
    av_dump_format(fmt_ctx, 0, "snow.mp4", 0);

    // Close an opened input AVFormatContext.
    avformat_close_input(&fmt_ctx);
    return 0;
}



Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'snow.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf60.3.100
  Duration: 00:00:05.80, start: 0.000000, bitrate: 370 kb/s
    Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720, 298 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : Core Media Video
      encoder         : Lavc60.3.100 libx264
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 64 kb/s (default)
    Metadata:
      handler_name    : Core Media Audio

If I decide to try to compile the source, I'll do a follow-up, but it seems to run fine.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.