<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Wow, sincere thanks for explaining
      everything :)<br>
      <br>
      I had done the ./configure, make, sudo make install sequence
      before (though only now I memorized it), but autogen.sh was a new
      for me (well, maybe I've used it before while following
      instructions, but I can't remember :p). And yes, I downloaded
      libnice from the git repo, so that explanation about autogen might
      be useful in the future. Also, I've completely missed the INSTALL
      file! But yes, it's there :)<br>
      <br>
      Indeed, I believe I installed libglib-2.0-dev. It was probably the
      only one, then. I saw those other two mentioned in the short Linux
      readme, but didn't install them.<br>
      <br>
      Those examples will also be useful. Thank you! And also "thank
      you" to everyone that contributed to the instructions and
      examples.<br>
      <br>
      I wouldn't mind at all. Feel free to use and modify what I wrote.
      By the way, I should have mentioned that my Linux is Mint 13
      (Maya), though that might not make much difference,
      instructions-wise. Same for Eclipse (in this case, the Indigo
      version), as the plugin install should work in every version.<br>
      <br>
      libnice compiled correctly in Windows with just the readme
      instructions (using the Visual Studio solution). The problem comes
      afterwards, when compiling user code that uses the library. It is
      possible that the solution contains what is needed for compiling
      it (I'm definitely not VS-savvy :) ), but if I want to use
      Eclipse, for example, I would need to know what libraries and
      paths to include. I will eventually try it to lookup how to
      correctly setup things for pkg-config in Windows, as it would
      solve this problem; it also seems interesting from your
      descriptions.<br>
      <br>
      I think the extra effort with readmes and examples would help
      other people like me immensely :)<br>
      <br>
      Much appreciated!<br>
      - Daniel<br>
      <br>
      On 15-02-2013 23:37, Youness Alaoui wrote:<br>
    </div>
    <blockquote cite="mid:511EC6C4.6030504@collabora.co.uk" type="cite">
      <pre wrap="">Hey again Daniel!

My colleague Olivier just told me that there actually are build instructions
with libnice, I didn't even notice! :p
The INSTALL file is actually auto generated (gets updated by the system when you
run ./autogen.sh) and gives you the build instructions and everything you need
to know about how to build libnice or any such similar software.
It does not mention pkg-config though, but it gives you enough info to know how
to ./configure && make && make install, clean, unintall, run the unit tests, etc...

I will simply mention that when I update the README file so people don't miss
that file.

Hope this helps,
Youness.

On 02/15/2013 06:11 PM, Youness Alaoui wrote:
</pre>
      <blockquote type="cite">
        <pre wrap="">Hi Daniel,

On 02/15/2013 11:27 AM, Daniel Lobo wrote:
</pre>
        <blockquote type="cite">
          <pre wrap="">This is not a question, but some kind of help for people with problems compiling
libnice examples. I was very surprised to find that no one ever asked how to
compile code using libnice, seeing as instructions were impossible for me to
find. Am I missing something really obvious?

</pre>
        </blockquote>
        <pre wrap="">Thanks for writing this, I'm sure others will find some of its content useful.
As for instructions. Maybe I should write build instructions in the README file.
</pre>
        <blockquote type="cite">
          <pre wrap="">
Anyway, I have, for the past 4 days, been trying to compile and use a C/C++
library that allows P2P communication for my project. After giving up for now on
the massively hard libjingle (hard to compile, hard to understand, examples with
thousands of lines...), I tried libnice.
</pre>
        </blockquote>
        <pre wrap="">
haha, yes, libjingle is a huge huge mess. libnice itself was written so we could
get rid of libjingle! You'll find libnice to be much easier to work with :)

</pre>
        <blockquote type="cite">
          <pre wrap="">

Compiling the library (Windows and Linux):

I successfully compiled libnice under Windows, using VS (just follow the readme
given in the libnice package), and under Linux. If you are compiling libnice in
Linux, and are unexperienced like I am (the readme instructions are
nonexistent), know that you have to run (inside the libnice folder) ./autogen.sh
(run "chmod +x autogen.sh" if it gives errors about permissions), ./configure,
make, sudo make install, in this order.
</pre>
        </blockquote>
        <pre wrap="">Great! The README.win32 and VS support was added by "Filippo Della Betta" who
sent his patches to this mailing list. I'm glad they were helpful to you! If you
find anything was missing, let me know and we could enhance/modify the readme
file to help others.
As for linux, there were no build instructions because the "./configure && make
&& sudo make install" is the 'standard' way of compiling anything on Linux. If
you need to compile stuff on linux, then you should know that magic sequence of
commands! To me at least, explicitely saying it is kind of like saying in the
windows instructions "in Visual Studio, go to menu build, and click the Build
button" :)
As you are new to linux, it's perfectly understandable that you didn't know
this, but at least now, you do. I will add build instructions in the README file
so other unexperienced liux users will not go through the same trouble as you did.
As for the ./autogen.sh, that's also the standard way of generating the
configure file. That's only necessary if you download the source from git, but
you don't need to do it if you download a release version since the configure
file is always pre-generated in those tarballs.

</pre>
        <blockquote type="cite">
          <pre wrap="">
You *might* need to do some apt-gets before (glib-2.0?), but I can't remember if
that was true for me (I tried loooots of things when attempting to build). If
this is the case, I'm sorry that I can't help enough, but I can't remember all
that I did (besides, I believe you can find most errors on the web, and they
should direct you to some missing library that can be acquired with apt-get).
</pre>
        </blockquote>
        <pre wrap="">As far as I remember, libnice has no dependencies other than glib. So you
probably had to do apt-get install libglib-2.0-dev. There are also dependencies
on gstreamer and on gupnp, but if those are not found during the ./configure
stage, then their respective features will simply be disabled and libnice will
compile without them.



</pre>
        <blockquote type="cite">
          <pre wrap="">

Compiling examples:

After compiling, the thing was: I couldn't (and still can't) find instructions
on how to compile libnice examples, or what libraries and paths to include. I
tried to compile the example at
<a class="moz-txt-link-freetext" href="http://nice.freedesktop.org/libnice/NiceAgent.html">http://nice.freedesktop.org/libnice/NiceAgent.html</a> (inside a main method and
using #include "agent.h") but I had to do a lot of trial and error on code
callbacks, linkage libraries, include paths, etc. Besides, there was an
undeclared variable "rcands" and, as of this writing, I still haven't understood
the theory about candidates.
</pre>
        </blockquote>
        <pre wrap="">The example there is more of a pseudo-code than an actual compilable example. It
is only meant to be read and to allow you to understand which API functions to
call and when. That's also why it couldn't compile and had missing variables, etc...
Until very recently (thanks Bryce Allen who contributed it), we never had real
examples with libnice. Most people would just read the documentation and the
unit tests to see how to use the library.
You can now find these examples here :
<a class="moz-txt-link-freetext" href="http://cgit.collabora.com/git/user/kakaroto/libnice.git/tree/examples">http://cgit.collabora.com/git/user/kakaroto/libnice.git/tree/examples</a>
They will be included in the next release of libnice (to be released very soon).
As you can see from the comment in the header of those files, they can be built
with :
 * Build:
 *   gcc -o simple-example simple-example.c `pkg-config --cflags --libs nice`

pkg-config is the standard tool on linux for defining which compiler flags and
options and libraries are needed when you compile a program that depends on the
library.
However, in the case of those examples, simply typing "make" will get them to
compile now that they are part of libnice's build system.

</pre>
        <blockquote type="cite">
          <pre wrap="">
I finally gave up after many many many undefined references of various kinds.

The ONLY thing that did save me was something called pkg-config.

Apparently, pkg-config is a tool that knows what flags you have to use when
compiling and linking your code with some libraries. One of the libraries which
it can help is "nice" (libnice).

</pre>
        </blockquote>
        <pre wrap="">Yep, libnice installs the file 'nice.pc' to /usr/lib/pkgconfig which allows
pkg-config to find which version of libnice is installed, what C flags to pass
to the compiler and what LD flags and dependent libraries to pass to the linker.
As I said above, it's the standard way on linux of checking for dependencies and
compiling programs with their dependent libraries. For example, libnice (and
pretty much every other software out there) uses pkg-config to check for the
existence and versions of their dependencies and to link with them. In the
configure.ac file, you will see this line :
PKG_CHECK_MODULES(GLIB, [dnl
        glib-2.0 >= 2.13 dnl
        gobject-2.0 >= 2.13 dnl
        gthread-2.0 >= 2.13 dnl
        gio-2.0 >= 2.13 dnl
        ])
This will check for all these modules (glib-2.0, gobject-2.0, gthread-2.0 and
gio-2.0) and will store the appropriate C flags and LD flags and dependencies in
GLIB_CFLAGS and GLIB_LIBS variables to be used in the makefile.



</pre>
        <blockquote type="cite">
          <pre wrap="">
Eclipse:

If you are using Eclipse, like me, go to "Help -> Install New Software...", use
<a class="moz-txt-link-freetext" href="http://petrituononen.com/pkg-config-support-for-eclipse-cdt/update">http://petrituononen.com/pkg-config-support-for-eclipse-cdt/update</a> as the "Work
with" site and select and install the plugin.

Then, on your project with the examples you want to run, go to Properties ->
C/C++ Build -> Pkg-config tab and select "nice". That should set the correct
includes, flags and libraries in the "Tool Settings" tab. Now it's hopefully
just a matter of using the right #includes in your code.

For those without Eclipse and wanting to know the paths and libraries, this is
what pkg-config gave me in Linux:

GCC C/C++ Compiler -> Includes -> Include paths (-I):
/usr/include/glib-2.0
/usr/lib/x86_64-linux-gnu/glib-2.0/include
/usr/local/include/nice

Compiler (C or C++) -> Miscellaneous -> other flags:
-pthread
(in addition to -c -fmessage-length=0)

GCC C++ Linker -> Libraries -> Libraries (-l):
nice
gthread-2.0
rt
gio-2.0
gobject-2.0
glib-2.0
nice
gthread-2.0
rt
gio-2.0
gobject-2.0
glib-2.0

GCC C++ Linker -> Libraries -> Library search path:
/usr/local/lib

If it helps, Eclipse ended up doing something like:

Compiler:
g++ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include
-I/usr/local/include/nice -O0 -g3 -Wall -c -fmessage-length=0 -pthread -MMD -MP
-MF"test.d" -MT"test.d" -o "test.o" "../test.cpp"

Linker:
g++ -L/usr/local/lib -o "libnice_tests"  ./test.o   -lnice -lgthread-2.0 -lrt
-lgio-2.0 -lgobject-2.0 -lglib-2.0 -lnice -lgthread-2.0 -lrt -lgio-2.0
-lgobject-2.0 -lglib-2.0

</pre>
        </blockquote>
        <pre wrap="">
Thanks for that, this looks useful, would you mind if I included parts of it in
the build instructions of the README ?

</pre>
        <blockquote type="cite">
          <pre wrap="">
pkg-config in Linux:

You can naturally also download and run pkg-config by itself (without Eclipse)
to get all of this, but I didn't do this so please bear with me and search the
web for a bit on the generic way to use pkg-config :) It should be something
like: gcc -o test test.c `pkg-config --libs --cflags glib-2.0`

</pre>
        </blockquote>
        <pre wrap="">Yep, that would do the trick, it should be installed on your system though since
I think pretty much everything would depend on it! If you want to compile
something, you would usually install gcc, autotools and some -dev packages and I
think pkg-config comes with them automatically as a dependency. :)

</pre>
        <blockquote type="cite">
          <pre wrap="">
pkg-config in Windows:

Try to download pkg-config already pre-compiled from somewhere like:
<a class="moz-txt-link-freetext" href="http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/">http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/</a>
The rest is the same as in Linux, but the problem is: pkg-config needs some
things set on path variables to detect the installed libraries and I couldn't
get it to work, not even in Eclipse :(
</pre>
        </blockquote>
        <pre wrap="">Humm.. I don't know about pkg-config on windows, but was this needed or were the
README.win32 instructions enough for you to get it to compile correctly on windows ?

</pre>
        <blockquote type="cite">
          <pre wrap="">

I hope some of this actually helps someone...
</pre>
        </blockquote>
        <pre wrap="">It is, thanks for taking the time to write this email. I will use that to
improve the README so others don't have to go through it the hard way.

Thanks,
Youness.




_______________________________________________
nice mailing list
<a class="moz-txt-link-abbreviated" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freedesktop.org/mailman/listinfo/nice">http://lists.freedesktop.org/mailman/listinfo/nice</a>

</pre>
      </blockquote>
      <pre wrap="">

</pre>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
nice mailing list
<a class="moz-txt-link-abbreviated" href="mailto:nice@lists.freedesktop.org">nice@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freedesktop.org/mailman/listinfo/nice">http://lists.freedesktop.org/mailman/listinfo/nice</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>