I am trying to make a build of ffmpeg with libx264 enabled. However when I run the following command in MSYS
./configure --prefix=ffmpeg/ --enable-gpl --enable-libx264
I get an error saying
ERROR: libx264 not found
I am using MSYS on windows 10. I also have installed NASM. Here is the config.log file
BEGIN /tmp/ffconf.TRVJWfGe/test.c
1 #include <stdint.h>
2 #include <x264.h>
3 #include <stdint.h>
4 long check_x264_encoder_encode(void) { return (long) x264_encoder_encode; }
5 int main(void) { int ret = 0;
6 ret |= ((intptr_t)check_x264_encoder_encode) & 0xFFFF;
7 return ret; }
END /tmp/ffconf.TRVJWfGe/test.c
gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -U__STRICT_ANSI__ -D__USE_MINGW_ANSI_STDIO=1 -D__MSVCRT_VERSION__=0x0700 -D_WIN32_WINNT=0x0600 -D__printf__=__gnu_printf__ -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -std=c11 -fomit-frame-pointer -c -o /tmp/ffconf.TRVJWfGe/test.o /tmp/ffconf.TRVJWfGe/test.c
In file included from c:\mingw\include\stdint.h:46,
from c:\mingw\lib\gcc\mingw32\9.2.0\include\stdint.h:9,
from C:/Users/pawel/AppData/Local/Temp/ffconf.TRVJWfGe/test.c:1:
c:\mingw\include\_mingw.h:413:3: warning: #warning "Direct definition of __USE_MINGW_ANSI_STDIO is deprecated." [-Wcpp]
413 | # warning "Direct definition of __USE_MINGW_ANSI_STDIO is deprecated."
| ^~~~~~~
c:\mingw\include\_mingw.h:414:10: note: #pragma message: See <_mingw.h> for preferred feature activation methods.
414 | # pragma message "See <_mingw.h> for preferred feature activation methods."
| ^~~~~~~
C:/Users/pawel/AppData/Local/Temp/ffconf.TRVJWfGe/test.c:2:10: fatal error: x264.h: No such file or directory
2 | #include <x264.h>
| ^~~~~~~~
compilation terminated.
ERROR: libx264 not found
Could you tell me how to fix the error, or is there a prebuilt package with libx264 already inside?
Related
This is quite similar to GCC define function-like macros using -D argument but I couldn't find a relation to my use case.
Consider the following code, main.c:
#include <stdio.h>
const char greeting[] = "hello world";
//#define printf(fmt, ...) (0)
int main() {
printf("%s!\n", greeting);
return 0;
}
If I compile and run this, it works as expected:
$ gcc -Wall -g main.c -o main.exe
$ ./main.exe
hello world!
$
Ok, now I want to How to disable printf function? so I uncomment the #define in the code; I get some warnings, but things again work as as expected (as there is no printout):
$ gcc -Wall -g main.c -o main.exe
main.c: In function 'main':
main.c:5:26: warning: statement with no effect [-Wunused-value]
5 | #define printf(fmt, ...) (0)
| ^
main.c:8:5: note: in expansion of macro 'printf'
8 | printf("%s!\n", greeting);
| ^~~~~~
$ ./main.exe
$
Now, go back to the example as originally posted - that is, comment the #define like - and let's try to set that define via the command-line -D argument:
$ gcc -Wall -D'printf(fmt, ...)=(0)' -g main.c -o main.exe
<command-line>: error: expected identifier or '(' before numeric constant
main.c: In function 'main':
<command-line>: warning: statement with no effect [-Wunused-value]
main.c:8:5: note: in expansion of macro 'printf'
8 | printf("%s!\n", greeting);
| ^~~~~~
Well, the command line argument -D'printf(fmt, ...)=(0)' causes the compilation to fail.
Is there any way I can format this macro somehow, so I can set it via the gcc command line using the -D argument? (Bonus: can it be formulated somehow, so it does not raise warnings like "statement with no effect")
EDIT: contents of C:/msys64/mingw64/include/stdio.h lines 366 to 372:
366 __mingw_ovr
367 __attribute__((__format__ (gnu_printf, 1, 2))) __MINGW_ATTRIB_NONNULL(1)
368 int printf (const char *__format, ...)
369 {
370 int __retval;
371 __builtin_va_list __local_argv; __builtin_va_start( __local_argv, __format );
372 __retval = __mingw_vfprintf( stdout, __format, __local_argv );
373 __builtin_va_end( __local_argv );
374 return __retval;
375 }
When you use:
#define printf(fmt, ...) (0)
The preprocessor turns the code into this:
int main() {
(0);
return 0;
}
That free standing (0) is not allowed. However if you define it this way:
#define printf(fmt, ...)
You can also use the command line definition:
"-Dprintf(fmt, ...)="
Everything works.
I was able to compiled the gateway but I got the error below running the make command.
gcc -D_REENTRANT=1 -I. -Igw -g -O2 -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_LARGE_FILES= -I/usr/include/libxml2 -I/usr/include/mysql -o gwlib/dbpool.o -c gwlib/dbpool.c
In file included from /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:33,
from /usr/include/stdlib.h:25,
from gwlib/gwlib.h:70,
from gwlib/dbpool.c:70:
/usr/include/features.h:187:3: warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
187 | # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
In file included from gwlib/gwlib.h:83,
from gwlib/dbpool.c:70:
gwlib/dbpool_mysql.c: In function ‘mysql_select’:
gwlib/dbpool_mysql.c:224:48: error: ‘my_bool’ undeclared (first use in this function); did you mean ‘xr_bool’?
224 | bind[i].is_null = gw_malloc(sizeof(my_bool));
gwlib/gwmem.h:122:43: note: in definition of macro ‘gw_malloc’
122 | #define gw_malloc(size) (gw_native_malloc(size))|
gwlib/dbpool_mysql.c:224:48: note: each undeclared identifier is reported only once for each function it appears in
224 | bind[i].is_null = gw_malloc(sizeof(my_bool));
gwlib/gwmem.h:122:43: note: in definition of macro ‘gw_malloc’
122 | #define gw_malloc(size) (gw_native_malloc(size))
make: *** [Makefile:230: gwlib/dbpool.o] Error 1`
This error comes when you're compiling with mysql 8
To fix this, add these lines to gwlib/dbpool_mysql.c
/* define my_bool for newer versions because they use the bool or int C type instead */
#if MYSQL_VERSION_ID >= 80000 && !defined(MARIADB_BASE_VERSION)
typedef bool my_bool;
#endif
I am trying to run a make file in MacOS sierra, but it seems to have trouble with the header of the Zlib (see below).
I have tried to install a separate version with brew and pass the directory of the brew zlib installation in the configure file.
./configure --prefix=/usr/local/etherlab --with-xml-prefix=/usr/local/opt/libxml2 --with-zlib-dir=/usr/local/opt/zlib CXXFLAGS=-std=c++11
However, when I run make I got the error
$ make
/Applications/Xcode.app/Contents/Developer/usr/bin/make all-recursive
Making all in proto
make[2]: Nothing to be done for `all'.
Making all in lib
Making all in LibDLS
make[3]: Nothing to be done for `all'.
/bin/sh ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I.. -I/usr/local/etherlab/include -Wall -I/usr/local/include -I/usr/local/opt/zlib/include -I/usr/local/opt/libxml2/include/libxml2 -std=c++11 -MT libdls_la-ZLib.lo -MD -MP -MF .deps/libdls_la-ZLib.Tpo -c -o libdls_la-ZLib.lo `test -f 'ZLib.cpp' || echo './'`ZLib.cpp
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I.. -I/usr/local/etherlab/include -Wall -I/usr/local/include -I/usr/local/opt/zlib/include -I/usr/local/opt/libxml2/include/libxml2 -std=c++11 -MT libdls_la-ZLib.lo -MD -MP -MF .deps/libdls_la-ZLib.Tpo -c ZLib.cpp -fno-common -DPIC -o .libs/libdls_la-ZLib.o
ZLib.cpp:22:10: warning: non-portable path to file '<ZLib.h>'; specified path differs in case from file name on disk
[-Wnonportable-include-path]
#include <zlib.h>
^~~~~~~~
<ZLib.h>
In file included from ZLib.cpp:22:
./zlib.h:42:17: error: unknown type name 'string'; did you mean 'std::string'?
EZLib(const string &pmsg) : Exception(pmsg) {};
^~~~~~
std::string
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iosfwd:194:65: note:
'std::string' declared here
typedef basic_string<char, char_traits<char>, allocator<char> > string;
^
ZLib.cpp:90:5: error: unknown type name 'uLongf'
uLongf out_size;
^
ZLib.cpp:104:17: error: use of undeclared identifier 'uLongf'
out_size = (uLongf) (src_size * 1.01 + 12 + 0.5);
^
ZLib.cpp:117:28: error: use of undeclared identifier 'Bytef'
comp_ret = ::compress((Bytef *) _out_buf, &out_size,
^
ZLib.cpp:117:35: error: expected expression
comp_ret = ::compress((Bytef *) _out_buf, &out_size,
^
ZLib.cpp:118:34: error: unknown type name 'Bytef'
(const Bytef *) src, src_size);
^
ZLib.cpp:117:16: error: no member named 'compress' in the global namespace; did you mean simply 'compress'?
comp_ret = ::compress((Bytef *) _out_buf, &out_size,
^~~~~~~~~~
compress
ZLib.cpp:88:12: note: 'compress' declared here
void ZLib::compress(const char *src, unsigned int src_size)
^
ZLib.cpp:120:21: error: use of undeclared identifier 'Z_OK'
if (comp_ret != Z_OK) // Fehler beim Komprimieren
^
ZLib.cpp:123:25: error: use of undeclared identifier 'Z_BUF_ERROR'
if (comp_ret == Z_BUF_ERROR) err << " (BUFFER ERROR)";
^
ZLib.cpp:155:5: error: unknown type name 'uLongf'
uLongf zlib_out_size = out_size;
^
ZLib.cpp:173:32: error: use of undeclared identifier 'Bytef'
uncomp_ret = ::uncompress((Bytef *) _out_buf, &zlib_out_size,
^
ZLib.cpp:173:39: error: expected expression
uncomp_ret = ::uncompress((Bytef *) _out_buf, &zlib_out_size,
^
ZLib.cpp:174:38: error: unknown type name 'Bytef'
(const Bytef *) src, src_size);
^
ZLib.cpp:173:18: error: no member named 'uncompress' in the global namespace; did you mean simply 'uncompress'?
uncomp_ret = ::uncompress((Bytef *) _out_buf, &zlib_out_size,
^~~~~~~~~~~~
uncompress
ZLib.cpp:150:12: note: 'uncompress' declared here
void ZLib::uncompress(const char *src, unsigned int src_size,
^
ZLib.cpp:176:23: error: use of undeclared identifier 'Z_OK'
if (uncomp_ret != Z_OK) // Fehler beim Dekomprimieren
^
ZLib.cpp:179:27: error: use of undeclared identifier 'Z_BUF_ERROR'
if (uncomp_ret == Z_BUF_ERROR) {
^
1 warning and 16 errors generated.
make[3]: *** [libdls_la-ZLib.lo] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
Digging a bit more I found that I could try to add
#include <string>
#include <cstring>
to the header zlib.h but this does not work either.
What else can I do to solve this issue?.
When compiling ltrace with icecc we run into a compilation problem. This is the minimal example:
main.c
#include <assert.h>
int main(int argc, char **argv) {
assert(argc != argc);
return 0;
}
test.sh:
#!/bin/bash
set -x
# one step compilation (no warning)
gcc -Wall main.c
# splitted compilation (warning)
gcc -Wall -E main.c -o main.i
gcc -Wall --preprocessed main.i
output:
++ gcc -Wall main.c
++ gcc -Wall -E main.c -o main.i
++ gcc -Wall --preprocessed main.i
main.c: In function ‘main’:
main.c:4:10: warning: self-comparison always evaluates to false [-Wtautological-compare]
assert(argc != argc);
^~
As you can see the result is different when compiling in one step and when preprocessing and compiling in two steps. Is this intended behavior?
I use gcc 6.3, the issue also appears in gcc 6.2 for ARM. I also cannot ignore this, as the full example uses -Werror.
Is there a GCC pragma directive that will stop, halt, or abort the compilation process?
I am using GCC 4.1, but I would want the pragma to be available in GCC 3.x versions also.
You probably want #error:
$ cd /tmp
$ g++ -Wall -DGoOn -o stopthis stopthis.cpp
$ ./stopthis
Hello, world
$ g++ -Wall -o stopthis stopthis.cpp
stopthis.cpp:7:6: error: #error I had enough
File stopthis.cpp
#include <iostream>
int main(void) {
std::cout << "Hello, world\n";
#ifndef GoOn
#error I had enough
#endif
return 0;
}
I do not know about a #pragma, but #error should do what you want:
#error Failing compilation
It will terminate compilation with the error message "Failing compilation".
This works:
#include <stophere>
GCC stops when it can't find the include file. I wanted GCC to stop if C++14 was not supported.
#if __cplusplus<201300L
#error need g++14
#include <stophere>
#endif
While typically #error is sufficient (and portable), there are times when you want to use a pragma, namely, when you want to optionally cause an error within a macro.
Here is an example use which depends on C11's _Generic and _Pragma.
This example ensures var isn't an int * or a short *, but not a const int * at compile time.
Example:
#define MACRO(var) do { \
(void)_Generic(var, \
int *: 0, \
short *: 0, \
const int *: 0 _Pragma("GCC error \"const not allowed\"")); \
\
MACRO_BODY(var); \
} while (0)
#pragma GCC error "error message"
Ref: 7 Pragmas
You can use:
#pragma GCC error "my message"
But it is not standard.
An alternative is to use static_assert:
#if defined(_MSC_VER) && _MSC_VER < 1916
static_assert(false, "MSVC supported versions are 1916 and later");
#endif