mesonbuild / meson

The Meson Build System
http://mesonbuild.com
Apache License 2.0
5.64k stars 1.64k forks source link

Create Vala & C++ project #476

Open ghost opened 8 years ago

ghost commented 8 years ago

I can't create this type of project due to errors :

meson.build : http://pastebin.com/AWtjPUF6 build log : http://pastebin.com/NWu9g3ks

jpakkane commented 8 years ago

The log is clipped but there is this:

error: Package `taglib' not found in specified Vala API directories or GObject-Introspection GIR directories

and

In file included from ../src/giofilestream.cpp:1:0:
../src/giofilestream.h:4:25: fatal error: taglib-glib.h: Aucun fichier ou dossier de ce type

This seems to indicate some sort of problem in the dependencies rather than with Vala/C++ mixing.

ghost commented 8 years ago

taglib doesn't exist in vala (only c binding) your system checks dependencies for each language : vala doesn't have vapi for C++ libraries ;)

jpakkane commented 8 years ago

Is the problem here that Meson passes --pkg-taglib to valac and would it start working if those were removed?

ghost commented 8 years ago

taglib is a C++ library, we can't use this type of lib in vala world. We have to write C binding.

btw, I've found an hack : create a fake 'taglib' vapi. but I can't override options and meson add his own options :/

FAILED: valac '-d' 'src/taglib-glib@sha' '-C' '-H' 'src/File.h' '--library=taglib-glib' '--vapi=../File.vapi' '--pkg' 'taglib' '--pkg' 'gio-2.0' '--pkg' 'gee-0.8' '-H' 'taglib-glib.h' '--vapidir' 'vapi' ../src/File.vala ../src/Tag.vala ../src/Picture.vala ../src/AudioProperties.vala ../src/RemoteFileStream.vala

meson ignore custom vapidir

jpakkane commented 8 years ago

If this is an existing project can you post the compiler invocations that the current build system does?

ghost commented 8 years ago
[3/9] Compiling Vala source ../src/File.vala ../src/Tag.vala ../src/Picture.vala ../src/AudioProperties.vala ../src/RemoteFileStream.vala.
FAILED: valac '-d' 'src/taglib-glib@sha' '-C' '-H' 'src/File.h' '--library=taglib-glib' '--vapi=../File.vapi' '--pkg' 'taglib' '--pkg' 'gio-2.0' '--pkg' 'gee-0.8' '--vapi' 'taglib-glib.vapi' '-H' 'taglib-glib.h' '--vapidir' 'vapi' ../src/File.vala ../src/Tag.vala ../src/Picture.vala ../src/AudioProperties.vala ../src/RemoteFileStream.vala
error: Package `taglib' not found in specified Vala API directories or GObject-Introspection GIR directories
Compilation failed: 1 error(s), 0 warning(s)

but the normal way to compile vala library is :

valac --library my-lib -H lib.h file.vala file2.vala --vapidir=path/to/vapis

add -C option to generate C files

with meson custom options are ignored

jpakkane commented 8 years ago

If you edit build.ninja and remove --pkg taglib from this compiler invocation, does it pass?

ghost commented 8 years ago

no because C step comes before vala step

[3/9] Compiling cpp object 'src/taglib-glib@sha/functions.cpp.o'
FAILED: c++  '-pipe' '-Wall' '-Winvalid-pch' '-Wnon-virtual-dtor' '-g' '-fPIC' '-I/usr/local/include/taglib' '-pthread' '-I/usr/include/glib-2.0' '-I/usr/lib/x86_64-linux-gnu/glib-2.0/include' '-I/usr/include/gee-0.8' '-I/usr/include/glib-2.0' '-I/usr/lib/x86_64-linux-gnu/glib-2.0/include' '-Isrc/taglib-glib@sha' '-I../src' '-Isrc' '-MMD' '-MQ' 'src/taglib-glib@sha/functions.cpp.o' '-MF' 'src/taglib-glib@sha/functions.cpp.o.d' -o 'src/taglib-glib@sha/functions.cpp.o' -c ../src/functions.cpp
In file included from ../src/functions.cpp:42:0:
../src/giofilestream.h:4:25: fatal error: taglib-glib.h: Aucun fichier ou dossier de ce type
compilation terminated.
[3/9] Compiling Vala source ../src/File.vala ../src/Tag.vala ../src/Picture.vala ../src/AudioProperties.vala ../src/RemoteFileStream.vala.
ssssam commented 8 years ago

One workaround for this is to put the Vala code in a separate, static library. Then link the C++ library to it. That way you can put taglib as a dependency of the C++ library but not the Vala library.