AD-Vega / qarv

A Qt-based GUI and library interface for ethernet cameras using the Aravis library.
GNU General Public License v3.0
20 stars 14 forks source link

Problems with glib files #18

Closed FCollaPi closed 4 years ago

FCollaPi commented 4 years ago

I started a Qt project from scratch so I could test the API. Right at the first build time, compiler said it couldn't find gio/gio.h. After researching a little, I found out this is related to glib headers, so I included its paths on the .pro file:

INCLUDEPATH += "/usr/include/glib-2.0/" INCLUDEPATH += "/usr/lib/x86_64-linux-gnu/glib-2.0/include"

Now the compiler is accusing the following errors in gdbusintrospection.h:

/usr/include/glib-2.0/gio/gdbusintrospection.h:155: error: expected unqualified-id before ‘public’ GDBusSignalInfo signals; ^ /usr/include/glib-2.0/gio/gdbusintrospection.h:155: error: expected ‘;’ at end of member declaration GDBusSignalInfo signals; ^ /usr/include/glib-2.0/gio/gdbusintrospection.h:155: error: expected ‘:’ before ‘;’ token GDBusSignalInfo **signals; ^

I'm using Qt 5.9.5 at Ubuntu 18.04.

exzombie commented 4 years ago

Ugh, I have forgotten how much hassle it is installing *-dev packages on Ubuntu :unamused: . But I got QArv built on 18.04 with no further issues. Changing INCLUDEPATH should not be necessary, and doing so (as you've shown) messes up the order if includes, causing conflicts with glib's and Qt's use of the word signal.

Are you sure that gio/gio.h is present on your system? The entire path is /usr/include/glib-2.0/gio/gio.h. Also, if QArv has trouble finding gio, where did you obtain Aravis? Aravis too needs gio to compile.

FCollaPi commented 4 years ago

I really have forgotten installing Aravis. Does it need a global install or can I just use make under the project folder?

exzombie commented 4 years ago

If you don't want to install Aravis to /usr/local as is the default, you can install it to any prefix, but you will then need to set PKG_CONFIG_PATH properly when running cmake for QArv. And possibly LD_LIBRARY_PATH when you run QArv.

For testing in my Kubuntu VM, I installed Aravis to /usr/local and had no further issues. Just don't use the latest release because it needs meson to build, and the one in 18.04 is too old. I used the latest release in the 0.5 series. Browsing the camera features will probably be slow because only the latest Aravis implements proper value caching, but you will need to update the distro for that.

EmmanuelP commented 4 years ago

Hi,

Just don't use the latest release because it needs meson to build,

I have not tried by myself, but you may probably use pip in order to get the latest release of meson:

pip3 install --user meson

I used the latest release in the 0.5 series.

I guess you meant the latest release in the 0.6 series.

exzombie commented 4 years ago

I used the latest release in the 0.5 series.

I guess you meant the latest release in the 0.6 series.

No, I did use 0.5. I thought that 0.6 requires meson as well, but didn't bother to check because I was running out of time, so I went for the one I knew will work. (I rarely build Aravis myself, only when I need to hack on it, I use packages otherwise)

But if meson is that easy to upgrade, it is definitely better to go for the latest Aravis.

EmmanuelP commented 4 years ago

No, I did use 0.5. I thought that 0.6 requires meson as well, but didn't bother to check because I was running out of time, so I went for the one I knew will work. (I rarely build Aravis myself, only when I need to hack on it, I use packages otherwise)

0.6.x is the latest stable series of aravis. There should be no API or ABI break between each release, which is not the case between unstable releases. 0.6.x releases still rely on autotools.

robotaiguy commented 4 years ago

I'm having the same problem @FCollaPi , @EmmanuelP , @exzombie , @alajovic and . I am also building a QT project from scratch, trying to utilize the API. I get the same errors for gdbusintrospection.h as FCollaPi.

If I use the prebuilt QArv project, it runs fine. However, when I followed the main() build suggestion in qarvgui.h, I get those errors. It seems that the gio/gio.h workaround isn't working.

I added PKGCONFIG += aravis-0.6 to my .pro file, and included the qarv-3 library and include paths. I am using aravis-0.6 stable release, so was able to install it with just ./configure then make then make install

exzombie commented 4 years ago

O dear, thanks for reminding me of this issue! I finally sat down and built a test app using qmake for the first time; I only ever used cmake for QArv apps. Here's what worked for me:

CONFIG += c++14 link_pkgconfig
QT += widgets network
PKGCONFIG += qarv-3 glib-2.0 opencv4

SOURCES = src/main.cpp

The test main.cpp was a copy of the one in QArv. Note the link_pkgconfig option, turns out it's important ☺ . Please confirm it works for you, @robotwhispering and @FCollaPi , then I'll add it to the documentation.

robotaiguy commented 4 years ago

@exzombie I already had link_pkgconfig set up. However, I was using the default c++11 settings. After I changed to 14, that error, and others, went away. I'm a bit embarrassed that I didn't see that already.

exzombie commented 4 years ago

Are you sure? Because it works for me if I remove c++14 (main.cpp doesn't use any of those features), but it doesn't work without link_pkgconfig, saying it cannot find gio/gio.h :thinking: . I'd like to have this cleared up so that I don't post useless instructions. For the record, I have gcc version 9.3.0.

robotaiguy commented 4 years ago

@exzombie I cannot be certain which change I made that actually resolved the issue. I got angry with my code, deleted everything, and started over from scratch again. I formed it like you suggested, so you're probably correct. I probably did not have the pkg linked correctly.

Here is my pro file (although, now I'm getting different errors related to "multiple definition of 'qt_plugin_query_metadata" in the moc_decoded files, and "undefined reference to "qt_static_plugin_xxxxxxxx" in the bayer.cpp file. But i should probably form this in a separate question to you, unless you might be able to reach out to me about it. If you see something that jumps out at you, can you email me at robotwhisperer@engineer.com please or message me directly through github?

QMAKE_PROJECT_NAME = "Detector"

VERSION = 1 DEFINES += VERSION_NUM=\\"$${VERSION}\\"

QT += core gui widgets network svg concurrent

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++14 link_pkgconfig

PKGCONFIG += qarv-3 glib-2.0 opencv aravis-0.6 gio-2.0 libswscale libavcodec libavutil

SOURCES += \ src/Calib.cpp \ src/DarkHelp.cpp \ src/Yolo.cpp \ src/api/globals.cpp \ src/api/qarvcamera.cpp \ src/api/qarvcameradelegate.cpp \ src/api/qarvdecoder.cpp \ src/api/qarvfeaturetree.cpp \ src/api/qarvgui.cpp \ src/api/qarvrecordedvideo.cpp \ src/api/qarvtype.cpp \ src/decoders/bayer.cpp \ src/decoders/graymap.cpp \ src/decoders/mono12packed.cpp \ src/decoders/monounpackeddecoders.cpp \ src/decoders/swscaledecoder.cpp \ src/filters/filter.cpp \ src/filters/levels.cpp \ src/glvideowidget.cpp \ src/main.cpp \ src/mainwindow.cpp \ src/recorders/gstrecorder_implementation.cpp \ src/recorders/gstrecorders.cpp \ src/recorders/imagerecorder.cpp \ src/recorders/rawrecorders.cpp \ src/recorders/recorder.cpp \ src/workthread.cpp

HEADERS += \ src/Calib.hpp \ src/DarkHelp.hpp \ src/Yolo.hpp \ src/api/globals.h \ src/api/qarvcamera.h \ src/api/qarvcameradelegate.h \ src/api/qarvdecoder.h \ src/api/qarvfeaturetree.h \ src/api/qarvgui.h \ src/api/qarvrecordedvideo.h \ src/api/qarvtype.h \ src/decoders/bayer.h \ src/decoders/bayer/BayerBG10.h \ src/decoders/bayer/BayerBG12.h \ src/decoders/bayer/BayerBG12_PACKED.h \ src/decoders/bayer/BayerBG16.h \ src/decoders/bayer/BayerBG8.h \ src/decoders/bayer/BayerGB10.h \ src/decoders/bayer/BayerGB12.h \ src/decoders/bayer/BayerGB12_PACKED.h \ src/decoders/bayer/BayerGB16.h \ src/decoders/bayer/BayerGB8.h \ src/decoders/bayer/BayerGR10.h \ src/decoders/bayer/BayerGR12.h \ src/decoders/bayer/BayerGR12_PACKED.h \ src/decoders/bayer/BayerGR16.h \ src/decoders/bayer/BayerGR8.h \ src/decoders/bayer/BayerRG10.h \ src/decoders/bayer/BayerRG12.h \ src/decoders/bayer/BayerRG12_PACKED.h \ src/decoders/bayer/BayerRG16.h \ src/decoders/bayer/BayerRG8.h \ src/decoders/bayer/decoder.h \ src/decoders/graymap.h \ src/decoders/mono12packed.h \ src/decoders/monounpacked.h \ src/decoders/monounpackeddecoders.h \ src/decoders/monounpackeddecoders/Mono10Format.h \ src/decoders/monounpackeddecoders/Mono12Format.h \ src/decoders/monounpackeddecoders/Mono14Format.h \ src/decoders/monounpackeddecoders/Mono16Format.h \ src/decoders/monounpackeddecoders/Mono8Format.h \ src/decoders/monounpackeddecoders/Mono8SignedFormat.h \ src/decoders/swscaledecoder.h \ src/decoders/unsupported.h \ src/filters/filter.h \ src/filters/levels.h \ src/getmtu_linux.h \ src/glvideowidget.h \ src/mainwindow.h \ src/recorders/gstrecorder_implementation.h \ src/recorders/gstrecorders.h \ src/recorders/imagerecorder.h \ src/recorders/rawrecorders.h \ src/recorders/rawrecorders/decoded16.h \ src/recorders/rawrecorders/decoded8.h \ src/recorders/rawrecorders/undecoded.h \ src/recorders/recorder.h \ src/workthread.h

FORMS += \ src/filters/levels.ui \ src/mainwindow.ui \

Default rules for deployment.

qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target

unix:!macx: LIBS += -L/usr/local/lib/ -lGevApi -ldarknet \ -L/usr/lib/x86_64-linux-gnu/ -lavutil -lavcodec -lswscale

INCLUDEPATH += $$PWD/src \ /usr/local/include/GigeV/include \ /opt/genicam_v3_0/library/CPP/include \ /usr/local/include \ /usr/include/x86_64-linux-gnu

DEPENDPATH += $$PWD/src \ $$PWD/src/decoders \ /usr/local/include/GigeV/include \ /opt/genicam_v3_0/library/CPP/include \ /usr/local/include

exzombie commented 4 years ago

OK, now I get it. You're trying to compile QArv itself with qmake, as part of compiling your own application. That's something I've never tried, and I don't know of anyone who did. The intended way to use QArv is to compile it on its own, install it with make install and then use it as a library by linking to it from your application, e.g. with qmake by declaring PKGCONFIG += qarv-3.

The issue of multiple definitions you have is because you are trying to do both: you first build QArv, and then link to the already installed QArv. So of course there would be multiple definitions of everything.

The best way to proceed is to use QArv the same way you use Aravis (or any other library): install it, then link against it. See my post above, that's literally all you need to get started; there is no need to have a complete copy of QArv in your project. How to proceed from there depends on which functionality of QArv you would like to use. I can provide advice, but it's out of scope of this issue, so we should discuss it over email.