Build says X264_encoder_open_xxx is not found

Started by MBantz, January 03, 2013, 08:49:15 PM

Previous topic - Next topic

MBantz

Trying to build the new Avidemux for PCLinuxOS to include it in the repos, the x264 encoder fails with:

-- Checking for x264
-- *****************
-- Found x264.h
--   core version: 129
-- Found x264.h
-- Found x264 library
-- Could not find x264_encoder_open_129 in /usr/lib64/libx264.a
-- Change Dir: /home/mbz/src/rpm/BUILD/avidemux_2.6.1/buildPluginsCommon/CMakeFiles/CMakeTmp


and

*** Video Encoder      ***
    Xvid           Yes
    x264           No


but checking libx264.a gives this output:


[mbz@localhost lib64]$ nm /usr/lib64/libx264.a | grep x264_encode
                 U x264_encoder_reconfig
000000000000b9f0 T x264_encoder_close
000000000000dba0 T x264_encoder_delayed_frames
0000000000000850 t x264_encoder_encapsulate_nals
0000000000009000 T x264_encoder_encode
0000000000002e40 t x264_encoder_frame_end
0000000000008bc0 T x264_encoder_headers
0000000000008f30 T x264_encoder_intra_refresh
0000000000008f50 T x264_encoder_invalidate_reference
000000000000dca0 T x264_encoder_maximum_delayed_frames
0000000000007740 T x264_encoder_open_129
0000000000008ba0 T x264_encoder_parameters
0000000000008850 T x264_encoder_reconfig
0000000000002ca0 t x264_encoder_thread_init



it appear that x264_encoder_open_129 is present.

The x264 library is only built as a static library,

can anyone see what could be wrong here?

thanks,
MBantz

MBantz

Have found admCheckX264.cmake that call a (custom?) function FIND_HEADER_AND_LIB

Guess is that the function checks shared libraries and not static?

In PCLinux we have dropped shared x264 libraries due to massive recompilation of dependent x264 libraries when x264 is updated.

Can an avidemux developer please confirm?

cheers,
MBantz

mean

Most probably need to link to libpthread or something when used as shared lib

MBantz

Thanks for the reply :-)

I'm a packager and not so much a programmer, and need some more info on how to do that.

It's a static library Avidemux is build against, not shared

mean

Does that help ?
(untested)
--- a/cmake/admCheckX264.cmake
+++ b/cmake/admCheckX264.cmake
@@ -18,7 +18,7 @@ MACRO(checkX264)
                                        MESSAGE("WARNING: x264 core version is too old.  At least version 67 is required.")
                                        SET(X264_FOUND 0)
                                ELSEIF (x264_version GREATER 73)
-                                       FIND_HEADER_AND_LIB(X264 x264.h x264 x264_encoder_open_${x264_version})
+                                       FIND_HEADER_AND_LIB(X264 x264.h x264 x264_encoder_open_${x264_version} -lpthread)
                                ELSE (x264_version LESS 67)
                                        FIND_HEADER_AND_LIB(X264 x264.h x264 x264_encoder_open)
                                ENDIF (x264_version LESS 67)

MBantz

Thanks for looking into this,

the error about not finding the open_129 is still the same after the patch

ajschult

On a basic level, cmake claims X264_encoder_open_xxx is not found because it creates a simple C file that references that function, tries to compile it and the compilation fails.  You'll need to figure out why it fails; that should give a pretty good indication how to fix it.  Determining why it failed would be easy enough with autoconf build system, but cmake seems to eat the error and I don't know the cmake incantations to let you see what's happening.

MBantz

If I include:

#include <stdint.h>
#include <x264.h>

to CheckFunctionExists.c

then the error returned is:
CheckFunctionExists.c:6:6: fejl: conflicting types for ââ,¬Ëœx264_encoder_open_129ââ,¬â,,¢
/usr/include/x264.h:829:1: bemærk: previous declaration of ââ,¬Ëœx264_encoder_open_129ââ,¬â,,¢ was here

and if x264.h is not included the error is:
/home/mbz/tmp/cceNyFLM.o: In function `main':
CheckFunctionExists.c:(.text+0x15): undefined reference to `x264_encoder_open_129'

can something be figured out by this?

ajschult

CheckFunctionExists.c includes

char CHECK_FUNCTION_EXISTS();

and that effectively declares x264_encoder_open_129 (CHECK_FUNCTION_EXISTS is replaced with x264_encoder_open_129).  including x264.h is unnecessary.  You want to determine how avidemux+cmake tries to compile the program (commandline arguments) and then what commandline arguments should be used on your system.  Invoke gcc directly and try to compile CheckFunctionExists.c, like

gcc -DCHECK_FUNCTION_EXISTS=x264_encoder_open_129 -o foo CheckFunctionExists.c -lx264
(that works on my system; it might be similar to what cmake does)

MBantz

Thanks ajschult :-)

I'm in deep water here :-) only help is that the same X264 library compile fine with MythTV and VLC that I have packaged with same version 129.

With the commandline you provided, I get a lot undefined references to math functions it seems:



[mbz@localhost cmake_compile_check]$ gcc -DCHECK_FUNCTION_EXISTS=x264_encoder_open_129 -o foo CheckFunctionExists.c -lx264
/usr/lib/gcc/x86_64-mandriva-linux-gnu/4.5.2/../../../../lib64/libx264.a(encoder.o): In function `x264_validate_parameters':
encoder.c:(.text+0x158f): undefined reference to `log2f'
encoder.c:(.text+0x15c2): undefined reference to `log2f'
/usr/lib/gcc/x86_64-mandriva-linux-gnu/4.5.2/../../../../lib64/libx264.a(encoder.o): In function `x264_encoder_frame_end':
encoder.c:(.text+0x3a05): undefined reference to `log10'
encoder.c:(.text+0x3a7a): undefined reference to `log10'
encoder.c:(.text+0x3aee): undefined reference to `log10'
encoder.c:(.text+0x3b91): undefined reference to `log10'
/usr/lib/gcc/x86_64-mandriva-linux-gnu/4.5.2/../../../../lib64/libx264.a(encoder.o): In function `x264_encoder_open_129':
encoder.c:(.text+0x8127): undefined reference to `pow'
encoder.c:(.text+0x8266): undefined reference to `pow'
/usr/lib/gcc/x86_64-mandriva-linux-gnu/4.5.2/../../../../lib64/libx264.a(encoder.o): In function `x264_encoder_close':
encoder.c:(.text+0xbba1): undefined reference to `log10'
encoder.c:(.text+0xbc7c): undefined reference to `log10'
encoder.c:(.text+0xbd57): undefined reference to `log10'
encoder.c:(.text+0xd04d): undefined reference to `log10'
encoder.c:(.text+0xd0e4): undefined reference to `log10'
/usr/lib/gcc/x86_64-mandriva-linux-gnu/4.5.2/../../../../lib64/libx264.a(lookahead.o): In function `x264_lookahead_init':
lookahead.c:(.text+0x6f8): undefined reference to `pthread_create'
/usr/lib/gcc/x86_64-mandriva-linux-gnu/4.5.2/../../../../lib64/libx264.a(lookahead.o): In function `x264_lookahead_delete':
lookahead.c:(.text+0x7e8): undefined reference to `pthread_join'
/usr/lib/gcc/x86_64-mandriva-linux-gnu/4.5.2/../../../../lib64/libx264.a(threadpool.o): In function `x264_threadpool_init':
threadpool.c:(.text+0x1f7): undefined reference to `pthread_create'
/usr/lib/gcc/x86_64-mandriva-linux-gnu/4.5.2/../../../../lib64/libx264.a(threadpool.o): In function `x264_threadpool_delete':
threadpool.c:(.text+0x3aa): undefined reference to `pthread_join'
/usr/lib/gcc/x86_64-mandriva-linux-gnu/4.5.2/../../../../lib64/libx264.a(set.o): In function `x264_cqm_init':
set.c:(.text+0x28b8): undefined reference to `pow'
set.c:(.text+0x395f): undefined reference to `pow'
set.c:(.text+0x4f9b): undefined reference to `pow'
set.c:(.text+0x62ab): undefined reference to `pow'
set.c:(.text+0x7c7d): undefined reference to `pow'
/usr/lib/gcc/x86_64-mandriva-linux-gnu/4.5.2/../../../../lib64/libx264.a(set.o):set.c:(.text+0x7d65): more undefined references to `pow' follow
/usr/lib/gcc/x86_64-mandriva-linux-gnu/4.5.2/../../../../lib64/libx264.a(analyse.o): In function `x264_analyse_prepare_costs':
analyse.c:(.text+0x23ee5): undefined reference to `log2f'
/usr/lib/gcc/x86_64-mandriva-linux-gnu/4.5.2/../../../../lib64/libx264.a(ratecontrol.o): In function `clip_qscale':
ratecontrol.c:(.text+0x19d): undefined reference to `powf'
ratecontrol.c:(.text+0x4d8): undefined reference to `log'
ratecontrol.c:(.text+0x4ed): undefined reference to `log'
ratecontrol.c:(.text+0x505): undefined reference to `log'
ratecontrol.c:(.text+0x536): undefined reference to `exp'
/usr/lib/gcc/x86_64-mandriva-linux-gnu/4.5.2/../../../../lib64/libx264.a(ratecontrol.o): In function `get_qscale':
ratecontrol.c:(.text+0x1148): undefined reference to `pow'
ratecontrol.c:(.text+0x11de): undefined reference to `powf'
/usr/lib/gcc/x86_64-mandriva-linux-gnu/4.5.2/../../../../lib64/libx264.a(ratecontrol.o): In function `find_underflow.clone.6':
ratecontrol.c:(.text+0x1396): undefined reference to `pow'
/usr/lib/gcc/x86_64-mandriva-linux-gnu/4.5.2/../../../../lib64/libx264.a(ratecontrol.o): In function `rate_estimate_qscale':
ratecontrol.c:(.text+0x1776): undefined reference to `pow'
ratecontrol.c:(.text+0x17ab): undefined reference to `log2f'
ratecontrol.c:(.text+0x1ae8): undefined reference to `powf'
ratecontrol.c:(.text+0x1b3b): undefined reference to `pow'
ratecontrol.c:(.text+0x1ee5): undefined reference to `log2f'
ratecontrol.c:(.text+0x20a8): undefined reference to `pow'
ratecontrol.c:(.text+0x2215): undefined reference to `pow'
ratecontrol.c:(.text+0x22e3): undefined reference to `powf'
ratecontrol.c:(.text+0x23b6): undefined reference to `pow'
ratecontrol.c:(.text+0x24e0): undefined reference to `powf'
ratecontrol.c:(.text+0x25ea): undefined reference to `powf'
/usr/lib/gcc/x86_64-mandriva-linux-gnu/4.5.2/../../../../lib64/libx264.a(ratecontrol.o): In function `x264_adaptive_quant_frame':
ratecontrol.c:(.text+0x2ae7): undefined reference to `powf'
/usr/lib/gcc/x86_64-mandriva-linux-gnu/4.5.2/../../../../lib64/libx264.a(ratecontrol.o): In function `x264_ratecontrol_init_reconfigurable':
ratecontrol.c:(.text+0x3927): undefined reference to `pow'
ratecontrol.c:(.text+0x396a): undefined reference to `powf'
/usr/lib/gcc/x86_64-mandriva-linux-gnu/4.5.2/../../../../lib64/libx264.a(ratecontrol.o): In function `x264_ratecontrol_new':
ratecontrol.c:(.text+0x3c56): undefined reference to `log2'
ratecontrol.c:(.text+0x3c6f): undefined reference to `log2'
ratecontrol.c:(.text+0x3c89): undefined reference to `log2'
ratecontrol.c:(.text+0x3d29): undefined reference to `pow'
ratecontrol.c:(.text+0x3d7c): undefined reference to `log2f'
ratecontrol.c:(.text+0x3db8): undefined reference to `log2f'
ratecontrol.c:(.text+0x3e54): undefined reference to `pow'
ratecontrol.c:(.text+0x401a): undefined reference to `powf'
ratecontrol.c:(.text+0x4053): undefined reference to `powf'
ratecontrol.c:(.text+0x42b9): undefined reference to `powf'
ratecontrol.c:(.text+0x443f): undefined reference to `powf'
ratecontrol.c:(.text+0x50e5): undefined reference to `log2f'
ratecontrol.c:(.text+0x53d6): undefined reference to `powf'
ratecontrol.c:(.text+0x6270): undefined reference to `exp'
ratecontrol.c:(.text+0x62c2): undefined reference to `pow'
ratecontrol.c:(.text+0x6453): undefined reference to `exp'
ratecontrol.c:(.text+0x64a5): undefined reference to `pow'
ratecontrol.c:(.text+0x66dd): undefined reference to `pow'
ratecontrol.c:(.text+0x69cf): undefined reference to `pow'
ratecontrol.c:(.text+0x6c85): undefined reference to `powf'
ratecontrol.c:(.text+0x6d1f): undefined reference to `powf'
ratecontrol.c:(.text+0x6e9e): undefined reference to `pow'
ratecontrol.c:(.text+0x6fff): undefined reference to `powf'
ratecontrol.c:(.text+0x7036): undefined reference to `powf'
ratecontrol.c:(.text+0x7334): undefined reference to `pow'
ratecontrol.c:(.text+0x735a): undefined reference to `exp'
ratecontrol.c:(.text+0x74f8): undefined reference to `pow'
ratecontrol.c:(.text+0x76d9): undefined reference to `pow'
ratecontrol.c:(.text+0x79aa): undefined reference to `log2f'
/usr/lib/gcc/x86_64-mandriva-linux-gnu/4.5.2/../../../../lib64/libx264.a(ratecontrol.o): In function `x264_ratecontrol_summary':
ratecontrol.c:(.text+0x7c09): undefined reference to `pow'
ratecontrol.c:(.text+0x7c2e): undefined reference to `log2f'
/usr/lib/gcc/x86_64-mandriva-linux-gnu/4.5.2/../../../../lib64/libx264.a(ratecontrol.o): In function `x264_ratecontrol_start':
ratecontrol.c:(.text+0x8411): undefined reference to `log2f'
ratecontrol.c:(.text+0x8472): undefined reference to `log2f'
/usr/lib/gcc/x86_64-mandriva-linux-gnu/4.5.2/../../../../lib64/libx264.a(ratecontrol.o): In function `x264_ratecontrol_mb':
ratecontrol.c:(.text+0x8663): undefined reference to `powf'
ratecontrol.c:(.text+0x8a12): undefined reference to `powf'
ratecontrol.c:(.text+0x8c20): undefined reference to `powf'
ratecontrol.c:(.text+0x8d8c): undefined reference to `powf'
ratecontrol.c:(.text+0x8ee4): undefined reference to `powf'
/usr/lib/gcc/x86_64-mandriva-linux-gnu/4.5.2/../../../../lib64/libx264.a(ratecontrol.o):ratecontrol.c:(.text+0x911b): more undefined references to `powf' follow
/usr/lib/gcc/x86_64-mandriva-linux-gnu/4.5.2/../../../../lib64/libx264.a(ratecontrol.o): In function `x264_ratecontrol_slice_type':
ratecontrol.c:(.text+0x9520): undefined reference to `log2f'
ratecontrol.c:(.text+0x959a): undefined reference to `log2f'
ratecontrol.c:(.text+0x9700): undefined reference to `powf'
ratecontrol.c:(.text+0x9757): undefined reference to `powf'
/usr/lib/gcc/x86_64-mandriva-linux-gnu/4.5.2/../../../../lib64/libx264.a(ratecontrol.o): In function `x264_ratecontrol_end':
ratecontrol.c:(.text+0x9c96): undefined reference to `powf'
ratecontrol.c:(.text+0x9d2b): undefined reference to `powf'
ratecontrol.c:(.text+0x9d72): undefined reference to `pow'
ratecontrol.c:(.text+0xa058): undefined reference to `powf'
ratecontrol.c:(.text+0xa248): undefined reference to `powf'
ratecontrol.c:(.text+0xa4b6): undefined reference to `powf'
/usr/lib/gcc/x86_64-mandriva-linux-gnu/4.5.2/../../../../lib64/libx264.a(ratecontrol.o): In function `x264_threads_distribute_ratecontrol':
ratecontrol.c:(.text+0xa7d6): undefined reference to `powf'
/usr/lib/gcc/x86_64-mandriva-linux-gnu/4.5.2/../../../../lib64/libx264.a(ratecontrol.o): In function `x264_threads_merge_ratecontrol':
ratecontrol.c:(.text+0xad0e): undefined reference to `powf'
/usr/lib/gcc/x86_64-mandriva-linux-gnu/4.5.2/../../../../lib64/libx264.a(ratecontrol.o): In function `clip_qscale':
ratecontrol.c:(.text+0x568): undefined reference to `exp'
/usr/lib/gcc/x86_64-mandriva-linux-gnu/4.5.2/../../../../lib64/libx264.a(set.o): In function `x264_sps_init':
set.c:(.text+0xb82): undefined reference to `log2f'
collect2: ld returnerede afslutningskoden 1


ajschult

you need to add both -lm and -lpthead

these are listed in x264.pc:

Libs.private: -lpthread -lm

although pkg-config doesn't seem to return them for any query I could come up with.

MBantz

Nearly there :-)

Compiling with -lpthread and -lm returns with no error :-)

Asking pkg-config about x264.pc with --debug gives this:

Unknown keyword 'Libs.private' in 'x264.pc'

I try and work with x264.pc and see where this leads

MBantz

Quote from: ajschult on January 27, 2013, 04:22:08 PM
you need to add both -lm and -lpthead

these are listed in x264.pc:

Libs.private: -lpthread -lm

although pkg-config doesn't seem to return them for any query I could come up with.

It appear, by inspecting pkg-config code, that Libs.private is only honored when pkg-config is called with the parameter --static
otherwise the Libs.private stanza is ignored as 'undefined keyword' (looks like a bug in pkg-config, even latest 0.28 I just packaged for the same reason :-).

Next question is now, how do I modify avidemux to use pkg-config with --static?