I'm trying to use a the gstreamer framework in my node addon. I had the following to my to my binding.gyp, but when i run the build command it, the console states that the header is not found. When i compile my gstreamer files outside of node-gyp, it compiles successfully. Does anyone see something wrong with my binding file ?
console
hello.cc3:25: fatal error: gstreamermm.h: No such file or directory
binding.gyp
{
"targets": [
{
"target_name": "addon",
"libraries": [
"-lgstreamer-1.0", "-L/usr/inlcude/gstreamer-1.0/gst/"
],
"sources": [ "hello.cc" ]
}
]
}
compile command that works correctly, and that I'm trying to run
g++ main.c -o main `pkg-config --cflags --libs gstreamer-1.0`
Yes:
The
"libraries"
element, inbinding.gyp
should include the libraries, specified in-l
or absolute filename form, that you want to link.-lgstreamer-1.0
is one of those.-L/usr/inlcude/gstreamer-1.0/gst/
is not. It is a linker option that will instruct the linker to search for libraries specified in-l
form in the directory/usr/include/gstreamer-1.0/gst/
.That is specifying a library search directory, so if it were needed, you should say so in the
"library_dirs"
element:But you don't need it, because there are no libraries in
/usr/inlcude/gstreamer-1.0/gst/
. All the files under/usr/include
are C or C++ header files, not libraries. Libraries are installed under/lib
,/usr/lib
or/usr/local/lib
.You say you can successfully compile a program with:
That works because as you may know,
outputs the compiler and linker options needed to build a target that depends on
gstreamer-1.0
Let's have a look:
Then let's use that information to write
binding.gyp
. (On your system it might differ from mine):binding.gyp
(Have we forgotten the
-pthread
option emitted bypkg-config
? No.node-gyp
passes it the compiler and linker by default)With this
binding.gyp
, your build should look something like mine:Note furthermore,
pkg-config
tells you that the correct compiler include-path to locate gstreamer-1.0 header files is:not:
And we have followed that advice in our
binding.gyp
. Therefore in your source code you will write, e.g.and not:
Later
Now your compiler cannot locate
<gst/gstconfig.h>
One possible cause is that you didn't faithfully copy the necessary include-directories reported for your system by:
into the
include_dirs
list of yourbinding-gyp
. Possibly you just copied the ones from my example. My example, giving directories:was run on Ubuntu 17.04, in which
gst/gstconfig.h
is in fact installed in/usr/include/gstreamer-1.0
. But on Ubuntu 16.04, for example:-we get the additional include directory:
and
gst/gstconfig.h
is indeed installed there. Check that you are using the correct include directories thatpkg-config
reports on your system and correct yourbinding.gyp
if necessary.If you were using the correct
pkg-config
results, then it would appear that yourgstreamer-1.0
dev package has a defectivegstreamer-1.0.pc
file providing incorrectpkg-config
info. To work around that, ask your distro's package manager to show you where the dev package really installedgst/gstconfig.h
. E.g. for Ubuntu 16.04:Then add the required path prefix (e.g.
/usr/lib/x86_64-linux-gnu/gstreamer-1.0/include
) to theinclude_dirs
of yourbinding.gyp
.