Undefined reference to function in VlcQt (after installation) - c++

I recently installed VlcQt libary for ubuntu 16.04, but when I try to use it, all i get is undefined reference to 'some_function()'.
Currently I am trying to expose video player to QML.
Main.cpp
#include <QGuiApplication>
#include <VLCQtCore/Common.h>
#include <VLCQtQml/QmlVideoPlayer.h>
#include "Controller.h"
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
VlcCommon::setPluginPath(app.applicationDirPath() + "plugins");
VlcQmlVideoPlayer::registerPlugin();
Controller controller;
QQuickWindow *quickWindow = qobject_cast<QQuickWindow *>(controller.view());
quickWindow->show();
return app.exec();
}
When I am trying to include libaries, Qt intellisense is detecting that this libary exists.
What am I doing wrong?
Thank you for your help!
//Edit:
I installed it via their repository:
add-apt-repository ppa:ntadej/tano
apt-get install libvlc-qt-core2 libvlc-qt-widgets2 libvlc-qt-dbg libvlc-qt-dev
//Edit:
This is how I add libs in .pro file, already tried INCLUDEPATH too
LIBS += -lvlccore -lvlc

Related

how to add qtvirtualkeyboard to a qt widget project

I have a Qt Widget project that I created using QtCreator and Qt version 5.15.2 to which I'm trying to add the QtVirtualKeyboard as matchbox-keyboard I've already tried using stays under the application when it's in fullscreen mode.
However I'm having trouble getting it to work as it's not appearing at all at the moment. This is how I've tried adding it
Main.cpp
#include "mainwindow.h"
#include <QApplication>
#include <QtWidgets>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
MainWindow w;
//w.showFullScreen();
w.show();
return a.exec();
}
I've tried adding QT += qtvirtualkeyboard or QT += virtualkeyboard in the .pro file but it just gives me an error saying "unknown module"
How can I add the virtual keyboard to the project?
You will need to make sure that the QtVirtualKeyboard library is selected during the installation process.
Also, I would recommend you that you start using cmake for Qt applications as Qt has officially dropped qmake since the release of Qt 6.
It is not to say that you cannot use it, but you will get better support and results by using an actively developed build system rather than an abandoned.

QT 5 [ error: QtGui/QApplication: No such file or directory]

I am using Qt5. I wrote the following code:
#include <QtGui/QApplication>
#include <Qlabel>
int main(int argc, char *argv[]){
QApplication prog(argc, argv);
Qlabel *label = new Qlabel("gametime!");
label->show();
return prog.exec();
}
the following problem occurs:-
error: QtGui/QApplication: No such file or directory
QApplication is part of the Qt5 Widgets library (not the GUI library, which provides lower-level facilities).
Add QT += widgets to your .pro file, and change
#include <QtGui/QApplication>
to
#include <QtWidgets/QApplication>
(You should be able to reduce to just <QApplication>, as QMake will normally add the necessary include paths based on the libraries specified in the QT variable.)

Cmake link issue: undefined reference to QPushButton

I just started using Qt. I have a problem with compiling the first example.
main.cpp:
#include <QCoreApplication>
#include <QPushButton>
int main(int argc, char** argv)
{
QCoreApplication app(argc, argv);
QPushButton button ("Hello world !");
return app.exec();
}
CMake.txt:
cmake_minimum_required(VERSION 2.6)
project(new)
find_package(Qt4 REQUIRED)
enable_testing()
include_directories(${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR})
set(source_SRCS main.cpp)
qt4_automoc(${source_SRCS})
add_executable(new ${source_SRCS})
target_link_libraries(new${QT_QTCORE_LIBRARY})
add_subdirectory(tests)
install(TARGETS new RUNTIME DESTINATION .)
The error I get upon building is:
undefined reference to `QPushButton::QPushButton(QString const&,QWidget*)'
It is a linking problem, but how can I solve it?
Here is what I think you are missing:
find_package(Qt4 REQUIRED QtGui)
looking at your cmake you probably want to change the target_link_libraries for the following:
target_link_libraries(new ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY})
You have three problems:
You're not linking with the Gui module (Widgets module in Qt 5). This is covered in the other answer.
You you must use QApplication in widgets-based applications. Since QPushButton comes from the Gui module (Widgets in Qt5), you can't merely use QCoreApplication nor QGuiApplication: your program will crash as soon as you attempt to instantiate a QWidget.
You're not showing the button, so when your program starts you'll see nothing once you fix the above.
Your main.cpp should look like:
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
#include <QtGui>
#else
#include <QtWidgets>
#endif
int main(int argc, char** argv)
{
QApplication app(argc, argv);
QPushButton button ("Hello world !");
button.show();
return app.exec();
}
You're also going to need to link against the QtGui and QtWidgets library. Within qmake it handles which of the many libraries make up Qt, you'll have to do this by hand in cmake.
If you look at the documentation for QPushButton (http://doc.qt.io/qt-5/qpushbutton.html), the "qmake" line shows what library you need.
Consider using qmake instead of cmake with Qt.
Anyway, QCoreApplication (see docs) is the console version of main application class and will not work in GUI application. QPushButton is a widget class and can exist alone and will make a window (although you must show() it explicitely for that) but only with QApplication.
When using qmake in your *.pro file you need to include widgets like so:
CONFIG += widgets
and make sure you don't have
CONFIG -= gui
If you insist on using cmake then see here.
this answer solves my same problem :)
ok,
i had can solve it by myself.
For all they have they problem too:
The error is sourced from the use of "Q_OBJECT".
To solve the error, right-cklick on the Project and choose "Run qmake" and after >this: "Rebuild".
Then the error should be disappeared ;-)
-casisto
https://forum.qt.io/topic/52439/get-undefined-reference-error-but-don-t-know-why/2

"Using OS scope before setting MAKEFILE_GENERATOR" in Qt

I have downloaded and installed Qt and I'm learning how to use it.
So, I created a new project myfristqt (empty project). I then added a main.cpp file with this code:
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
return app.exec();
}
First thing I noticed #include <QApplication> line is hightlighted with a red line as if QApplication was an unknown identifier. So, I compiled it to see what happens and here's the error I got:
(internal):1: error : Using OS scope before setting MAKEFILE_GENERATOR
Any idea why this is happening ? I'm using Windows XP
MAKEFILE_GENERATOR is a qmake variable.
This variable contains the name of the Makefile generator to use when generating a Makefile. The value of this variable is typically handled internally by qmake and rarely needs to be modified.
It define in QTDIR/mkspecs/PLATFORM/qmake.conf. Where PLATFORM is maybe cygwin-g++, win32-msvc200x on your Windows XP.

Missing File application.h in gtkmm-3.0 on Ubuntu 11.10

I'm currently trying to compile some code examples from
http://developer.gnome.org/gtkmm-tutorial/unstable/sec-treeview-examples.html.en
but from what I can see Ubuntu 11.10 gtkmm-3.0 is missing the file
/usr/include/gtkmm-3.0/gtkmm/application.h
and I can't find it anywhere else:
apt-file search "gtkmm/application.h"
returns nothing.
Even more strange, Application is not referenced anywhere under /usr/include/gtkmm-3.0/gtkmm.
Here's the main function
#include "../examplewindow.hpp"
#include <gtkmm/application.h>
int main(int argc, char *argv[])
{
Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
ExampleWindow window;
return app->run(window);
}
Have I missed something? Has the API changed recently?
After reading the good answers:
For now, with gtkmm 3.2, I use
#include "../examplewindow.hpp"
int main(int argc, char *argv[])
{
Gtk::Main kit(argc, argv);
ExampleWindow window;
Gtk::Main::run(window);
}
instead. What do I gain by using the 3.4 Application Interface instead?
According to the Gtk::Application documentation, it only exists on gtkmm 3.4+.
You can check the installed version of the package with:
pkg-config --modversion gtkmm-3.0
There was some issues wrapping GtkApplication for gtkmm 3.0 and 3.2. It's now in the 3.3.x development sources, but was recently considered "not ready". I assume it will be in good shape when 3.4 is released.