<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Building LibVorbis fails</title>
		<link>http://www.allegro.cc/forums/view/598976</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Wed, 28 Jan 2009 13:02:02 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;ve been trying to get libvorbis built and installed for a while now, but libvorbis is not linking to libogg when they build their libraries.</p><p>I attached the build log for libvorbis, hopefully someone can help me. The problem is in the last few lines before all of the undefined reference errors near the bottom of the log.</p><p> </p><div class="source-code snippet"><div class="inner"><pre><span class="c">// ...</span>
C:<span class="k3">/</span>msys<span class="k3">/</span><span class="n">1</span>.<span class="n">0</span><span class="k3">/</span>bin<span class="k3">/</span>sh.exe ..<span class="k3">/</span>libtool <span class="k3">-</span><span class="k3">-</span>tag<span class="k3">=</span>CC   <span class="k3">-</span><span class="k3">-</span>mode<span class="k3">=</span>compile gcc <span class="k3">-</span>DHAVE_CONFIG_H <span class="k3">-</span>I. <span class="k3">-</span>I.. <span class="k3">-</span>I..<span class="k3">/</span>include <span class="k3">-</span>I<span class="k3">/</span>mingw<span class="k3">/</span>include    <span class="k3">-</span>O20 <span class="k3">-</span>D__NO_MATH_INLINES <span class="k3">-</span>fsigned-char  <span class="k3">-</span>DUSE_MEMORY_H <span class="k3">-</span>MT vorbisfile.lo <span class="k3">-</span>MD <span class="k3">-</span>MP <span class="k3">-</span>MF .deps<span class="k3">/</span>vorbisfile.Tpo <span class="k3">-</span>c <span class="k3">-</span>o vorbisfile.lo vorbisfile.c
 gcc <span class="k3">-</span>DHAVE_CONFIG_H <span class="k3">-</span>I. <span class="k3">-</span>I.. <span class="k3">-</span>I..<span class="k3">/</span>include <span class="k3">-</span>I<span class="k3">/</span>mingw<span class="k3">/</span>include <span class="k3">-</span>O20 <span class="k3">-</span>D__NO_MATH_INLINES <span class="k3">-</span>fsigned-char <span class="k3">-</span>DUSE_MEMORY_H <span class="k3">-</span>MT vorbisfile.lo <span class="k3">-</span>MD <span class="k3">-</span>MP <span class="k3">-</span>MF .deps<span class="k3">/</span>vorbisfile.Tpo <span class="k3">-</span>c vorbisfile.c  <span class="k3">-</span>DDLL_EXPORT <span class="k3">-</span>DPIC <span class="k3">-</span>o .libs<span class="k3">/</span>vorbisfile.o
 gcc <span class="k3">-</span>DHAVE_CONFIG_H <span class="k3">-</span>I. <span class="k3">-</span>I.. <span class="k3">-</span>I..<span class="k3">/</span>include <span class="k3">-</span>I<span class="k3">/</span>mingw<span class="k3">/</span>include <span class="k3">-</span>O20 <span class="k3">-</span>D__NO_MATH_INLINES <span class="k3">-</span>fsigned-char <span class="k3">-</span>DUSE_MEMORY_H <span class="k3">-</span>MT vorbisfile.lo <span class="k3">-</span>MD <span class="k3">-</span>MP <span class="k3">-</span>MF .deps<span class="k3">/</span>vorbisfile.Tpo <span class="k3">-</span>c vorbisfile.c <span class="k3">-</span>o vorbisfile.o <span class="k3">&gt;</span><span class="k3">/</span>dev<span class="k3">/</span>null <span class="n">2</span><span class="k3">&gt;</span><span class="k3">&amp;</span><span class="n">1</span>
mv <span class="k3">-</span>f .deps<span class="k3">/</span>vorbisfile.Tpo .deps<span class="k3">/</span>vorbisfile.Plo
C:<span class="k3">/</span>msys<span class="k3">/</span><span class="n">1</span>.<span class="n">0</span><span class="k3">/</span>bin<span class="k3">/</span>sh.exe ..<span class="k3">/</span>libtool <span class="k3">-</span><span class="k3">-</span>tag<span class="k3">=</span>CC   <span class="k3">-</span><span class="k3">-</span>mode<span class="k3">=</span><a href="http://www.delorie.com/djgpp/doc/libc/libc_531.html" target="_blank">link</a> gcc  <span class="k3">-</span>O20 <span class="k3">-</span>D__NO_MATH_INLINES <span class="k3">-</span>fsigned-char  <span class="k3">-</span>DUSE_MEMORY_H <span class="k3">-</span>no-undefined <span class="k3">-</span>version-info <span class="n">5</span><span class="k2">:</span><span class="n">0</span><span class="k2">:</span><span class="n">2</span>  <span class="k3">-</span>o libvorbisfile.la <span class="k3">-</span>rpath <span class="k3">/</span>mingw<span class="k3">/</span>lib vorbisfile.lo libvorbis.la 
gcc <span class="k3">-</span>shared  .libs<span class="k3">/</span>vorbisfile.o  .<span class="k3">/</span>.libs<span class="k3">/</span>libvorbis.dll.a <span class="k3">-</span>L<span class="k3">/</span>mingw<span class="k3">/</span>lib  <span class="k3">-</span>o .libs<span class="k3">/</span>libvorbisfile-3.dll <span class="k3">-</span>Wl,<span class="k3">-</span><span class="k3">-</span>enable-auto-image-base <span class="k3">-</span>Xlinker <span class="k3">-</span><span class="k3">-</span>out-implib <span class="k3">-</span>Xlinker .libs<span class="k3">/</span>libvorbisfile.dll.a
.libs<span class="k3">/</span>vorbisfile.o:vorbisfile.c:<span class="k2">(</span>.text<span class="k3">+</span><span class="n">0x73</span><span class="k2">)</span><span class="k2">:</span> undefined reference to `ogg_sync_pageseek<span class="s">'</span>
<span class="s">.libs/vorbisfile.o:vorbisfile.c:(.text+0xc2): undefined reference to `ogg_sync_buffer'</span>
.libs<span class="k3">/</span>vorbisfile.o:vorbisfile.c:<span class="k2">(</span>.text<span class="k3">+</span><span class="n">0xf6</span><span class="k2">)</span><span class="k2">:</span> undefined reference to `ogg_sync_wrote<span class="s">'</span>
<span class="s">// ...</span>
</pre></div></div><p>

I found this <a href="http://www.allegro.cc/forums/thread/543339/546807#target">reply about building libogg and libvorbis</a> and the errors are similar, but I don&#39;t think Victor&#39;s solution is entirely accurate for my uses (He&#39;s using devcpp, I&#39;m using MinGW  , he links against both the static and import libraries of libogg).</p><p>Can anyone help me figure out how to manually link libvorbis at this stage so I can continue on with the rest of the make process?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Thu, 22 Jan 2009 07:24:19 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Try with:
</p><div class="source-code snippet"><div class="inner"><pre>.<span class="k3">/</span>configure <span class="k3">-</span><span class="k3">-</span>disable-shared
</pre></div></div><p>
It worked for me (<i>libogg-1.1.3</i> and <i>libvorbis-1.2.0</i> with <i>gcc</i> 3.4.5).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (kenmasters1976)</author>
		<pubDate>Thu, 22 Jan 2009 09:00:49 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yup, that worked for me too. If you&#39;re really lazy I have some precompiled packages at <a href="http://trent.gamblin.ca/logg">http://trent.gamblin.ca/logg</a>, static only.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Trent Gamblin)</author>
		<pubDate>Thu, 22 Jan 2009 09:18:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">kenmasters1976 said:</div><div class="quote"><p>

Try with:</p><p>./configure --disable-shared</p><p>It worked for me (libogg-1.1.3 and libvorbis-1.2.0 with gcc 3.4.5).
</p></div></div><p>

That means the dll won&#39;t be built though, doesn&#39;t it? I&#39;d like to get it built if I can. I&#39;m trying to build the same versions of the libraries with the same MinGW version that you used as well.</p><div class="quote_container"><div class="title">Trent Gamblin said:</div><div class="quote"><p>

Yup, that worked for me too. If you&#39;re really lazy I have some precompiled packages at <a href="http://trent.gamblin.ca/logg">http://trent.gamblin.ca/logg</a>, static only.
</p></div></div><p>
So you skipped the shared library too?</p><p>Sorry, I&#39;m just in the mood to make this thing work. I&#39;m not going to let these wacko configure jobbies get the best of me.</p><p>It looks like this line is creating a dll and the import library in the same command :
</p><div class="source-code snippet"><div class="inner"><pre><span class="c">//</span>
gcc <span class="k3">-</span>shared  .libs<span class="k3">/</span>vorbisfile.o  .<span class="k3">/</span>.libs<span class="k3">/</span>libvorbis.dll.a <span class="k3">-</span>L<span class="k3">/</span>mingw<span class="k3">/</span>lib  <span class="k3">-</span>o .libs<span class="k3">/</span>libvorbisfile-3.dll <span class="k3">-</span>Wl,<span class="k3">-</span><span class="k3">-</span>enable-auto-image-base <span class="k3">-</span>Xlinker <span class="k3">-</span><span class="k3">-</span>out-implib <span class="k3">-</span>Xlinker .libs<span class="k3">/</span>libvorbisfile.dll.a
<span class="c">//</span>
</pre></div></div><p>
It says &#39;-o .libs/libvorbisfile-3.dll&#39;, and the two arguments following the -Xlinker arguments specify to create an import library (--out-implib), and name it .libs/libvorbisfile.dll.a</p><p>So, which form of the ogg library should I link to in addition to the arguments there?</p><p>Victor&#39;s reply seemed to link against both the static and import libraries of ogg ( -logg -logg.dll ).
</p><div class="source-code snippet"><div class="inner"><pre><span class="c">//</span>
gcc <span class="k3">-</span>shared  .libs<span class="k3">/</span>vorbisfile.o  <span class="k3">-</span>logg <span class="k3">-</span>logg.dll  .<span class="k3">/</span>.libs<span class="k3">/</span>libvorbis.dll.a  <span class="k3">-</span>o .libs<span class="k3">/</span>libvorbisfile-3.dll <span class="k3">-</span>Wl,<span class="k3">-</span><span class="k3">-</span>image-base<span class="k3">=</span><span class="n">0x10000000</span> <span class="k3">-</span>Wl,<span class="k3">-</span><span class="k3">-</span>out-implib,.libs<span class="k3">/</span>libvorbisfile.dll.a
<span class="c">//</span>
</pre></div></div><p>

Since this is building the dll and the import library of libvorbisfile, should I use the import library of ogg, or does it make more sense to statically link ogg into it? I don&#39;t know all that much about library creation yet.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Thu, 22 Jan 2009 10:05:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Curious thing is that it actually <b>does</b> create the shared library if you build it after <i>./configure --disable-shared</i>. I&#39;m not good with makefiles so I don&#39;t know why, but if after building, you <i>./configure</i> it again enabling the shared lib, it will simply say that there&#39;s nothing left to do next time you <i>make</i> it.</p><p>I don&#39;t know if the shared lib is created correctly though since I haven&#39;t used it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (kenmasters1976)</author>
		<pubDate>Thu, 22 Jan 2009 10:44:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;ll keep that in mind in case I can&#39;t make it work normally.</p><p>After &#39;./configure --prefix=/mingw&#39; and &#39;mingw32-make&#39; fails with the undefined references, I can build the shared libraries without any error by using :
</p><div class="source-code snippet"><div class="inner"><pre><span class="c">//</span>
$ rm .libs<span class="k3">/</span>libvorbisfile.dll.a

$ gcc <span class="k3">-</span>shared  .libs<span class="k3">/</span>vorbisfile.o  .<span class="k3">/</span>.libs<span class="k3">/</span>libvorbis.dll.a <span class="k3">-</span>L<span class="k3">/</span>mingw<span class="k3">/</span>lib <span class="k3">-</span>logg <span class="k3">-</span>o .libs<span class="k3">/</span>libvorbisfile-3.dll <span class="k3">-</span>Wl,<span class="k3">-</span><span class="k3">-</span>enable-auto-image-base <span class="k3">-</span>Xlinker <span class="k3">-</span><span class="k3">-</span>out-implib <span class="k3">-</span>Xlinker .libs<span class="k3">/</span>libvorbisfile.dll.a
Creating library file: .libs<span class="k3">/</span>libvorbisfile.dll.a
<span class="c">//</span>
</pre></div></div><p>

But calling mingw32-make again after that tries to rebuild it over again and fails in the same way.</p><p>So, I passed -k to mingw32-make to make it keep going past any errors, and it builds the libvorbisenc shared and static libraries and dll, but I seem to be missing the static library for libvorbisfile. Isn&#39;t there supposed to be a decoding library as well?</p><p>I managed to track what I believe to be the offending line that creates the command line missing the linker argument for libogg :</p><div class="quote_container"><div class="title">c:/mingw/libvorbis-1.2.0/libtool file lines 213-214 said:</div><div class="quote"><p>

</p><div class="source-code snippet"><div class="inner"><pre><span class="c">//</span>
<span class="p"># Commands used to build and install a shared archive.</span>
archive_cmds<span class="k3">=</span><span class="s">"\$CC -shared \$libobjs \$deplibs \$compiler_flags -o \$output_objdir/\$soname \${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker \$lib"</span>
<span class="c">//</span>
</pre></div></div><p>
</p></div></div><p>

It matches the faulty compiling command from the build log verbatim. So I think the problem is with the way the \$deplibs variable is being created in the libtool file there. Maybe I can track it down further tomorrow.</p><p>Can anyone give me a quick rundown of what happens build wise when a configure script is run? Does it generate the libtool file? Ie.. - where&#39;s the real source of the missing -logg parameter coming from?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Thu, 22 Jan 2009 15:32:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Have you tried with the options in <i>./configure --help</i> to manually set the directory where <i>libogg</i> is installed?. I guess I&#39;d read that it gets messed (at least with MinGW) and manually setting it should solve the problem, but I didn&#39;t try it.</p><p>As for manually fixing the configure script and makefiles, I have no idea.</p><p>I have these files generated in the <i>libvorbis-1.2.0\lib\.libs</i> dir:<br /><i>libvorbis.a
libvorbis.dll.a
libvorbisenc.a
libvorbisfile.a</i>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (kenmasters1976)</author>
		<pubDate>Thu, 22 Jan 2009 23:41:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><i><b>See &quot;fix&quot; below</b></i></p><div class="quote_container"><div class="title">kenmasters1976 said:</div><div class="quote"><p>

I have these files generated in the libvorbis-1.2.0\lib\.libs dir:
</p></div></div><p>
With the aforementioned tweaking to the build process, I have these :
</p><pre>
Static                 Dynamic                  Import
---------------------------------------------------------------------
libvorbis.a            libvorbis.dll.a          libvorbis-0.dll
libvorbisenc.a         libvorbisenc.dll.a       libvorbisenc-2.dll
                       libvorbisfile.dll.a      libvorbisfile-3.dll
</pre><p>
So somehow, it&#39;s missing the static link library libvorbisfile.a.</p><div class="quote_container"><div class="title">kenmasters1976 said:</div><div class="quote"><p>

Have you tried with the options in ./configure --help to manually set the directory where libogg is installed?
</p></div></div><p>
Oh, didn&#39;t know about &#39;./configure --help&#39;. It shows these options related to linking with ogg.
</p><div class="quote_container"><div class="title">kenmasters1976 said:</div><div class="quote"><p>

  --with-ogg=PFX   Prefix where libogg is installed (optional)<br />  --with-ogg-libraries=DIR   Directory where libogg library is installed (optional)<br />  --with-ogg-includes=DIR   Directory where libogg header files are installed (optional)
</p></div></div><p>

I tried this :
</p><pre>
./configure --prefix=/mingw --with-ogg-libraries=/c/mingw/lib --with-ogg-includes=/c/mingw/include
</pre><p>
but it failed at the same place and had an extra warning - <br />&#39;libogg.la may have been moved&#39;.</p><p> </p><pre>#######     It&#39;s a hack, but it seems to work     #######</pre><p>
So I saw that you can set an environment variable named LIBS to the linking options for extra libraries to link with, so I unpacked a fresh copy of the library and used :<br /> </p><pre>
export LIBS=-logg
./configure --prefix=/mingw
.....
mingw32-make
.....
</pre><p>
and it built the static and import libraries and the dlls for libvorbis, libvorbisfile, and libvorbisenc without any errors. After that I went back to compiling the logg addon for allegro 4.3.x, and it worked fine (it links against the static libraries of ogg and vorbis). I also tested a modified play_ogg.c that linked against ogg, vorbis, and vorbisfile dynamically and that worked as well.</p><p>It&#39;s certainly not a fix by any means but rather a hack - the build process passes -logg twice in one place and LIBS shouldn&#39;t need to be set to -logg.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Fri, 23 Jan 2009 15:01:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I extracted a clean copy of <i>libvorbis</i> and tried your fix. It worked perfectly. It created all files including <i>libvorbisfile.a</i>... then I remembered that I only have the static <i>libogg</i> libraries installed, so it might have something to do.</p><p>There&#39;s something weird indeed in trying to build <i>libvorbis</i>, but your fix solve it pretty nicely.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (kenmasters1976)</author>
		<pubDate>Sat, 24 Jan 2009 05:10:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I gave up on trying to find out where the configure script and/or autotools was messing up. Something to learn for another day, and perhaps better left to the libvorbis developers who know what&#39;s happening behind the scenes.</p><p>Anyway, thanks for your help guys. Cookies! <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" /></p><p><s>Edit</s><br />I also submitted a bug report over at xiph.org :<br /> <a href="https://trac.xiph.org/ticket/1499">https://trac.xiph.org/ticket/1499</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Wed, 28 Jan 2009 13:02:02 +0000</pubDate>
	</item>
</rss>
