{"id":3843,"date":"2014-03-30T06:01:22","date_gmt":"2014-03-30T06:01:22","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/using-libavformat-in-c-code-undefined-x86_64-symbols-collection-of-common-programming-errors\/"},"modified":"2014-03-30T06:01:22","modified_gmt":"2014-03-30T06:01:22","slug":"using-libavformat-in-c-code-undefined-x86_64-symbols-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/using-libavformat-in-c-code-undefined-x86_64-symbols-collection-of-common-programming-errors\/","title":{"rendered":"Using libavformat in C code, undefined x86_64 symbols-Collection of common programming errors"},"content":{"rendered":"<p>I am working on a project where I have to create a simple C program that makes use of <code>libavformat<\/code> to convert a file from one format to another.<\/p>\n<p>I am working on OS X (10.8.3) and have installed <code>libav<\/code> through the following steps.<\/p>\n<p>First, install dependancies using Homebrew:<\/p>\n<pre><code>brew install yasm zlib faac lame speex libogg libvorbis theora libvpx x264\nXviD openjpeg opencore-amr freetype\n<\/code><\/pre>\n<p>Next, download libav from here: http:\/\/libav.org\/download.html (using the <code>libav 9 \"plain 9\"<\/code> release)<\/p>\n<p>Finally, configure with the following commands:<\/p>\n<pre><code>export CFLAGS=\"-I\/usr\/local\/Cellar\/openjpeg\/1.5.1\/include\/openjpeg-1.5\/ -I\/usr\/local\/Cellar\/lame\/3.99.5\/include\/lame\/\"\n\n.\/configure --enable-gpl --enable-libx264 --enable-libxvid --enable-version3\n--enable-libopencore-amrnb --enable-libopencore-amrwb --enable-nonfree\n--enable-libfaac --enable-libmp3lame --enable-libspeex --enable-libvorbis\n--enable-libtheora --enable-libvpx --enable-libopenjpeg --enable-libfreetype\n--enable-doc --enable-gnutls --enable-shared --arch=x86_64\n<\/code><\/pre>\n<p>Everything compiles correctly and gives a list of supported codecs, encoders, decoders, muxers, demuxers, etc.<\/p>\n<p>I then run <code>make &amp;&amp; sudo make install<\/code>.<\/p>\n<p>However, once I try to make use of <code>av_register_all()<\/code> and some other critical functions in my own C code, I get the following error:<\/p>\n<pre><code>Undefined symbols for architecture x86_64:\n  \"_av_register_all\", referenced from:\n      _main in base-bPKLay.o\n<\/code><\/pre>\n<p>I have tried compiling it using <code>gcc -Wall base.c -o base<\/code> as well as <code>clang -Wall base.c -o base<\/code>, but both give the above error. I fear that something is wrong with how the libraries are linked, but I am not experienced enough with C programming in general to know where to look next. The C code itself compiles fine when I remove the <code>av_register_all()<\/code> call.<\/p>\n<p>The include for libavformat looks like this: <code>#include \"libavformat\/avformat.h\"<\/code><\/p>\n<p>Any help is appreciated. I have tried adding <code>-arch x86_64<\/code> to the CFLAGS export, but it made no difference.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am working on a project where I have to create a simple C program that makes use of libavformat to convert a file from one format to another. I am working on OS X (10.8.3) and have installed libav through the following steps. First, install dependancies using Homebrew: brew install yasm zlib faac lame [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3843","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3843","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3843"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3843\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3843"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3843"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3843"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}