Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

libfov

2 views
Skip to first unread message

Ido.Y...@gmail.com

unread,
Apr 7, 2006, 4:33:11 AM4/7/06
to
Hi,
dos anyone here have experiance with using libfov?
I've had some problems understanding some of it.

Thanks,
Ido.

Radomir 'The Sheep' Dopieralski

unread,
Apr 7, 2006, 5:05:27 AM4/7/06
to
At 7 Apr 2006 01:33:11 -0700,
Ido.Y...@gmail.com wrote:

> Hi,
> dos anyone here have experiance with using libfov?
> I've had some problems understanding some of it.

Could you be more specific? Which parts you have problems with?

--
Radomir `The Sheep' Dopieralski

Ido.Y...@gmail.com

unread,
Apr 7, 2006, 5:16:18 AM4/7/06
to
For instance, What are these strange "void *map" and "void *source" I
keep seeing?

As far as i understand, libfov is in c, yet it lists several of its
function as requiring parameters of the mysterios 'map data structure'
& 'source data structure' - are these structs?

Where are they defined? The example (simple.cc) seems to give libfov
instances of c++ classes... but how can a c lib accept a c++ class?

Thanks,
Ido Yehieli.

Radomir 'The Sheep' Dopieralski

unread,
Apr 7, 2006, 6:21:15 AM4/7/06
to
At 7 Apr 2006 02:16:18 -0700,
Ido.Y...@gmail.com wrote:

> For instance, What are these strange "void *map" and "void *source" I
> keep seeing?

These are generic helper pointers. They are not used by the library
itself, but instead passed as-is to the helper functions you provide.
You are supposed to define them by yourself, or just use NULL if you
don't need them.

> As far as i understand, libfov is in c, yet it lists several of its
> function as requiring parameters of the mysterios 'map data structure'
> & 'source data structure' - are these structs?

As you can see, these are void *, so they can be anything, really.
Depends on what you need.

> Where are they defined? The example (simple.cc) seems to give libfov
> instances of c++ classes... but how can a c lib accept a c++ class?

It just passes them trough, so it doesn't care what they are.

Ido.Y...@gmail.com

unread,
Apr 7, 2006, 6:32:40 AM4/7/06
to
Thanks Sheep, it all makes sense now. I will continue playing with the
example when I get back from work, I think these were the only things I
didn't understand.

> These are generic helper pointers. They are not used by the library
> itself, but instead passed as-is to the helper functions you provide.

Normally speaking these helper function will be apply & opaque, right?
Like in the example.

it really looks quite simpe to use now that I understand the purpose of
map & src - I kept searching the fov.c/fov.h files for clues as to what
they were supposed to do...

Radomir 'The Sheep' Dopieralski

unread,
Apr 7, 2006, 7:11:11 AM4/7/06
to
At 7 Apr 2006 03:32:40 -0700,
Ido.Y...@gmail.com wrote:

> Thanks Sheep, it all makes sense now. I will continue playing with the
> example when I get back from work, I think these were the only things I
> didn't understand.

Glad I could help.

>> These are generic helper pointers. They are not used by the library
>> itself, but instead passed as-is to the helper functions you provide.
>
> Normally speaking these helper function will be apply & opaque, right?
> Like in the example.

Right.

> it really looks quite simpe to use now that I understand the purpose of
> map & src - I kept searching the fov.c/fov.h files for clues as to what
> they were supposed to do...

I think libfov could use a little better documentation. Wonder if we could
do it collaboratively on rogue basin?

Ido.Y...@gmail.com

unread,
Apr 7, 2006, 8:45:21 AM4/7/06
to
> I think libfov could use a little better documentation. Wonder if we could
> do it collaboratively on rogue basin?

I think that is a good idea.

Ido.Y...@gmail.com

unread,
Apr 7, 2006, 8:56:46 AM4/7/06
to
I've added a stub at http://roguebasin.t-o-m-e.net/index.php/Libfov and
linked to it from the field of view page.
When I'll start learning more about libfov (will take at least few
days...) I could add what I've learned. I will also link to this
conversation, maybe someone will find the tip you gave me about map &
src helpfull as well.

Ido.Y...@gmail.com

unread,
Apr 7, 2006, 10:29:08 AM4/7/06
to
ok, 2 more problems I've had- this time it has to do with linking
against libfov (I'm sorry if this is really trivial, I'm quite the
beginner in c - more of a python/java person...):

i have this very minimal file:

***begin of libfov-test.cc***
#include <fov/fov.h>

int
main(){
return 0;
}
***end of libfov-test.cc***

And this makefile:
***begin of Makefile***
VPATH= src:../headers
bin-dir= bin/
libfov-libs= -L/usr/local/lib/ -lfov

all: libfov-test
libfov-test: libfov-test.o
$(CC) $(CFLAGS) -o $(bin-dir)$@ $(libfov-libs) libfov-test.o
***end of Makefile***

Now when I type make everything compiles just fine.


However, I soon encounter 2 problems:

1. if I change the file to include something from libfov, like that:

***begin of libfov-test.cc***
#include <fov/fov.h>

int
main(){
fov_settings_type settings;
fov_settings_init(&settings);
return 0;
}
***end of libfov-test.cc***

and then 'make', i get the following error:

libfov-test.o: In function `main':
libfov-test.cc:(.text+0x24): undefined reference to `fov_settings_init'
libfov-test.o:(.eh_frame+0x11): undefined reference to
`__gxx_personality_v0'
collect2: ld returned 1 exit status
make: *** [libfov-test] Error 1

I assume that probably means I'm linking incorrectly?


2. if I go back to the first way the file was and I change the name to
libfov-test.c in order to compile it as a c program rather then a c++
program, i get the following:

In file included from src/libfov-test.c:1:
/usr/local/include/fov/fov.h:68: error: syntax error before 'bool'
/usr/local/include/fov/fov.h:83: error: syntax error before '}'
token
/usr/local/include/fov/fov.h:102: error: syntax error before '*'
token
/usr/local/include/fov/fov.h:123: error: syntax error before '*'
token
/usr/local/include/fov/fov.h:150: error: syntax error before '*'
token
/usr/local/include/fov/fov.h:161: error: syntax error before '*'
token
/usr/local/include/fov/fov.h:169: error: syntax error before '*'
token
/usr/local/include/fov/fov.h:169: error: syntax error before ')'
token
/usr/local/include/fov/fov.h:177: error: syntax error before '*'
token
/usr/local/include/fov/fov.h:177: error: syntax error before ')'
token
/usr/local/include/fov/fov.h:185: error: syntax error before '*'
token
/usr/local/include/fov/fov.h:197: error: syntax error before '*'
token
/usr/local/include/fov/fov.h:218: error: syntax error before '*'
token
make: *** [libfov-test.o] Error 1

Why would it need to be compiled as a c++ program?

Thanks in advance,
Ido Yeheili

Radomir 'The Sheep' Dopieralski

unread,
Apr 7, 2006, 12:03:38 PM4/7/06
to
At 7 Apr 2006 07:29:08 -0700,
Ido.Y...@gmail.com wrote:

> ok, 2 more problems I've had- this time it has to do with linking
> against libfov (I'm sorry if this is really trivial, I'm quite the
> beginner in c - more of a python/java person...):

> i have this very minimal file:

[...]

> And this makefile:
> ***begin of Makefile***
> VPATH= src:../headers

What does this line mean? I don;t understand this syntex :/

> bin-dir= bin/
> libfov-libs= -L/usr/local/lib/ -lfov
>
> all: libfov-test
> libfov-test: libfov-test.o
> $(CC) $(CFLAGS) -o $(bin-dir)$@ $(libfov-libs) libfov-test.o
> ***end of Makefile***
>
> Now when I type make everything compiles just fine.

It doesn't use any symbols from the library, it will compile
even when you don't link the library in.

> However, I soon encounter 2 problems:

> 1. if I change the file to include something from libfov, like that:

[...]

> and then 'make', i get the following error:

> libfov-test.o: In function `main':
> libfov-test.cc:(.text+0x24): undefined reference to `fov_settings_init'
> libfov-test.o:(.eh_frame+0x11): undefined reference to
> `__gxx_personality_v0'
> collect2: ld returned 1 exit status
> make: *** [libfov-test] Error 1

> I assume that probably means I'm linking incorrectly?

Yes, but no idea what's wrong :/
Honestly, I always used libfov by compiling it into an .o file
and then linking together with the rest of my objects. Can you
make sure that the libfov file really exists in the directory
you specfied?

> 2. if I go back to the first way the file was and I change the name to
> libfov-test.c in order to compile it as a c program rather then a c++
> program, i get the following:
>
> In file included from src/libfov-test.c:1:
> /usr/local/include/fov/fov.h:68: error: syntax error before 'bool'

This must be an error. Try to add:

#define bool int

somewhere in your code, before you include the fov.h, or just include
some ready-to-use bool definition from your system. AFAIR curses
defines it.

> /usr/local/include/fov/fov.h:83: error: syntax error before '}'

[...]


> /usr/local/include/fov/fov.h:218: error: syntax error before '*'
> token
> make: *** [libfov-test.o] Error 1

These are the result of the first error.

> Why would it need to be compiled as a c++ program?

It doesn't. It seems that Puyo always used it together with curses or
other library that defines 'bool' and forgot that it isn't defined in
C by default. It's a bug, of course.

Ido.Y...@gmail.com

unread,
Apr 7, 2006, 12:34:54 PM4/7/06
to
Ok, thanks Sheep.

the VPATH= src:../headers just tells make to search for my sources in
the 'src' directory instead of at the current directory, where the
makefile is.

I've solved my first problem by myself by using libtool like was done
in the example. My new make file looks something like this:

***begin of Makefile***
CFLAGS= -Wall -std=c99 -pedantic
VPATH= src:../headers

bin-dir= bin/
libtool-path= /usr/bin/libtool
fov-libs= /usr/local/lib/libfov.la

all: ln-libtool libfov-test

libfov-test: libfov-test.o
$(shell) ./libtool --mode=link $(CC) $(CFLAGS) -o $(bin-dir)$@ $<
$(fov-libs)

ln-libtool:
$(shell) ln -f $(libtool-path)
***end of Makefile***


As for the second problem- your solution almost fixed it ;). I had to
add #include <math.h> and link against the math lib (adding -lm to the
end of fov-libs= /usr/local/lib/libfov.la) in order for libfov to be
able to use sqrt.

I am now happily able to use libfov :)

kobus...@gmail.com

unread,
Apr 9, 2006, 5:45:56 PM4/9/06
to
What I'd really like to see would be a straightforwards guide to how to
install and use libfov in Visual C++, for the Coding Impaired. I feel
like I'm really missing something fundamental.

0 new messages