Sample Code Compilation Problem

225 views
Skip to first unread message

Bolan Meek

unread,
Sep 15, 2013, 1:59:13 PM9/15/13
to apps-...@webmproject.org
After installing the sources, and successfully building, and testing, including using vpxdec to decode a .webm file, and vpxenc to reencode it, I'm hitting a wall trying to compile snippets from http://www.webmproject.org/docs/vp8-sdk/example__simple__encoder.html:

This snippet is just for getting the default configuration:
#include <stdio.h>
#include <vpx/vpx_encoder.h>
#include <vpx/vp8cx.h>
#define interface (vpx_codec_vp8_cx())

int main()
{
  vpx_codec_enc_cfg_t cfg;
  vpx_codec_err_t errRet;
  
  errRet = vpx_codec_enc_config_default(interface, &cfg, 0);
  if (errRet == VPX_CODEC_OK)
    puts("got default configuration");
  else
    puts("failed to get default configuration");
  return 0;
 }

When I try to compile it, the linker doesn't seem to find certain symbols in libvpx.a:
libvpx $ gcc -lvpx -o experiment/getDefaultConfig experiment/getDefaultConfig.c
/tmp/cckEfNvx.o: In function `vpx_codec_control_VP8_SET_REFERENCE':
getDefaultConfig.c:(.text+0x29): undefined reference to `vpx_codec_control_'
/tmp/cckEfNvx.o: In function `vpx_codec_control_VP8_COPY_REFERENCE':
getDefaultConfig.c:(.text+0x58): undefined reference to `vpx_codec_control_'
/tmp/cckEfNvx.o: In function `vpx_codec_control_VP8_SET_POSTPROC':
getDefaultConfig.c:(.text+0x87): undefined reference to `vpx_codec_control_'
/tmp/cckEfNvx.o: In function `vpx_codec_control_VP8_SET_DBG_COLOR_REF_FRAME':
getDefaultConfig.c:(.text+0xb4): undefined reference to `vpx_codec_control_'
/tmp/cckEfNvx.o: In function `vpx_codec_control_VP8_SET_DBG_COLOR_MB_MODES':
getDefaultConfig.c:(.text+0xe1): undefined reference to `vpx_codec_control_'
/tmp/cckEfNvx.o:getDefaultConfig.c:(.text+0x10e): more undefined references to `vpx_codec_control_' follow
/tmp/cckEfNvx.o: In function `main':
getDefaultConfig.c:(.text+0x4db): undefined reference to `vpx_codec_vp8_cx'
getDefaultConfig.c:(.text+0x4f2): undefined reference to `vpx_codec_enc_config_default'
collect2: error: ld returned 1 exit status

However, vpx_codec_control_ , vpx_codec_vp8_cx and vpx_codec_enc_config_default are all in libvpx.a:
libvpx $ nm /usr/local/lib/libvpx.a | grep -B 2 vpx_codec_control_

vpx_codec.c.o:
0000000000000150 T vpx_codec_control_
libvpx $ nm /usr/local/lib/libvpx.a | grep -B 24 vpx_codec_vp8_cx

vp8_cx_iface.c.o:
                 U calloc
                 U free
0000000000000000 r .LC28
                 U malloc
                 U vp8_change_config
                 U vp8_create_compressor
                 U vp8_get_compressed_data
                 U vp8_get_preview_raw_frame
                 U vp8_get_quantizer
                 U vp8_get_reference
                 U vp8_receive_raw_frame
                 U vp8_remove_compressor
                 U vp8_reverse_trans
                 U vp8_set_active_map
                 U vp8_set_internal_size
                 U vp8_set_reference
                 U vp8_set_roimap
                 U vp8_update_entropy
                 U vp8_update_reference
                 U vp8_use_as_reference
                 U vpx_codec_pkt_list_add
                 U vpx_codec_pkt_list_get
0000000000002cb0 T vpx_codec_vp8_cx
libvpx $ nm /usr/local/lib/libvpx.a | grep -B 3 vpx_codec_enc_config_default
vpx_encoder.c.o:
                 U memcpy
                 U vpx_codec_destroy
0000000000000400 T vpx_codec_enc_config_default

If I pass in the object from which vpx_codec_control_ was derived, the linker finds the first of the symbols:
libvpx $ gcc -lvpx -o experiment/getDefaultConfig experiment/getDefaultConfig.c vpx/src/vpx_codec.c.o
/tmp/ccIlU56O.o: In function `main':
getDefaultConfig.c:(.text+0x4db): undefined reference to `vpx_codec_vp8_cx'
getDefaultConfig.c:(.text+0x4f2): undefined reference to `vpx_codec_enc_config_default'
collect2: error: ld returned 1 exit status

If I also pass in the object from which vpx_codec_enc_config_default, that symbol is found:
libvpx $ gcc -lvpx -o experiment/getDefaultConfig experiment/getDefaultConfig.c vpx/src/vpx_encoder.c.o vpx/src/vpx_codec.c.o
/tmp/ccFQgq3T.o: In function `main':
getDefaultConfig.c:(.text+0x4db): undefined reference to `vpx_codec_vp8_cx'
collect2: error: ld returned 1 exit status

If I yet also pass in the object from which vpx_codec_vp8_cx is derived, that symbol is found, but a long list of others are not:
libvpx $ gcc -lvpx -o experiment/getDefaultConfig experiment/getDefaultConfig.c vpx/src/vpx_encoder.c.o vpx/src/vpx_codec.c.o vp8/vp8_cx_iface.c.o
vp8/vp8_cx_iface.c.o: In function `get_param':
vp8_cx_iface.c:(.text+0xa8): undefined reference to `vp8_get_quantizer'
vp8_cx_iface.c:(.text+0xaf): undefined reference to `vp8_reverse_trans'
vp8_cx_iface.c:(.text+0xc8): undefined reference to `vp8_get_quantizer'
vp8/vp8_cx_iface.c.o: In function `vp8e_set_scalemode':
vp8_cx_iface.c:(.text+0x10b): undefined reference to `vp8_set_internal_size'
vp8/vp8_cx_iface.c.o: In function `vp8e_set_activemap':
vp8_cx_iface.c:(.text+0x174): undefined reference to `vp8_set_active_map'
vp8/vp8_cx_iface.c.o: In function `vp8e_set_roi_map':
vp8_cx_iface.c:(.text+0x1e4): undefined reference to `vp8_set_roimap'
vp8/vp8_cx_iface.c.o: In function `vp8e_use_reference':
vp8_cx_iface.c:(.text+0x231): undefined reference to `vp8_use_as_reference'
vp8/vp8_cx_iface.c.o: In function `vp8e_update_reference':
vp8_cx_iface.c:(.text+0x271): undefined reference to `vp8_update_reference'
vp8/vp8_cx_iface.c.o: In function `vp8e_update_entropy':
vp8_cx_iface.c:(.text+0x2b1): undefined reference to `vp8_update_entropy'
vp8/vp8_cx_iface.c.o: In function `vp8e_get_preview':
vp8_cx_iface.c:(.text+0x32e): undefined reference to `vp8_get_preview_raw_frame'
vp8/vp8_cx_iface.c.o: In function `vp8e_destroy':
vp8_cx_iface.c:(.text+0x408): undefined reference to `vp8_remove_compressor'
vp8/vp8_cx_iface.c.o: In function `vp8e_init':
vp8_cx_iface.c:(.text+0x81c): undefined reference to `vp8_rtcd'
vp8_cx_iface.c:(.text+0xfbe): undefined reference to `vp8_create_compressor'
vp8/vp8_cx_iface.c.o: In function `vp8e_get_reference':
vp8_cx_iface.c:(.text+0x1112): undefined reference to `vp8_get_reference'
vp8/vp8_cx_iface.c.o: In function `vp8e_set_reference':
vp8_cx_iface.c:(.text+0x11e2): undefined reference to `vp8_set_reference'
vp8/vp8_cx_iface.c.o: In function `set_param':
vp8_cx_iface.c:(.text+0x1c06): undefined reference to `vp8_change_config'
vp8/vp8_cx_iface.c.o: In function `vp8e_set_config':
vp8_cx_iface.c:(.text+0x237d): undefined reference to `vp8_change_config'
vp8/vp8_cx_iface.c.o: In function `vp8e_encode.part.5':
vp8_cx_iface.c:(.text+0x2507): undefined reference to `vp8_change_config'
vp8_cx_iface.c:(.text+0x25a4): undefined reference to `vp8_use_as_reference'
vp8_cx_iface.c:(.text+0x2709): undefined reference to `vp8_receive_raw_frame'
vp8_cx_iface.c:(.text+0x279d): undefined reference to `vp8_get_compressed_data'
vp8_cx_iface.c:(.text+0x2a8b): undefined reference to `vp8_update_reference'
vp8_cx_iface.c:(.text+0x2ae2): undefined reference to `vp8_update_entropy'
collect2: error: ld returned 1 exit status

From what I interpret from the nm output, these are all from vp8_cx_iface.c.o, so I don't know what further work-around I can attempt.  Please, advise.

This is on Linux armalite.bolanm.me 3.2.0-4-amd64 #1 SMP Debian 3.2.41-2 x86_64 GNU/Linux
libvpx $ gcc --version
gcc (Debian 4.7.3-4) 4.7.3

Bolan Meek

unread,
Sep 15, 2013, 2:06:17 PM9/15/13
to apps-...@webmproject.org
Taking a clue from another thread , I tried putting the -lvpx last, saw that it was failing to find math functions, so added -lm, now I'm getting failure to find pthread and semaphore functions:
 libvpx $ gcc -o experiment/getDefaultConfig experiment/getDefaultConfig.c -lvpx -lm
/usr/local/lib/libvpx.a(onyx_if.c.o): In function `vp8_change_config':
(.text+0x2100): undefined reference to `sem_wait'
/usr/local/lib/libvpx.a(onyx_if.c.o): In function `vp8_loopfilter_frame':
(.text+0x36cc): undefined reference to `sem_post'
/usr/local/lib/libvpx.a(onyx_if.c.o): In function `vp8_loopfilter_frame':
(.text+0x3e9e): undefined reference to `sem_post'
/usr/local/lib/libvpx.a(onyx_if.c.o): In function `vp8_loopfilter_frame':
(.text+0x4736): undefined reference to `sem_wait'
/usr/local/lib/libvpx.a(onyx_if.c.o): In function `vp8_loopfilter_frame':
(.text+0x592c): undefined reference to `sem_wait'
/usr/local/lib/libvpx.a(onyx_if.c.o): In function `vp8_loopfilter_frame':
(.text+0x5e99): undefined reference to `sem_wait'
/usr/local/lib/libvpx.a(onyx_if.c.o): In function `vp8_get_preview_raw_frame':
(.text+0x7e71): undefined reference to `sem_wait'
/usr/local/lib/libvpx.a(rtcd.c.o): In function `vpx_rtcd':
(.text+0x45b): undefined reference to `pthread_once'
/usr/local/lib/libvpx.a(encodeframe.c.o): In function `vp8_encode_frame':
(.text+0x20b8): undefined reference to `sem_post'
/usr/local/lib/libvpx.a(encodeframe.c.o): In function `vp8_encode_frame':
(.text+0x2216): undefined reference to `sem_post'
/usr/local/lib/libvpx.a(encodeframe.c.o): In function `vp8_encode_frame':
(.text+0x223d): undefined reference to `sem_wait'
/usr/local/lib/libvpx.a(ethreading.c.o):(.text+0x2c): undefined reference to `sem_wait'
/usr/local/lib/libvpx.a(ethreading.c.o):(.text+0x69): undefined reference to `sem_post'
/usr/local/lib/libvpx.a(ethreading.c.o):(.text+0xdf): undefined reference to `sem_wait'
/usr/local/lib/libvpx.a(ethreading.c.o):(.text+0x79d): undefined reference to `sem_post'
/usr/local/lib/libvpx.a(ethreading.c.o): In function `vp8cx_create_encoder_threads':
(.text+0x146b): undefined reference to `sem_init'
/usr/local/lib/libvpx.a(ethreading.c.o): In function `vp8cx_create_encoder_threads':
(.text+0x14fd): undefined reference to `sem_init'
/usr/local/lib/libvpx.a(ethreading.c.o): In function `vp8cx_create_encoder_threads':
(.text+0x152b): undefined reference to `pthread_create'
/usr/local/lib/libvpx.a(ethreading.c.o): In function `vp8cx_create_encoder_threads':
(.text+0x1582): undefined reference to `pthread_join'
/usr/local/lib/libvpx.a(ethreading.c.o): In function `vp8cx_create_encoder_threads':
(.text+0x1595): undefined reference to `sem_destroy'
/usr/local/lib/libvpx.a(ethreading.c.o): In function `vp8cx_create_encoder_threads':
(.text+0x15a4): undefined reference to `sem_destroy'
/usr/local/lib/libvpx.a(ethreading.c.o): In function `vp8cx_create_encoder_threads':
(.text+0x161e): undefined reference to `sem_init'
/usr/local/lib/libvpx.a(ethreading.c.o): In function `vp8cx_create_encoder_threads':
(.text+0x162a): undefined reference to `sem_init'
/usr/local/lib/libvpx.a(ethreading.c.o): In function `vp8cx_create_encoder_threads':
(.text+0x164b): undefined reference to `pthread_create'
/usr/local/lib/libvpx.a(ethreading.c.o): In function `vp8cx_create_encoder_threads':
(.text+0x1693): undefined reference to `sem_post'
/usr/local/lib/libvpx.a(ethreading.c.o): In function `vp8cx_create_encoder_threads':
(.text+0x16a9): undefined reference to `pthread_join'
/usr/local/lib/libvpx.a(ethreading.c.o): In function `vp8cx_create_encoder_threads':
(.text+0x16bc): undefined reference to `sem_destroy'
/usr/local/lib/libvpx.a(ethreading.c.o): In function `vp8cx_create_encoder_threads':
(.text+0x16cb): undefined reference to `sem_destroy'
/usr/local/lib/libvpx.a(ethreading.c.o): In function `vp8cx_create_encoder_threads':
(.text+0x16d3): undefined reference to `sem_destroy'
/usr/local/lib/libvpx.a(ethreading.c.o): In function `vp8cx_create_encoder_threads':
(.text+0x16db): undefined reference to `sem_destroy'
/usr/local/lib/libvpx.a(ethreading.c.o): In function `vp8cx_remove_encoder_threads':
(.text+0x17df): undefined reference to `sem_post'
/usr/local/lib/libvpx.a(ethreading.c.o): In function `vp8cx_remove_encoder_threads':
(.text+0x17f5): undefined reference to `pthread_join'
/usr/local/lib/libvpx.a(ethreading.c.o): In function `vp8cx_remove_encoder_threads':
(.text+0x1804): undefined reference to `sem_destroy'
/usr/local/lib/libvpx.a(ethreading.c.o): In function `vp8cx_remove_encoder_threads':
(.text+0x181c): undefined reference to `sem_post'
/usr/local/lib/libvpx.a(ethreading.c.o): In function `vp8cx_remove_encoder_threads':
(.text+0x182a): undefined reference to `pthread_join'
/usr/local/lib/libvpx.a(ethreading.c.o): In function `vp8cx_remove_encoder_threads':
(.text+0x1836): undefined reference to `sem_destroy'
/usr/local/lib/libvpx.a(ethreading.c.o): In function `vp8cx_remove_encoder_threads':
(.text+0x1842): undefined reference to `sem_destroy'
/usr/local/lib/libvpx.a(ethreading.c.o): In function `vp8cx_remove_encoder_threads':
(.text+0x184a): undefined reference to `sem_destroy'

Bolan Meek

unread,
Sep 15, 2013, 2:09:44 PM9/15/13
to apps-...@webmproject.org
Successfully compiled with -lpthread.

libvpx $ gcc -o experiment/getDefaultConfig experiment/getDefaultConfig.c -lvpx -lm -lpthread
libvpx $ experiment/getDefaultConfig 
got default configuration

letr...@gmail.com

unread,
Mar 10, 2015, 1:23:28 PM3/10/15
to apps-...@webmproject.org
Thank you so much
Thong LT 
Reply all
Reply to author
Forward
0 new messages