Re: [Vala] Header file not found ?!?



Hello,

In fact, I've the same problem as :
http://www.perlmonks.org/?node_id=896237

$ valac --pkg libpcap -X -I/opt/include test.vala
test.vala.c: In function 'main':
test.vala.c:29:2: warning: 'g_type_init' is deprecated (declared at
C:\TEMP\cccVFFzy.o:test.vala.c:(.text+0x47): undefined reference to
`pcap_lib_version'
collect2: ld returned 1 exit status
error: cc exited with status 1
Compilation failed: 1 error(s), 0 warning(s)

I will try the fix explained in the web page.

Regards,

Raum

On Fri, 2013-09-20 at 15:49 +0200, raum no-log org wrote:
Hello,

I'm trying to output "pcap version" in mingw32 environnement. I've
installed libpcap.vapi, libpcap.deps (from
https://github.com/apmasell/vapis) and all header and lib files from
WpdPack.zip (WinPcap developper kit).

I found in my /opt/include folder :
pcap.h
pcap/pcap.h
...

CPPFLAGS=-I/opt/include

This isn't likely to have much effect?Vala uses C, not C++.  You may
have better luck with CFLAGS.  AFAIK Vala doesn't use the CFLAGS
environment variable, though, so if that's what you're hoping will pick
it up I think you're out of luck.

If you want to get valac to pass specific C flags to the C compiler, use
-X (valac -X -I/opt/include ...).

C_LIBRARY_PATH=/usr/include:/mingw/include:/opt/include

simple vala code test_pcap.vala :
---------------------
void main() {
     stdout.printf ("%s\n", PCap.get_version());

}
---------------------

Command to compile test code :
$ valac --pkg gio-2.0 --pkg libpcap  test_pcap.vala
d:/test_pcap.vala.c:8:23: fatal error: pcap/pcap.h: No such file or
directory
compilation terminated.
error: cc exited with status 1
Compilation failed: 1 error(s), 0 warning(s)
$

Do you have an advice ? I don't understand why valac didn't find a file
which is obviously present in /opt/include/pcap/ folder ?

It's actually not valac which doesn't find the header file, it's the C
compiler.  You can always just tell valac to compile to C but not
compile the C itself (using the -C flag), then invoke your C compiler
manually.  Once you figure out the right flags, you can pass them to
valac with -X.  You can also see what flags valac is passing to the C
compiler with something like `valac --cc=echo --pkg gio-2.0 --pkg
libpcap test_pcap.vala`.


-Evan




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]