Not able to debug shared dylib in mac os - c++

i'm using ffmpeg (open source) compiled dylib in macos for my project. But not able to debug ffmpeg dll's src using lldb.
configure \
--prefix=$_outAbsPathDebug \
--extra-cflags="-I${_x264AbsPathDebug}/include" \
--extra-ldflags="-L${_x264AbsPathDebug}/lib" \
--enable-debug \
--disable-optimizations \
--enable-shared \
--enable-static \
--disable-ffplay \
--enable-ffprobe \
--enable-ffmpeg \
--enable-gpl \
--enable-libx264 \
--enable-avresample
compiling sample
g++ \
-std=c++17 \
-D__STDC_CONSTANT_MACROS \
-Wno-deprecated \
-o "sampleffmpeg" \
-I"./../../../../../../mod/out/FFmpeg/mac/debug/config/" \
-I"./../../../../../../mod/src/FFmpeg/" \
-I"./../../../../../../mod/src/FFmpeg/compat/atomics/mac32/" \
-g \
"sampleffmpeg.cpp" \
-L"./" \
-lavcodec \
-lavdevice \
-lavfilter \
-lavformat \
-lavutil \
-lpostproc \
-lswresample \
-lswscale
sampleffmpeg.cpp
#include <iostream>
extern "C" {
#include <libavformat/avformat.h>
#include <libavutil/imgutils.h>
#include <libswscale/swscale.h>
}
int main() {
// Register all codecs and formats
av_register_all();
return 0;
}
lldb not able to step in av_register_all
Process 5392 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x0000000100003f98 sampleffmpeg`main at sampleffmpeg.cpp:10:5
7
8 int main() {
9 // Register all codecs and formats
-> 10 av_register_all();
11
12 return 0;
13 }
Target 0: (sampleffmpeg) stopped.
(lldb) s
Process 5392 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = step in
frame #0: 0x0000000100003fa0 sampleffmpeg`main at sampleffmpeg.cpp:12:5
9 // Register all codecs and formats
10 av_register_all();
11
-> 12 return 0;
13 }
Target 0: (sampleffmpeg) stopped.

Related

ffmpeg undefined reference to sws_getContext

I am learning to use ffmpeg libraries, and have successfully compiled and run a program that demuxes and decodes a video. However, when I was trying to use the swscale library, I got a linking error "undefined reference to sws_getContext". There are similar problems on the Internet but none of them solves my problem.
The full error message is
/usr/bin/ld: CMakeFiles/ffmpeg_test.dir/main.cpp.o: in function `main':
main.cpp:(.text+0x44f): undefined reference to `sws_getContext'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/ffmpeg_test.dir/build.make:93: ffmpeg_test] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/ffmpeg_test.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
Here is my Dockerfile, source file and CMakeList.
# FFMPEG Image
# ref:https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu
FROM ubuntu:20.04
ARG http_proxy=''
ARG https_proxy=''
ENV HTTP_PROXY=${http_proxy}
ENV HTTPS_PROXY=${https_proxy}
RUN apt-get update \
&& DEBIAN_FRONTEND="noninteractive" \
apt-get install -y --no-install-recommends \
autoconf \
automake \
build-essential \
cmake \
git \
libass-dev \
libfreetype6-dev \
libgnutls28-dev \
# libsdl2-dev \
libtool \
# libva-dev \
# libvdpau-dev \
libvorbis-dev \
# libxcb1-dev \
# libxcb-shm0-dev \
# libxcb-xfixes0-dev \
meson \
ninja-build \
pkg-config \
texinfo \
wget \
yasm \
zlib1g-dev \
libunistring-dev \
python3.8-dev \
ca-certificates
ARG FFMPEG_ROOT=/root/ffmpeg
RUN mkdir ${FFMPEG_ROOT}
WORKDIR ${FFMPEG_ROOT}
RUN mkdir sources && mkdir build && mkdir bin
# NASM
RUN cd sources \
&& wget https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/nasm-2.15.05.tar.bz2 \
&& tar xjvf nasm-2.15.05.tar.bz2 \
&& cd nasm-2.15.05 \
&& ./autogen.sh \
&& PATH="${FFMPEG_ROOT}/bin:$PATH" \
./configure \
--prefix="${FFMPEG_ROOT}/build" \
--bindir="${FFMPEG_ROOT}/bin" \
--enable-shared \
--enable-pic \
&& make -j$(nproc) \
&& make install
# H.264 video encoder (GPL License!!! --enable-gpl --enable-libx264)
RUN cd sources \
&& git -C x264 pull 2> /dev/null || git clone --depth 1 https://code.videolan.org/videolan/x264.git \
&& cd x264 \
&& PATH="${FFMPEG_ROOT}/bin:$PATH" \
PKG_CONFIG_PATH="${FFMPEG_ROOT}/build/lib/pkgconfig" \
./configure \
--prefix="${FFMPEG_ROOT}/build" \
--bindir="${FFMPEG_ROOT}/bin" \
--enable-shared \
--enable-pic \
--disable-cli \
&& PATH="${FFMPEG_ROOT}/bin:$PATH" make -j$(nproc) \
&& make install
# H.265/HEVC video encoder (GPL License!!! --enable-gpl --enable-libx265)
RUN apt-get install -y --no-install-recommends libnuma-dev \
&& cd sources \
&& git -C x265_git pull 2> /dev/null || git clone https://bitbucket.org/multicoreware/x265_git \
&& cd x265_git/build/linux \
&& PATH="${FFMPEG_ROOT}/bin:$PATH" \
cmake \
-G "Unix Makefiles" \
-DCMAKE_INSTALL_PREFIX="${FFMPEG_ROOT}/build" \
-DENABLE_SHARED=on \
-DENABLE_CLI=off \
../../source \
&& PATH="${FFMPEG_ROOT}/bin:$PATH" make -j$(nproc) \
&& make install
# VP8/VP9 video encoder/decoder (--enable-libvpx)
RUN cd sources \
&& git -C libvpx pull 2> /dev/null || git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git \
&& cd libvpx \
&& PATH="${FFMPEG_ROOT}/bin:$PATH" \
./configure \
--prefix="${FFMPEG_ROOT}/build" \
--disable-debug \
--disable-examples \
--disable-docs \
--disable-unit-tests \
--enable-vp9-highbitdepth \
--as=yasm \
--enable-pic \
--enable-shared \
&& PATH="${FFMPEG_ROOT}/bin:$PATH" make -j$(nproc) \
&& make install
# # AAC audio encoder (NON-FREE!!! --enable-gpl --enable-nonfree --enable-libfdk-aac)
# RUN cd sources \
# && git -C fdk-aac pull 2> /dev/null || git clone --depth 1 https://github.com/mstorsjo/fdk-aac \
# && cd fdk-aac \
# && autoreconf -fiv \
# && ./configure \
# --prefix="${FFMPEG_ROOT}/build" \
# --disable-shared \
# && make -j$(nproc) \
# && make install
# MP3 audio encoder (--enable-libmp3lame)
RUN cd sources \
&& wget -O lame-3.100.tar.gz https://downloads.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz \
&& tar xzvf lame-3.100.tar.gz \
&& cd lame-3.100 \
&& PATH="${FFMPEG_ROOT}/bin:$PATH" \
./configure \
--prefix="${FFMPEG_ROOT}/build" \
--bindir="${FFMPEG_ROOT}/bin" \
--enable-shared \
--enable-pic \
--enable-nasm \
&& PATH="${FFMPEG_ROOT}/bin:$PATH" make -j$(nproc) \
&& make install
# Opus audio decoder and encoder (--enable-libopus)
RUN cd sources \
&& git -C opus pull 2> /dev/null || git clone --depth 1 https://github.com/xiph/opus.git \
&& cd opus \
&& ./autogen.sh \
&& ./configure \
--prefix="${FFMPEG_ROOT}/build" \
--enable-shared \
&& make -j$(nproc) \
&& make install
# AV1 video encoder/decoder
# encoder (--enable-libsvtav1)
RUN cd sources \
&& git -C SVT-AV1 pull 2> /dev/null || git clone https://gitlab.com/AOMediaCodec/SVT-AV1.git \
&& mkdir -p SVT-AV1/build \
&& cd SVT-AV1/build \
&& PATH="${FFMPEG_ROOT}/bin:$PATH" \
cmake \
-G "Unix Makefiles" \
-DCMAKE_INSTALL_PREFIX="${FFMPEG_ROOT}/build" \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_DEC=OFF \
-DBUILD_SHARED_LIBS=ON \
.. \
&& PATH="${FFMPEG_ROOT}/bin:$PATH" make -j$(nproc)\
&& make install
# decoder (--enable-libdav1d)
RUN cd sources \
&& git -C dav1d pull 2> /dev/null || git clone --depth 1 https://code.videolan.org/videolan/dav1d.git \
&& mkdir -p dav1d/build \
&& cd dav1d/build \
&& PATH="${FFMPEG_ROOT}/bin:$PATH" \
meson setup \
-Denable_tools=false \
-Denable_tests=false \
--default-library=shared \
.. \
--prefix="${FFMPEG_ROOT}/build" \
--libdir="${FFMPEG_ROOT}/build/lib" \
&& ninja -j$(nproc) \
&& ninja install
# Library for calculating the ​VMAF video quality metric (--enable-libvmaf --ld="g++")
RUN cd sources \
&& wget https://github.com/Netflix/vmaf/archive/v2.1.1.tar.gz \
&& tar xvf v2.1.1.tar.gz \
&& mkdir -p vmaf-2.1.1/libvmaf/build \
&& cd vmaf-2.1.1/libvmaf/build \
&& PATH="${FFMPEG_ROOT}/bin:$PATH" \
meson setup \
-Denable_tests=false \
-Denable_docs=false \
--buildtype=release \
--default-library=shared \
.. \
--prefix "${FFMPEG_ROOT}/build" \
--bindir="${FFMPEG_ROOT}/build/bin" \
--libdir="${FFMPEG_ROOT}/build/lib" \
&& ninja -j$(nproc) \
&& ninja install
# FFMPEG
RUN cd sources \
&& wget -O ffmpeg-snapshot.tar.bz2 https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 \
&& tar xjvf ffmpeg-snapshot.tar.bz2 \
&& cd ffmpeg \
&& PATH="${FFMPEG_ROOT}/bin:$PATH" \
PKG_CONFIG_PATH="${FFMPEG_ROOT}/build/lib/pkgconfig" \
./configure \
--prefix="${FFMPEG_ROOT}/build" \
--pkg-config-flags="--static" \
--extra-cflags="-I${FFMPEG_ROOT}/build/include" \
--extra-ldflags="-L${FFMPEG_ROOT}/build/lib" \
--extra-libs="-lpthread -lm" \
--ld="g++" \
--bindir="${FFMPEG_ROOT}/bin" \
--disable-debug \
--disable-doc \
--disable-ffplay \
--enable-shared \
--enable-pic \
--enable-gpl \
--enable-gnutls \
# --enable-libaom \
--enable-libass \
# --enable-libfdk-aac \
--enable-libfreetype \
--enable-libmp3lame \
--enable-libopus \
--enable-libsvtav1 \
--enable-libdav1d \
--enable-libvorbis \
--enable-libvpx \
--enable-libx264 \
--enable-libx265 \
# --enable-nonfree \
&& PATH="${FFMPEG_ROOT}/bin:$PATH" make -j$(nproc) \
&& make install \
&& hash -r
# opencv
RUN apt-get update \
& apt-get install -y --no-install-recommends libopencv-dev
#include <iostream>
extern "C" {
#include <libavutil/avutil.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
}
#include <opencv2/core.hpp>
// fix c++ av_err2str problem
// ref: https://github.com/joncampbell123/composite-video-simulator/issues/5
#ifdef av_err2str
#undef av_err2str
#include <string>
av_always_inline std::string av_err2string(int errnum) {
char str[AV_ERROR_MAX_STRING_SIZE];
return av_make_error_string(str, AV_ERROR_MAX_STRING_SIZE, errnum);
}
#define av_err2str(err) av_err2string(err).c_str()
#endif // av_err2str
static int decode_packet(AVPacket *, AVCodecContext *, AVFrame *, AVStream *);
int main(int argc, const char *argv[]) {
std::cout << "hello world" << std::endl;
AVFormatContext *pFormatContext = avformat_alloc_context();
if (avformat_open_input(&pFormatContext, argv[1], NULL, NULL) != 0) {
std::cout << "ERROR could not open the file\n";
return -1;
}
printf("File format %s, duration %.2fs, bit_rate %ld\n", pFormatContext->iformat->long_name, pFormatContext->duration / 1e6, pFormatContext->bit_rate);
if (avformat_find_stream_info(pFormatContext, NULL) < 0) {
std::cout << "ERROR could not get the stream info\n";
return -1;
}
int video_stream_index = -1;
printf("Number of streams %d\n", pFormatContext->nb_streams);
AVCodecParameters *pVideoCodecParameters;
const AVCodec *pVideoCodec;
AVStream *pVideoStream;
for (int i = 0; i < pFormatContext->nb_streams; i++)
{
AVCodecParameters *pLocalCodecParameters = pFormatContext->streams[i]->codecpar;
const AVCodec *pLocalCodec = NULL;
pLocalCodec = avcodec_find_decoder(pLocalCodecParameters->codec_id);
// print its name and bitrate
printf("Codec %s, bit_rate %ld\n", pLocalCodec->long_name, pLocalCodecParameters->bit_rate);
if (pLocalCodecParameters->codec_type == AVMEDIA_TYPE_VIDEO) {
if (video_stream_index == -1) {
video_stream_index = i;
pVideoCodecParameters = pLocalCodecParameters;
pVideoCodec = pLocalCodec;
}
pVideoStream = pFormatContext->streams[i];
AVRational *fps = &pVideoStream->avg_frame_rate;
AVRational *rfps = &pVideoStream->r_frame_rate;
AVRational *time_base = &pVideoStream->time_base;
printf("Video Codec: resolution %d x %d, fps %d/%d, frames %ld, time base %d/%d, rfps %d/%d\n",
pLocalCodecParameters->width, pLocalCodecParameters->height,
fps->num, fps->den, pVideoStream->nb_frames, time_base->num, time_base->den,
rfps->num, rfps->den);
} else if (pLocalCodecParameters->codec_type == AVMEDIA_TYPE_AUDIO) {
printf("Audio Codec: %d channels, sample rate %d\n", pLocalCodecParameters->channels, pLocalCodecParameters->sample_rate);
}
if (pLocalCodec==NULL) {
printf("ERROR unsupported codec!\n");
// In this example if the codec is not found we just skip it
continue;
}
}
if (video_stream_index == -1) {
printf("File %s does not contain a video stream!\n", argv[1]);
return -1;
}
AVCodecContext *pCodecContext = avcodec_alloc_context3(pVideoCodec);
if (!pCodecContext)
{
printf("failed to allocated memory for AVCodecContext\n");
return -1;
}
if (avcodec_parameters_to_context(pCodecContext, pVideoCodecParameters) < 0)
{
printf("failed to copy codec params to codec context\n");
return -1;
}
if (avcodec_open2(pCodecContext, pVideoCodec, NULL) < 0)
{
printf("failed to open codec through avcodec_open2\n");
return -1;
}
// https://ffmpeg.org/doxygen/trunk/structAVPacket.html
AVPacket *pPacket = av_packet_alloc();
if (!pPacket)
{
printf("failed to allocated memory for AVPacket\n");
return -1;
}
// https://ffmpeg.org/doxygen/trunk/structAVFrame.html
AVFrame *pFrame = av_frame_alloc();
if (!pFrame)
{
printf("failed to allocated memory for AVFrame\n");
return -1;
}
SwsContext *pImgConvertContext = sws_getContext(
pCodecContext->width,
pCodecContext->height,
pCodecContext->pix_fmt,
pCodecContext->width,
pCodecContext->height,
AV_PIX_FMT_BGR24,
SWS_BICUBIC,
NULL,
NULL,
NULL
);
int response = 0;
int how_many_packets_to_process = 8;
// fill the Packet with data from the Stream
// https://ffmpeg.org/doxygen/trunk/group__lavf__decoding.html#ga4fdb3084415a82e3810de6ee60e46a61
while (av_read_frame(pFormatContext, pPacket) >= 0)
{
// if it's the video stream
if (pPacket->stream_index == video_stream_index) {
printf("AVPacket->pts %" PRId64, pPacket->pts);
std::cout << std::endl;
response = decode_packet(pPacket, pCodecContext, pFrame, pVideoStream);
if (response < 0)
break;
// stop it, otherwise we'll be saving hundreds of frames
if (--how_many_packets_to_process <= 0) break;
}
// https://ffmpeg.org/doxygen/trunk/group__lavc__packet.html#ga63d5a489b419bd5d45cfd09091cbcbc2
av_packet_unref(pPacket);
}
avformat_close_input(&pFormatContext);
av_packet_free(&pPacket);
av_frame_free(&pFrame);
avcodec_free_context(&pCodecContext);
std::cout << "bye world" << std::endl;
return 0;
}
static int decode_packet(AVPacket *pPacket, AVCodecContext *pCodecContext, AVFrame *pFrame, AVStream *pStream)
{
// Supply raw packet data as input to a decoder
// https://ffmpeg.org/doxygen/trunk/group__lavc__decoding.html#ga58bc4bf1e0ac59e27362597e467efff3
int response = avcodec_send_packet(pCodecContext, pPacket);
// printf("response %d\n", response);
if (response < 0) {
printf("Error while sending a packet to the decoder: %s\n", av_err2str(response));
return response;
}
while (response >= 0)
{
// Return decoded output data (into a frame) from a decoder
// https://ffmpeg.org/doxygen/trunk/group__lavc__decoding.html#ga11e6542c4e66d3028668788a1a74217c
response = avcodec_receive_frame(pCodecContext, pFrame);
if (response == AVERROR(EAGAIN) || response == AVERROR_EOF) {
break;
} else if (response < 0) {
printf("Error while receiving a frame from the decoder: %s\n", av_err2str(response));
return response;
}
if (response >= 0) {
float time_base = pStream->time_base.num / float(pStream->time_base.den);
printf(
"Frame %d (type=%c, size=%d bytes, format=%d) pts %ld timestampe %.2f key_frame %d [DTS %d]\n",
pCodecContext->frame_number,
av_get_picture_type_char(pFrame->pict_type),
pFrame->pkt_size,
pFrame->format,
pFrame->pts,
pFrame->pts * time_base,
pFrame->key_frame,
pFrame->coded_picture_number
);
// char frame_filename[1024];
// snprintf(frame_filename, sizeof(frame_filename), "%s-%d.pgm", "frame", pCodecContext->frame_number);
// Check if the frame is a planar YUV 4:2:0, 12bpp
// That is the format of the provided .mp4 file
// RGB formats will definitely not give a gray image
// Other YUV image may do so, but untested, so give a warning
// if (pFrame->format != AV_PIX_FMT_YUV420P)
// {
// printf("Warning: the generated file may not be a grayscale image, but could e.g. be just the R component if the video format is RGB");
// }
// save a grayscale frame into a .pgm file
// save_gray_frame(pFrame->data[0], pFrame->linesize[0], pFrame->width, pFrame->height, frame_filename);
}
}
return 0;
}
cmake_minimum_required(VERSION 3.10)
# set the project name
project(ffmpeg_test)
# specify the C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# add the executable
add_executable(ffmpeg_test main.cpp)
# link ffmpeg
set(FFMPEG_ROOT "/root/ffmpeg/build")
target_include_directories(ffmpeg_test PUBLIC "${FFMPEG_ROOT}/include")
target_link_libraries(ffmpeg_test
"${FFMPEG_ROOT}/lib/libavutil.so"
"${FFMPEG_ROOT}/lib/libpostproc.so"
"${FFMPEG_ROOT}/lib/libswresample.so"
"${FFMPEG_ROOT}/lib/libswscale.so"
"${FFMPEG_ROOT}/lib/libavfilter.so"
"${FFMPEG_ROOT}/lib/libavdevice.so"
"${FFMPEG_ROOT}/lib/libavformat.so"
"${FFMPEG_ROOT}/lib/libavcodec.so"
)
# link opencv
target_include_directories(ffmpeg_test PUBLIC "/usr/include/opencv4")
target_link_libraries(ffmpeg_test
"/usr/lib/x86_64-linux-gnu/libopencv_core.so"
)
# find_library(OpenCV REQUIRED)
# message(STATUS ${OpenCV_VERSION})
# message(STATUS ${OpenCV_LIBS})
# message(STATUS ${OpenCV_INCLUDE_DIRS})

GNU linker: errors if pointer in header file is declared NULL and/or extern [duplicate]

This question already has answers here:
How do I use extern to share variables between source files?
(19 answers)
Closed 3 years ago.
I am testing some patches (C language) for BOINC client (C++ language), and during compilation I got a GNU linker error about GDBusProxy* proxy = NULL; line in file linux/user_idle_time_detection.h (complete file hereunder). So I started doing some attempts to modify the affected line, but I got two different errors (case 1 and 2 hereunder), and I really cannot understand why the linker does not like:
the extern statement
the pointer initialized at NULL;
Thank you
CASE 1
extern GDBusProxy* proxy;
returns error
/usr/bin/ld: boinc_client-user_idle_time_detection.o: in function `create_proxy':
/builddir/build/BUILD/boinc-client_release-7.14-7.14.2/client/linux/user_idle_time_detection.c:5: undefined reference to `proxy'
/usr/bin/ld: boinc_client-user_idle_time_detection.o: in function `get_user_idle_time':
/builddir/build/BUILD/boinc-client_release-7.14-7.14.2/client/linux/user_idle_time_detection.c:21: undefined reference to `proxy'
collect2: error: ld returned 1 exit status
CASE 2
Both
extern GDBusProxy* proxy = NULL;
and
GDBusProxy* proxy = NULL;
return error
/usr/bin/ld: boinc_client-hostinfo_unix.o:/builddir/build/BUILD/boinc-client_release-7.14-7.14.2/client/linux/user_idle_time_detection.h:7: multiple definition of `proxy'; boinc_client-user_idle_time_detection.o:/builddir/build/BUILD/boinc-client_release-7.14-7.14.2/client/linux/user_idle_time_detection.h:7: first defined here
CASE 3
The following works good instead
GDBusProxy* proxy;
SOURCE FILES
linux/user_idle_time_detection.h
#ifndef USER_IDLE_TIME_DETECTION_H
#define USER_IDLE_TIME_DETECTION_H
#include <gio/gio.h>
#include "gnome/gnome_dbus_interface.h"
GDBusProxy* proxy = NULL;
GDBusProxy* create_proxy();
double get_user_idle_time();
#endif /* USER_IDLE_TIME_DETECTION_H */
linux/user_idle_time_detection.c
#include <gio/gio.h>
#include "user_idle_time_detection.h"
GDBusProxy* create_proxy()
{
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_NONE,
NULL,
GNOME_DBUS_SERVICE,
GNOME_DBUS_PATH_SETTINGS,
GNOME_DBUS_INTERFACE_SETTINGS,
NULL, NULL);
return proxy;
}
double get_user_idle_time()
{
guint64 user_idle_time;
double user_idle_time_double;
GError* error = NULL;
GVariant* ret = NULL;
proxy = create_proxy();
ret = g_dbus_proxy_call_sync(proxy,
GNOME_DBUS_METHOD_SETTINGS,
NULL,
G_DBUS_CALL_FLAGS_NONE, -1,
NULL, &error);
if (!ret) {
g_dbus_error_strip_remote_error (error);
g_print ("GetIdletime failed: %s\n", error->message);
g_error_free (error);
return;
}
g_variant_get(ret, "(t)", &user_idle_time);
user_idle_time_double = (double)user_idle_time;
g_variant_unref (ret);
return user_idle_time_double;
}
linux/gnome/gnome_dbus_interface.h
#ifndef GNOME_DBUS_INTERFACE_H
#define GNOME_DBUS_INTERFACE_H
#define GNOME_DBUS_SERVICE "org.gnome.Mutter.IdleMonitor"
#define GNOME_DBUS_PATH_SETTINGS "/org/gnome/Mutter/IdleMonitor/Core"
#define GNOME_DBUS_INTERFACE_SETTINGS "org.gnome.Mutter.IdleMonitor"
#define GNOME_DBUS_METHOD_SETTINGS "GetIdletime"
#endif /* GNOME_DBUS_INTERFACE_H */
hostinfo_unix.cpp
#include "linux/user_idle_time_detection.h"
CUT
bool HOST_INFO::users_idle(bool check_all_logins, double idle_time_to_run) {
double user_idle_time;
double user_pref_idle_time_in_ms;
//user_idle_time = get_user_idle_time();
user_pref_idle_time_in_ms = (idle_time_to_run * 60000);
CUT
Makefile.am
## -*- mode: makefile; tab-width: 4 -*-
## $Id$
include $(top_srcdir)/Makefile.incl
if ENABLE_CLIENT_RELEASE
AM_LDFLAGS += -static-libtool-libs
## for an entirely statically linked library, you may want to try
## -all-static instead. There's a good chance it won't work properly,
## so we'll use the safer "-static-libtool-libs" by default.
else
if DYNAMIC_CLIENT
## if libtool starts to need flags for dynamic linking, add them here
else
AM_LDFLAGS += -static
endif
endif ## ENABLE_CLIENT_RELEASE
LIBS += $(CLIENTLIBS)
if OS_DARWIN
LIBS += -framework IOKit -framework Foundation -framework ScreenSaver -framework Cocoa -framework CoreServices
endif
bin_PROGRAMS = boinc_client boinccmd
if !OS_WIN32
bin_PROGRAMS += switcher
endif
boinccmd_SOURCES = boinc_cmd.cpp
boinccmd_DEPENDENCIES = $(LIBBOINC)
boinccmd_CPPFLAGS = $(AM_CPPFLAGS)
boinccmd_LDFLAGS = $(AM_LDFLAGS) -L$(top_srcdir)/lib
boinccmd_LDADD = $(LIBBOINC) $(BOINC_EXTRA_LIBS) $(PTHREAD_LIBS)
boinc_client_SOURCES = \
acct_mgr.cpp \
acct_setup.cpp \
app.cpp \
app_config.cpp \
app_control.cpp \
app_start.cpp \
async_file.cpp \
check_state.cpp \
client_msgs.cpp \
client_state.cpp \
client_types.cpp \
coproc_sched.cpp \
cpu_sched.cpp \
cs_account.cpp \
cs_apps.cpp \
cs_benchmark.cpp \
cs_cmdline.cpp \
cs_files.cpp \
cs_notice.cpp \
cs_platforms.cpp \
cs_prefs.cpp \
cs_proxy.cpp \
cs_scheduler.cpp \
cs_statefile.cpp \
cs_trickle.cpp \
current_version.cpp \
dhrystone.cpp \
dhrystone2.cpp \
file_names.cpp \
file_xfer.cpp \
gpu_amd.cpp \
gpu_detect.cpp \
gpu_intel.cpp \
gpu_nvidia.cpp \
gpu_opencl.cpp \
gui_http.cpp \
gui_rpc_server.cpp \
gui_rpc_server_ops.cpp \
hostinfo_linux.cpp \
hostinfo_network.cpp \
http_curl.cpp \
log_flags.cpp \
mac_address.cpp \
main.cpp \
net_stats.cpp \
pers_file_xfer.cpp \
project.cpp \
project_list.cpp \
result.cpp \
rr_sim.cpp \
sandbox.cpp \
scheduler_op.cpp \
thread.cpp \
time_stats.cpp \
whetstone.cpp \
work_fetch.cpp \
linux/user_idle_time_detection.c
boinc_client_DEPENDENCIES = $(LIBBOINC)
boinc_client_CPPFLAGS = $(AM_CPPFLAGS) $(GIO_CFLAGS) $(GLIB_CFLAGS)
boinc_client_CXXFLAGS = $(AM_CXXFLAGS) $(SSL_CXXFLAGS)
boinc_client_LDFLAGS = $(AM_LDFLAGS) $(SSL_LDFLAGS) $(GIO_LIBS) $(GLIB_LIBS) -L$(top_srcdir)/lib
if OS_WIN32
boinc_client_CXXFLAGS += -I$(top_srcdir)/coprocs/NVIDIA/include
boinc_client_SOURCES += hostinfo_win.cpp \
hostinfo_wsl.cpp \
sysmon_win.cpp \
win/boinc_cli.rc \
win/res/boinc.ico
else
if OS_DARWIN
boinc_client_LDFLAGS += -Wl,-flat_namespace,-undefined,dynamic_lookup
else
boinc_client_SOURCES += hostinfo_unix.cpp
endif
endif
boinc_client_LDADD = $(LIBBOINC) $(LIBBOINC_CRYPT) $(BOINC_EXTRA_LIBS) $(PTHREAD_LIBS)
boinc_clientdir = $(bindir)
if OS_ARM_LINUX
boinc_client_LDADD += libwhetneon.a libwhetvfp.a
noinst_LIBRARIES = libwhetneon.a libwhetvfp.a
libwhetneon_a_SOURCES = whetstone.cpp
libwhetneon_a_CXXFLAGS = $(boinc_client_CXXFLAGS) -DANDROID_NEON -mfloat-abi=softfp -mfpu=neon
libwhetvfp_a_SOURCES = whetstone.cpp
libwhetvfp_a_CXXFLAGS = $(boinc_client_CXXFLAGS) -DANDROID_VFP -mfloat-abi=softfp -mfpu=vfp
endif
switcher_SOURCES = switcher.cpp
switcher_LDFLAGS = $(AM_LDFLAGS) -L../lib
switcher_LDADD = $(LIBBOINC)
## since we are using libtool we need some magic to get boinc and boinc_client
## to both be installed properly. The next two rules do that...
all-local: boinc$(EXEEXT)
boinc$(EXEEXT): boinc_client$(EXEEXT)
rm -f boinc$(EXEEXT) .libs/boinc$(EXEEXT)
$(LN) boinc_client$(EXEEXT) boinc$(EXEEXT)
if test -f .libs/boinc_client$(EXEEXT) ; then $(LN) .libs/boinc_client$(EXEEXT) .libs/boinc$(EXEEXT) ; fi
install-exec-hook:
rm -f $(DESTDIR)$(exec_prefix)/bin/boinc$(EXEEXT)
$(LN) $(DESTDIR)$(exec_prefix)/bin/boinc_client$(EXEEXT) $(DESTDIR)$(exec_prefix)/bin/boinc$(EXEEXT)
## these source files need to be specified because no rule uses them.
EXTRA_DIST = *.h \
mac \
translation \
win
Makefile.curl.am
## -*- mode: make; tab-width: 4 -*-
## $Id$
include $(top_srcdir)/Makefile.incl
# (for a while we used "-static -static-libgcc" on linux, but this is obsolete
# now)
#STATIC_FLAGS=#STATIC_FLAGS#
client-bin: #CLIENT_BIN_FILENAME#
LIBS += #CLIENTLIBS#
bin_PROGRAMS = boinc_client
EXTRA_PROGRAMS = cpu_benchmark
boinc_client_SOURCES = \
acct_mgr.cpp \
acct_setup.cpp \
app.cpp \
app_control.cpp \
app_graphics.cpp \
app_start.cpp \
check_state.cpp \
client_msgs.cpp \
client_state.cpp \
client_types.cpp \
cs_account.cpp \
cs_apps.cpp \
cs_benchmark.cpp \
cs_cmdline.cpp \
cs_data.cpp \
cs_files.cpp \
cs_prefs.cpp \
cs_scheduler.cpp \
cs_statefile.cpp \
cs_trickle.cpp \
dhrystone.cpp \
dhrystone2.cpp \
file_names.cpp \
file_xfer.cpp \
gui_http.cpp \
gui_rpc_server.cpp \
gui_rpc_server_ops.cpp \
hostinfo_linux.cpp \
hostinfo_network.cpp \
hostinfo_unix.cpp \
http_curl.cpp \
log_flags.cpp \
main.cpp \
net_stats.cpp \
net_xfer_curl.cpp \
pers_file_xfer.cpp \
scheduler_op.cpp \
time_stats.cpp \
whetstone.cpp \
linux/user_idle_time_detection.c
boinc_client_DEPENDENCIES = $(LIBRSA)
boinc_client_CPPFLAGS = -D_USE_CURL -I../../curl-7.14.0/include -I $(srcdir)/win $(AM_CPPFLAGS) -O3
boinc_client_LDFLAGS = -static-libgcc
boinc_client_LDADD = -L/usr/local/ssl/lib -lssl -L../../curl-7.14.0/lib -lcurl -L../lib -lboinc $(RSA_LIBS) $(PTHREAD_LIBS)
#boinc_client_LDFLAGS = $(STATIC_FLAGS)
# the following don't do anything
cpu_benchmark_SOURCES = whetstone.cpp dhrystone.cpp
cpu_benchmark_CFLAGS = -O3 $(AM_CFLAGS)
all-local: client-bin
# make a hard link to the client name.
#CLIENT_BIN_FILENAME#: boinc_client
rm -f $#
#LN# $? $#
#STRIP# $#
## these source files need to be specified because no rule uses them.
EXTRA_DIST = *.h \
mac \
translation \
win
clean-local:
rm -f #CLIENT_BIN_FILENAME#
configure.ac
Cannot insert it here due Stackoverflow characters limit.
You should be getting a warning:
// This is wrong...
extern GDBusProxy* proxy = NULL;
warning: ‘proxy’ initialized and declared ‘extern’
extern GDBusProxy* proxy = NULL;
^~~~~
The extern storage class specifier basically means "this is defined somewhere else", but the = NULL is not really somewhere else.
Just like functions, with variables you should:
Declare them in the header file (compiled many times):
extern GDBusProxy *proxy;
This is a declaration and you can have as many declarations of a single object as you like (as long as they are all compatible).
Define them in the C file (compiled once):
GDBusProxy *proxy = NULL;
This is a definition and you can only have one definition in your entire project. So it cannot appear in a header file, unless that header file is only included by one C file.
This not the only way to do it. You can use the following declaration everywhere:
GDBusProxy *proxy;
This is a special case, it counts as a definition but you are allowed to have more than one in your program.
Note that = NULL is redundant. Global variables are zero-initialized by default.
In the case 1 you missed to define the variable in a source file, so its definition is missing
In the other cases having
GDBusProxy* proxy = NULL;
in a header file does not declare the variable but define it, so including the header file in several sources define it several times.
replace it by
extern GDBusProxy* proxy;
and define it in one of the source files

undefined reference to `TVersionCheck::TVersionCheck(int)

I want to use root cern libs in my Qt program. But I have problems with linker:
undefined reference to `TVersionCheck::TVersionCheck(int)
I don't know what's the reason. I did read another forum, but still can't understand the issue. Please, help me.
The .pro file contents:
QT += core
QT -= gui
CONFIG += c++11
TARGET = v_root_trees_2
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += "C:/root_v5.34.34/include"
LIBS += -L"C:/root_v5.34.34/lib" \
-lcomplexDict \
-ldequeDict \
-lfreetype \
-llibAfterImage \
-llibASImage \
-llibASImageGui \
-llibCint \
-llibCintex \
-llibCore \
-llibEG \
-llibEGPythia8 \
-llibEve \
-llibFitPanel \
-llibFoam \
-llibFTGL \
-llibFumili \
-llibGdml \
-llibGed \
-llibGenetic \
-llibGenVector \
-llibGeom \
-llibGeomBuilder \
-llibGeomPainter \
-llibGLEW \
-llibGpad \
-llibGraf \
-llibGraf3d \
-llibGui \
-llibGuiBld \
-llibGuiHtml \
-llibGviz3d \
-llibHist \
-llibHistPainter \
-llibHtml \
-llibMathCore \
-llibMathMore \
-llibMatrix \
-llibMinuit \
-llibMinuit2 \
-llibMLP \
-llibNet \
-llibPhysics \
-llibPostscript \
-llibProof \
-llibProofDraw \
-llibProofPlayer \
-llibPyROOT \
-llibQuadp \
-llibRecorder \
-llibReflex \
-llibReflexDict \
-llibRGL \
-llibRHTTP \
-llibRint \
-llibRIO \
-llibRODBC \
-llibRooFit \
-llibRooFitCore \
-llibRooStats \
-llibRootAuth \
-llibSessionViewer \
-llibSmatrix \
-llibSpectrum \
-llibSpectrumPainter \
-llibSPlot \
-llibSQLIO \
-llibTable \
-llibThread \
-llibTMVA \
-llibTree \
-llibTreePlayer \
-llibTreeViewer \
-llibUnuran \
-llibVMC \
-llibWin32gdk \
-llibXMLIO \
-llistDict \
-lmap2Dict \
-lmapDict \
-lmathtext \
-lmultimap2Dict \
-lmultimapDict \
-lmultisetDict \
-lsetDict \
-lvectorDict
main.cpp file:
#include <QCoreApplication>
#include "TMultiGraph.h" // problem if add this line
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
return a.exec();
}
I don't know what is wrong. I added all .lib files.
The paths C:/root_v5.34.34/lib and C:/root_v5.34.34/include are correct and do exist. Changing paths I see cannot find ... error.
So, the paths are correct.
I checked the similar code in VS2013 and don't see any errors.
But I write a lot of code in Qt and can't change IDE.
I understand, that some link causes the error, but can't find it.
Some libraries in your project are included incorrectly. e.g. -llibAfterImage -llibASImage -llibASImageGui
you should write -lAfterImage -lASImage -lASImageGui and so on...
When i corrected your .pro file, build succeeded.
Possibly one of that incorrectly included libraries contains implementation of TVersionCheck::TVersionCheck(int)
I was struggling for this problem recently. It's because that ROOT under windows is 32bit, and you need to check the MSCV2015 32bit while reinstalling Qt...

Adding Makefile options into qtcreator project

I have a project made in qtcreator. The project in itself isn't very important for the question. I would like to add a project called PowerWatershed, the sources are available here:
PowerWatershed
Unfortunately, adding all the files to the .pro file give me an error when compiling, when making the "make" command with the Makefile of the PowerWatershed project works.
The makefile of the project is:
# Camille Couprie
# october 2009
OBJDIR = objects
PINKDIR = PINK
CSDIR = CSparse
ARGV = argv
PWSRC = src
VPATH = ${PINKDIR}:${CSDIR}:${ARGV}
CSINCLUDE = -I${CSDIR}/Include
PINKINCLUDE = -I${PINKDIR}
ARGVINCLUDE = -I${ARGV}
PWINCLUDE = -Iinclude
INCL = ${CSINCLUDE} ${PINKINCLUDE} ${ARGVINCLUDE} ${PWINCLUDE}
OBJ= objects/larith.o \
objects/ccsort.o \
objects/cccodimage.o \
objects/gageodesic.o \
objects/mccodimage.o \
objects/mcimage.o \
objects/mcindic.o \
objects/mclifo.o \
objects/random_walker.o \
objects/lMSF.o \
objects/MSF_RW.o \
objects/mcrbt.o \
objects/union_find.o \
objects/image_toolbox.o \
objects/cs_lu.o \
objects/cs_lusol.o \
objects/cs_malloc.o \
objects/cs_util.o \
objects/cs_multiply.o \
objects/cs_compress.o \
objects/cs_lsolve.o \
objects/cs_scatter.o \
objects/cs_cumsum.o \
objects/cs_sqr.o \
objects/cs_ipvec.o \
objects/cs_amd.o \
objects/cs_permute.o \
objects/cs_transpose.o \
objects/cs_counts.o \
objects/cs_add.o \
objects/cs_etree.o \
objects/cs_leaf.o \
objects/cs_fkeep.o \
objects/cs_tdfs.o \
objects/cs_usolve.o \
objects/cs_spsolve.o \
objects/cs_post.o \
objects/cs_reach.o \
objects/cs_dfs.o \
objects/argv.o
# objects/cs_print.o \
# objects/cs_norm.o \
#
FLAGS = -g -Wall # -pg
CXX = g++
CC = gcc
OPTIMISE=-O4
WARNINGS=-Wall #-Werror
DEBUG=-g
CXXFLAGS= ${DEBUG} ${WARNINGS} ${OPTIMISE} -Wno-deprecated ${FLAGS}
CFLAGS = ${DEBUG} ${WARNINGS} ${OPTIMISE} ${FLAGS}
all: ${CS} ${OBJ}
${MAKE} powerwatsegm.exe
# make with the Intel compiler, a very good complement to gcc/g++
# much more efficient and with better diagnoses
intel:
${MAKE} CC=icc CXX=icpc all
debug:
${MAKE} OPTIMISE='' all
# remove the asserts and the debug information
production:
${MAKE} DEBUG='' FLAGS="-DNDEBUG" all
clean:
rm -f *.exe; rm -f *~; rm -f $(OBJ); #rm -f overlay*; rm -f mask*;
powerwatsegm.exe: ${PWSRC}/powerwatsegm.c $(OBJ)
$(CXX) $(CXXFLAGS) $(INCL) ${PWSRC}/powerwatsegm.c $(OBJ) -o powerwatsegm.exe
$(OBJDIR)/%.o: ${PWSRC}/%.c
$(CXX) $(CXXFLAGS) ${INCL} -c $< -o $#
$(OBJDIR)/%.o: ${CSDIR}/Source/%.c ${CSDIR}/Include/cs.h
$(CC) $(CFLAGS) ${CSINCLUDE} -c $< -o $#
$(OBJDIR)/%.o: ${PINKDIR}/%.c
$(CXX) $(CXXFLAGS) ${PINKINCLUDE} -c $< -o $#
$(OBJDIR)/argv.o: ${ARGV}/argv.c ${ARGV}/argv.h ${ARGV}/argv_loc.h
$(CC) $(CCFLAGS) ${ARGVINCLUDE} -c $< -o $#
$(OBJDIR)/lMSF.o: ${PWSRC}/lMSF.c ${PINKDIR}/mcimage.h ${PINKDIR}/mccodimage.h
$(CXX) $(CFLAGS) ${PINKINCLUDE} ${PWINCLUDE} -c ${PWSRC}/lMSF.c -o $#
I would like to add th propoer option to my .pro file to make the compilation work. At the moment, my pro file looks like
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = Power
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
PW_1.0.1/argv/argv.c \
PW_1.0.1/CSparse/Source/cs_add.c \
PW_1.0.1/CSparse/Source/cs_amd.c \
PW_1.0.1/CSparse/Source/cs_chol.c \
PW_1.0.1/CSparse/Source/cs_cholsol.c \
PW_1.0.1/CSparse/Source/cs_compress.c \
PW_1.0.1/CSparse/Source/cs_counts.c \
PW_1.0.1/CSparse/Source/cs_cumsum.c \
PW_1.0.1/CSparse/Source/cs_dfs.c \
PW_1.0.1/CSparse/Source/cs_etree.c \
PW_1.0.1/CSparse/Source/cs_fkeep.c \
PW_1.0.1/CSparse/Source/cs_ipvec.c \
PW_1.0.1/CSparse/Source/cs_leaf.c \
PW_1.0.1/CSparse/Source/cs_lsolve.c \
PW_1.0.1/CSparse/Source/cs_lu.c \
PW_1.0.1/CSparse/Source/cs_lusol.c \
PW_1.0.1/CSparse/Source/cs_malloc.c \
PW_1.0.1/CSparse/Source/cs_multiply.c \
PW_1.0.1/CSparse/Source/cs_norm.c \
PW_1.0.1/CSparse/Source/cs_permute.c \
PW_1.0.1/CSparse/Source/cs_post.c \
PW_1.0.1/CSparse/Source/cs_print.c \
PW_1.0.1/CSparse/Source/cs_reach.c \
PW_1.0.1/CSparse/Source/cs_scatter.c \
PW_1.0.1/CSparse/Source/cs_spsolve.c \
PW_1.0.1/CSparse/Source/cs_sqr.c \
PW_1.0.1/CSparse/Source/cs_tdfs.c \
PW_1.0.1/CSparse/Source/cs_transpose.c \
PW_1.0.1/CSparse/Source/cs_usolve.c \
PW_1.0.1/CSparse/Source/cs_util.c \
PW_1.0.1/PINK/gageodesic.c \
PW_1.0.1/PINK/larith.c \
PW_1.0.1/PINK/lMSF.c \
PW_1.0.1/PINK/mccodimage.c \
PW_1.0.1/PINK/mcimage.c \
PW_1.0.1/PINK/mcindic.c \
PW_1.0.1/PINK/mclifo.c \
PW_1.0.1/PINK/mcrbt.c \
PW_1.0.1/src/cccodimage.c \
PW_1.0.1/src/ccsort.c \
PW_1.0.1/src/gageodesic.c \
PW_1.0.1/src/image_toolbox.c \
PW_1.0.1/src/lMSF.c \
PW_1.0.1/src/MSF_RW.c \
PW_1.0.1/src/powerwatsegm.c \
PW_1.0.1/src/random_walker.c \
PW_1.0.1/src/union_find.c
HEADERS += mainwindow.h \
PW_1.0.1/argv/argv.h \
PW_1.0.1/argv/argv_loc.h \
PW_1.0.1/argv/compat.h \
PW_1.0.1/argv/conf.h \
PW_1.0.1/CSparse/Include/cs.h \
PW_1.0.1/include/cccodimage.h \
PW_1.0.1/include/ccsort.h \
PW_1.0.1/include/gageodesic.h \
PW_1.0.1/include/image_toolbox.h \
PW_1.0.1/include/lMSF.h \
PW_1.0.1/include/MSF_RW.h \
PW_1.0.1/include/powerwatsegm.h \
PW_1.0.1/include/random_walker.h \
PW_1.0.1/include/union_find.h \
PW_1.0.1/PINK/larith.h \
PW_1.0.1/PINK/mccodimage.h \
PW_1.0.1/PINK/mcimage.h \
PW_1.0.1/PINK/mcindic.h \
PW_1.0.1/PINK/mclifo.h \
PW_1.0.1/PINK/mcrbt.h \
PW_1.0.1/PINK/mcutil.h
FORMS += mainwindow.ui
And I have the error:
/home/iznogood/Documents/Power/PW_1.0.1/src/gageodesic.c:44: erreur : mccodimage.h: No such file or directory
#include <mccodimage.h>
^
I think this is a matter of path, which are mentionned in the Makefile with:
OBJDIR = objects
PINKDIR = PINK
CSDIR = CSparse
ARGV = argv
PWSRC = src
VPATH = ${PINKDIR}:${CSDIR}:${ARGV}
But I can't manage to add them to the .pro file.
The relevant qmake variable is INCLUDEPATH.
So, for the following from the original makefile:
CSINCLUDE = -I${CSDIR}/Include
PINKINCLUDE = -I${PINKDIR}
ARGVINCLUDE = -I${ARGV}
PWINCLUDE = -Iinclude
INCL = ${CSINCLUDE} ${PINKINCLUDE} ${ARGVINCLUDE} ${PWINCLUDE}
would be something like this:
INCLUDEPATH += ${CSDIR}/Include \
${PINKDIR} \
${ARGV} \
include
This is documented in the QMake manual in the reference pages.

compile QT and OpenCV together in Ubuntu using qmake

Im writing a OpenCV application and a QT GUI together and im having some issues compiling.
Some background information that might be useful; the OS is Ubuntu 13.10, the output of " qmake --version" is :QMake version 3.0 Using Qt version 5.0.2 in /usr/lib/x86_64-linux-gnu
The issues starts upon the appearance of one line of code, that being "Mat cvImage" where I declare a Mat object. The way im compiling is first "qmake -project" then "qmake" then i go into my .pro file and add "QT += widgets" and then I type "make", when i do this, i get the error
/usr/lib/x86_64-linux-gnu/qt5/bin/qmake -o Makefile gui2.pro
g++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/share/qt5/mkspecs/linux-g++-64 -I. -I. -I/usr/include/qt5 - I/usr/include/qt5/QtWidgets -I/usr/include/qt5/QtGui -I/usr/include/qt5/QtCore -I. -o main.o main.cpp
main.cpp: In function ‘int main(int, char**)’:
main.cpp:55:2: error: ‘Mat’ was not declared in this scope
Mat cvImage;
^
main.cpp:55:2: note: suggested alternative:
In file included from main.cpp:20:0:
/usr/local/include/opencv2/core/core.hpp:1683:18: note: ‘cv::Mat’
class CV_EXPORTS Mat
^
main.cpp:55:6: error: expected ‘;’ before ‘cvImage’
Mat cvImage;
^
make: *** [main.o] Error 1
To be honest, i have no idea what "In file included from main.cpp:20:0: /usr/local/include/opencv2/core/core.hpp:1683:10 note: 'cv :: Mat' " means. I included all the appropriate OpenCV libraries and I dont know how to interpret that line of error output. Below is my code
/*****************C++ Libraries******************/
#include <iostream>
/****************User Defined*******************/
#include "function.h"
#include "function.cpp"
/****************Libraries Needed for QT********/
#include <QObject>
#include <QApplication>
#include <QWidget>
#include <QGridLayout>
#include <QSpinBox>
#include <QLabel>
#include <QGraphicsScene>
#include<QGraphicsView>
#include <QGraphicsPixmapItem>
/************Libraries Needed For OpenCV*******/
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace std;
int main(int argc, char ** argv){
QApplication a(argc, argv);
/** some code that runs a gui ***/
Mat cvImage; // This is where the problem starts
window.show();
return a.exec();
}
I also looked into my Makefile and i dont see any paths or anything to OpenCV libraries so I tried adding them, it caused more problems.
This is the auto-generated Makefile(via the qmake command)
#############################################################################
# Makefile for building: gui2
# Generated by qmake (3.0) (Qt 5.0.2) on: Mon Jan 27 12:24:52 2014
# Project: gui2.pro
# Template: app
# Command: /usr/lib/x86_64-linux-gnu/qt5/bin/qmake -o Makefile gui2.pro
#############################################################################
MAKEFILE = Makefile
####### Compiler, tools and options
CC = gcc
CXX = g++
DEFINES = -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB
CFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIE $(DEFINES)
CXXFLAGS = -m64 -pipe -O2 -Wall -W -D_REENTRANT -fPIE $(DEFINES)
INCPATH = -I/usr/share/qt5/mkspecs/linux-g++-64 -I. -I. -I/usr/include/qt5 -I/usr/include/qt5/QtWidgets -I/usr/include/qt5/QtGui -I/usr/include/qt5/QtCore -I.
LINK = g++
LFLAGS = -m64 -Wl,-O1
LIBS = $(SUBLIBS) -L/usr/X11R6/lib64 -lQt5Widgets -L/usr/lib/x86_64-linux-gnu -lQt5Gui -lQt5Core -lGL -lpthread
AR = ar cqs
RANLIB =
QMAKE = /usr/lib/x86_64-linux-gnu/qt5/bin/qmake
TAR = tar -cf
COMPRESS = gzip -9f
COPY = cp -f
SED = sed
COPY_FILE = cp -f
COPY_DIR = cp -f -R
STRIP = strip
INSTALL_FILE = install -m 644 -p
INSTALL_DIR = $(COPY_DIR)
INSTALL_PROGRAM = install -m 755 -p
DEL_FILE = rm -f
SYMLINK = ln -f -s
DEL_DIR = rmdir
MOVE = mv -f
CHK_DIR_EXISTS= test -d
MKDIR = mkdir -p
####### Output directory
OBJECTS_DIR = ./
####### Files
SOURCES = main.cpp moc_function.cpp
OBJECTS = main.o \
moc_function.o
DIST = /usr/share/qt5/mkspecs/features/spec_pre.prf \
/usr/share/qt5/mkspecs/common/shell-unix.conf \
/usr/share/qt5/mkspecs/common/unix.conf \
/usr/share/qt5/mkspecs/common/linux.conf \
/usr/share/qt5/mkspecs/common/gcc-base.conf \
/usr/share/qt5/mkspecs/common/gcc-base-unix.conf \
/usr/share/qt5/mkspecs/common/g++-base.conf \
/usr/share/qt5/mkspecs/common/g++-unix.conf \
/usr/share/qt5/mkspecs/qconfig.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_3d.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_3dquick.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_bootstrap.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_clucene.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_concurrent.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_core.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_dbus.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_designer.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_designercomponents.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_gui.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_help.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_location.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_multimedia.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_multimediawidgets.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_network.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_opengl.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_platformsupport.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_printsupport.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_qml.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_qmldevtools.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_qmltest.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_qtmultimediaquicktools.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_quick.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_quickparticles.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_script.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_scripttools.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_sensors.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_sql.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_svg.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_testlib.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_uitools.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_v8.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_webkit.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_webkitwidgets.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_widgets.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_xml.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_xmlpatterns.pri \
/usr/share/qt5/mkspecs/features/qt_functions.prf \
/usr/share/qt5/mkspecs/features/qt_config.prf \
/usr/share/qt5/mkspecs/linux-g++-64/qmake.conf \
/usr/share/qt5/mkspecs/features/spec_post.prf \
/usr/share/qt5/mkspecs/features/exclusive_builds.prf \
/usr/share/qt5/mkspecs/features/default_pre.prf \
/usr/share/qt5/mkspecs/features/unix/default_pre.prf \
/usr/share/qt5/mkspecs/features/resolve_config.prf \
/usr/share/qt5/mkspecs/features/default_post.prf \
/usr/share/qt5/mkspecs/features/unix/gdb_dwarf_index.prf \
/usr/share/qt5/mkspecs/features/warn_on.prf \
/usr/share/qt5/mkspecs/features/qt.prf \
/usr/share/qt5/mkspecs/features/resources.prf \
/usr/share/qt5/mkspecs/features/moc.prf \
/usr/share/qt5/mkspecs/features/unix/opengl.prf \
/usr/share/qt5/mkspecs/features/uic.prf \
/usr/share/qt5/mkspecs/features/unix/thread.prf \
/usr/share/qt5/mkspecs/features/wayland-scanner.prf \
/usr/share/qt5/mkspecs/features/testcase_targets.prf \
/usr/share/qt5/mkspecs/features/exceptions.prf \
/usr/share/qt5/mkspecs/features/yacc.prf \
/usr/share/qt5/mkspecs/features/lex.prf \
gui2.pro \
gui2.pro
QMAKE_TARGET = gui2
DESTDIR =
TARGET = gui2
first: all
####### Implicit rules
.SUFFIXES: .o .c .cpp .cc .cxx .C
.cpp.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$#" "$<"
.cc.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$#" "$<"
.cxx.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$#" "$<"
.C.o:
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$#" "$<"
.c.o:
$(CC) -c $(CFLAGS) $(INCPATH) -o "$#" "$<"
####### Build rules
all: Makefile $(TARGET)
$(TARGET): $(OBJECTS)
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
Makefile: gui2.pro /usr/share/qt5/mkspecs/linux-g++-64/qmake.conf /usr/share/qt5/mkspecs/features/spec_pre.prf \
/usr/share/qt5/mkspecs/common/shell-unix.conf \
/usr/share/qt5/mkspecs/common/unix.conf \
/usr/share/qt5/mkspecs/common/linux.conf \
/usr/share/qt5/mkspecs/common/gcc-base.conf \
/usr/share/qt5/mkspecs/common/gcc-base-unix.conf \
/usr/share/qt5/mkspecs/common/g++-base.conf \
/usr/share/qt5/mkspecs/common/g++-unix.conf \
/usr/share/qt5/mkspecs/qconfig.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_3d.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_3dquick.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_bootstrap.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_clucene.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_concurrent.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_core.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_dbus.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_designer.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_designercomponents.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_gui.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_help.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_location.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_multimedia.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_multimediawidgets.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_network.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_opengl.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_platformsupport.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_printsupport.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_qml.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_qmldevtools.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_qmltest.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_qtmultimediaquicktools.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_quick.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_quickparticles.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_script.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_scripttools.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_sensors.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_sql.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_svg.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_testlib.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_uitools.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_v8.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_webkit.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_webkitwidgets.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_widgets.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_xml.pri \
/usr/share/qt5/mkspecs/modules/qt_lib_xmlpatterns.pri \
/usr/share/qt5/mkspecs/features/qt_functions.prf \
/usr/share/qt5/mkspecs/features/qt_config.prf \
/usr/share/qt5/mkspecs/linux-g++-64/qmake.conf \
/usr/share/qt5/mkspecs/features/spec_post.prf \
/usr/share/qt5/mkspecs/features/exclusive_builds.prf \
/usr/share/qt5/mkspecs/features/default_pre.prf \
/usr/share/qt5/mkspecs/features/unix/default_pre.prf \
/usr/share/qt5/mkspecs/features/resolve_config.prf \
/usr/share/qt5/mkspecs/features/default_post.prf \
/usr/share/qt5/mkspecs/features/unix/gdb_dwarf_index.prf \
/usr/share/qt5/mkspecs/features/warn_on.prf \
/usr/share/qt5/mkspecs/features/qt.prf \
/usr/share/qt5/mkspecs/features/resources.prf \
/usr/share/qt5/mkspecs/features/moc.prf \
/usr/share/qt5/mkspecs/features/unix/opengl.prf \
/usr/share/qt5/mkspecs/features/uic.prf \
/usr/share/qt5/mkspecs/features/unix/thread.prf \
/usr/share/qt5/mkspecs/features/wayland-scanner.prf \
/usr/share/qt5/mkspecs/features/testcase_targets.prf \
/usr/share/qt5/mkspecs/features/exceptions.prf \
/usr/share/qt5/mkspecs/features/yacc.prf \
/usr/share/qt5/mkspecs/features/lex.prf \
gui2.pro \
/usr/lib/x86_64-linux-gnu/libQt5Widgets.prl \
/usr/lib/x86_64-linux-gnu/libQt5Gui.prl \
/usr/lib/x86_64-linux-gnu/libQt5Core.prl
$(QMAKE) -o Makefile gui2.pro
/usr/share/qt5/mkspecs/features/spec_pre.prf:
/usr/share/qt5/mkspecs/common/shell-unix.conf:
/usr/share/qt5/mkspecs/common/unix.conf:
/usr/share/qt5/mkspecs/common/linux.conf:
/usr/share/qt5/mkspecs/common/gcc-base.conf:
/usr/share/qt5/mkspecs/common/gcc-base-unix.conf:
/usr/share/qt5/mkspecs/common/g++-base.conf:
/usr/share/qt5/mkspecs/common/g++-unix.conf:
/usr/share/qt5/mkspecs/qconfig.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_3d.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_3dquick.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_bootstrap.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_clucene.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_concurrent.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_core.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_dbus.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_designer.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_designercomponents.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_gui.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_help.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_location.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_multimedia.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_multimediawidgets.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_network.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_opengl.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_platformsupport.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_printsupport.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_qml.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_qmldevtools.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_qmltest.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_qtmultimediaquicktools.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_quick.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_quickparticles.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_script.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_scripttools.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_sensors.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_sql.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_svg.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_testlib.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_uitools.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_v8.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_webkit.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_webkitwidgets.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_widgets.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_xml.pri:
/usr/share/qt5/mkspecs/modules/qt_lib_xmlpatterns.pri:
/usr/share/qt5/mkspecs/features/qt_functions.prf:
/usr/share/qt5/mkspecs/features/qt_config.prf:
/usr/share/qt5/mkspecs/linux-g++-64/qmake.conf:
/usr/share/qt5/mkspecs/features/spec_post.prf:
/usr/share/qt5/mkspecs/features/exclusive_builds.prf:
/usr/share/qt5/mkspecs/features/default_pre.prf:
/usr/share/qt5/mkspecs/features/unix/default_pre.prf:
/usr/share/qt5/mkspecs/features/resolve_config.prf:
/usr/share/qt5/mkspecs/features/default_post.prf:
/usr/share/qt5/mkspecs/features/unix/gdb_dwarf_index.prf:
/usr/share/qt5/mkspecs/features/warn_on.prf:
/usr/share/qt5/mkspecs/features/qt.prf:
/usr/share/qt5/mkspecs/features/resources.prf:
/usr/share/qt5/mkspecs/features/moc.prf:
/usr/share/qt5/mkspecs/features/unix/opengl.prf:
/usr/share/qt5/mkspecs/features/uic.prf:
/usr/share/qt5/mkspecs/features/unix/thread.prf:
/usr/share/qt5/mkspecs/features/wayland-scanner.prf:
/usr/share/qt5/mkspecs/features/testcase_targets.prf:
/usr/share/qt5/mkspecs/features/exceptions.prf:
/usr/share/qt5/mkspecs/features/yacc.prf:
/usr/share/qt5/mkspecs/features/lex.prf:
gui2.pro:
/usr/lib/x86_64-linux-gnu/libQt5Widgets.prl:
/usr/lib/x86_64-linux-gnu/libQt5Gui.prl:
/usr/lib/x86_64-linux-gnu/libQt5Core.prl:
qmake: FORCE
#$(QMAKE) -o Makefile gui2.pro
qmake_all: FORCE
dist:
#test -d .tmp/gui21.0.0 || mkdir -p .tmp/gui21.0.0
$(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/gui21.0.0/ && $(COPY_FILE) --parents function.h hide/convertImage.h function.cpp .tmp/gui21.0.0/ && $(COPY_FILE) --parents main.cpp .tmp/gui21.0.0/ && (cd `dirname .tmp/gui21.0.0` && $(TAR) gui21.0.0.tar gui21.0.0 && $(COMPRESS) gui21.0.0.tar) && $(MOVE) `dirname .tmp/gui21.0.0`/gui21.0.0.tar.gz . && $(DEL_FILE) -r .tmp/gui21.0.0
clean:compiler_clean
-$(DEL_FILE) $(OBJECTS)
-$(DEL_FILE) *~ core *.core
####### Sub-libraries
distclean: clean
-$(DEL_FILE) $(TARGET)
-$(DEL_FILE) Makefile
mocclean: compiler_moc_header_clean compiler_moc_source_clean
mocables: compiler_moc_header_make_all compiler_moc_source_make_all
check: first
compiler_rcc_make_all:
compiler_rcc_clean:
compiler_wayland-server-header_make_all:
compiler_wayland-server-header_clean:
compiler_wayland-client-header_make_all:
compiler_wayland-client-header_clean:
compiler_moc_header_make_all: moc_function.cpp
compiler_moc_header_clean:
-$(DEL_FILE) moc_function.cpp
moc_function.cpp: /usr/include/qt5/QtCore/QObject \
/usr/include/qt5/QtCore/qobject.h \
/usr/include/qt5/QtCore/qobjectdefs.h \
/usr/include/qt5/QtCore/qnamespace.h \
/usr/include/qt5/QtCore/qglobal.h \
/usr/include/qt5/QtCore/qconfig.h \
/usr/include/qt5/QtCore/qfeatures.h \
/usr/include/qt5/QtCore/qsystemdetection.h \
/usr/include/qt5/QtCore/qcompilerdetection.h \
/usr/include/qt5/QtCore/qprocessordetection.h \
/usr/include/qt5/QtCore/qlogging.h \
/usr/include/qt5/QtCore/qflags.h \
/usr/include/qt5/QtCore/qtypeinfo.h \
/usr/include/qt5/QtCore/qtypetraits.h \
/usr/include/qt5/QtCore/qsysinfo.h \
/usr/include/qt5/QtCore/qobjectdefs_impl.h \
/usr/include/qt5/QtCore/qstring.h \
/usr/include/qt5/QtCore/qchar.h \
/usr/include/qt5/QtCore/qbytearray.h \
/usr/include/qt5/QtCore/qrefcount.h \
/usr/include/qt5/QtCore/qatomic.h \
/usr/include/qt5/QtCore/qbasicatomic.h \
/usr/include/qt5/QtCore/qatomic_bootstrap.h \
/usr/include/qt5/QtCore/qgenericatomic.h \
/usr/include/qt5/QtCore/qatomic_msvc.h \
/usr/include/qt5/QtCore/qatomic_integrity.h \
/usr/include/qt5/QtCore/qoldbasicatomic.h \
/usr/include/qt5/QtCore/qatomic_vxworks.h \
/usr/include/qt5/QtCore/qatomic_power.h \
/usr/include/qt5/QtCore/qatomic_aarch64.h \
/usr/include/qt5/QtCore/qatomic_alpha.h \
/usr/include/qt5/QtCore/qatomic_armv7.h \
/usr/include/qt5/QtCore/qatomic_armv6.h \
/usr/include/qt5/QtCore/qatomic_armv5.h \
/usr/include/qt5/QtCore/qatomic_bfin.h \
/usr/include/qt5/QtCore/qatomic_ia64.h \
/usr/include/qt5/QtCore/qatomic_mips.h \
/usr/include/qt5/QtCore/qatomic_s390.h \
/usr/include/qt5/QtCore/qatomic_sh4a.h \
/usr/include/qt5/QtCore/qatomic_sparc.h \
/usr/include/qt5/QtCore/qatomic_x86.h \
/usr/include/qt5/QtCore/qatomic_cxx11.h \
/usr/include/qt5/QtCore/qatomic_gcc.h \
/usr/include/qt5/QtCore/qatomic_unix.h \
/usr/include/qt5/QtCore/qarraydata.h \
/usr/include/qt5/QtCore/qstringbuilder.h \
/usr/include/qt5/QtCore/qlist.h \
/usr/include/qt5/QtCore/qalgorithms.h \
/usr/include/qt5/QtCore/qiterator.h \
/usr/include/qt5/QtCore/qcoreevent.h \
/usr/include/qt5/QtCore/qscopedpointer.h \
/usr/include/qt5/QtCore/qmetatype.h \
/usr/include/qt5/QtCore/qvarlengtharray.h \
/usr/include/qt5/QtCore/qcontainerfwd.h \
/usr/include/qt5/QtCore/qisenum.h \
/usr/include/qt5/QtCore/qobject_impl.h \
function.h
/usr/lib/x86_64-linux-gnu/qt5/bin/moc $(DEFINES) $(INCPATH) function.h -o moc_function.cpp
compiler_wayland-code_make_all:
compiler_wayland-code_clean:
compiler_moc_source_make_all:
compiler_moc_source_clean:
compiler_uic_make_all:
compiler_uic_clean:
compiler_yacc_decl_make_all:
compiler_yacc_decl_clean:
compiler_yacc_impl_make_all:
compiler_yacc_impl_clean:
compiler_lex_make_all:
compiler_lex_clean:
compiler_clean: compiler_moc_header_clean
####### Compile
main.o: main.cpp function.h \
/usr/include/qt5/QtCore/QObject \
/usr/include/qt5/QtCore/qobject.h \
/usr/include/qt5/QtCore/qobjectdefs.h \
/usr/include/qt5/QtCore/qnamespace.h \
/usr/include/qt5/QtCore/qglobal.h \
/usr/include/qt5/QtCore/qconfig.h \
/usr/include/qt5/QtCore/qfeatures.h \
/usr/include/qt5/QtCore/qsystemdetection.h \
/usr/include/qt5/QtCore/qcompilerdetection.h \
/usr/include/qt5/QtCore/qprocessordetection.h \
/usr/include/qt5/QtCore/qlogging.h \
/usr/include/qt5/QtCore/qflags.h \
/usr/include/qt5/QtCore/qtypeinfo.h \
/usr/include/qt5/QtCore/qtypetraits.h \
/usr/include/qt5/QtCore/qsysinfo.h \
/usr/include/qt5/QtCore/qobjectdefs_impl.h \
/usr/include/qt5/QtCore/qstring.h \
/usr/include/qt5/QtCore/qchar.h \
/usr/include/qt5/QtCore/qbytearray.h \
/usr/include/qt5/QtCore/qrefcount.h \
/usr/include/qt5/QtCore/qatomic.h \
/usr/include/qt5/QtCore/qbasicatomic.h \
/usr/include/qt5/QtCore/qatomic_bootstrap.h \
/usr/include/qt5/QtCore/qgenericatomic.h \
/usr/include/qt5/QtCore/qatomic_msvc.h \
/usr/include/qt5/QtCore/qatomic_integrity.h \
/usr/include/qt5/QtCore/qoldbasicatomic.h \
/usr/include/qt5/QtCore/qatomic_vxworks.h \
/usr/include/qt5/QtCore/qatomic_power.h \
/usr/include/qt5/QtCore/qatomic_aarch64.h \
/usr/include/qt5/QtCore/qatomic_alpha.h \
/usr/include/qt5/QtCore/qatomic_armv7.h \
/usr/include/qt5/QtCore/qatomic_armv6.h \
/usr/include/qt5/QtCore/qatomic_armv5.h \
/usr/include/qt5/QtCore/qatomic_bfin.h \
/usr/include/qt5/QtCore/qatomic_ia64.h \
/usr/include/qt5/QtCore/qatomic_mips.h \
/usr/include/qt5/QtCore/qatomic_s390.h \
/usr/include/qt5/QtCore/qatomic_sh4a.h \
/usr/include/qt5/QtCore/qatomic_sparc.h \
/usr/include/qt5/QtCore/qatomic_x86.h \
/usr/include/qt5/QtCore/qatomic_cxx11.h \
/usr/include/qt5/QtCore/qatomic_gcc.h \
/usr/include/qt5/QtCore/qatomic_unix.h \
/usr/include/qt5/QtCore/qarraydata.h \
/usr/include/qt5/QtCore/qstringbuilder.h \
/usr/include/qt5/QtCore/qlist.h \
/usr/include/qt5/QtCore/qalgorithms.h \
/usr/include/qt5/QtCore/qiterator.h \
/usr/include/qt5/QtCore/qcoreevent.h \
/usr/include/qt5/QtCore/qscopedpointer.h \
/usr/include/qt5/QtCore/qmetatype.h \
/usr/include/qt5/QtCore/qvarlengtharray.h \
/usr/include/qt5/QtCore/qcontainerfwd.h \
/usr/include/qt5/QtCore/qisenum.h \
/usr/include/qt5/QtCore/qobject_impl.h \
function.cpp \
/usr/include/qt5/QtWidgets/QApplication \
/usr/include/qt5/QtWidgets/qapplication.h \
/usr/include/qt5/QtCore/qcoreapplication.h \
/usr/include/qt5/QtCore/qeventloop.h \
/usr/include/qt5/QtGui/qwindowdefs.h \
/usr/include/qt5/QtGui/qwindowdefs_win.h \
/usr/include/qt5/QtCore/qpoint.h \
/usr/include/qt5/QtCore/qsize.h \
/usr/include/qt5/QtGui/qcursor.h \
/usr/include/qt5/QtWidgets/qdesktopwidget.h \
/usr/include/qt5/QtWidgets/qwidget.h \
/usr/include/qt5/QtCore/qmargins.h \
/usr/include/qt5/QtGui/qpaintdevice.h \
/usr/include/qt5/QtCore/qrect.h \
/usr/include/qt5/QtGui/qpalette.h \
/usr/include/qt5/QtGui/qcolor.h \
/usr/include/qt5/QtGui/qrgb.h \
/usr/include/qt5/QtCore/qstringlist.h \
/usr/include/qt5/QtCore/qdatastream.h \
/usr/include/qt5/QtCore/qiodevice.h \
/usr/include/qt5/QtCore/qpair.h \
/usr/include/qt5/QtCore/qregexp.h \
/usr/include/qt5/QtCore/qstringmatcher.h \
/usr/include/qt5/QtGui/qbrush.h \
/usr/include/qt5/QtCore/qvector.h \
/usr/include/qt5/QtGui/qmatrix.h \
/usr/include/qt5/QtGui/qpolygon.h \
/usr/include/qt5/QtGui/qregion.h \
/usr/include/qt5/QtCore/qline.h \
/usr/include/qt5/QtGui/qtransform.h \
/usr/include/qt5/QtGui/qpainterpath.h \
/usr/include/qt5/QtGui/qimage.h \
/usr/include/qt5/QtGui/qpixmap.h \
/usr/include/qt5/QtCore/qsharedpointer.h \
/usr/include/qt5/QtCore/qshareddata.h \
/usr/include/qt5/QtCore/qsharedpointer_impl.h \
/usr/include/qt5/QtCore/qhash.h \
/usr/include/qt5/QtGui/qfont.h \
/usr/include/qt5/QtGui/qfontmetrics.h \
/usr/include/qt5/QtGui/qfontinfo.h \
/usr/include/qt5/QtWidgets/qsizepolicy.h \
/usr/include/qt5/QtGui/qkeysequence.h \
/usr/include/qt5/QtGui/qevent.h \
/usr/include/qt5/QtCore/qvariant.h \
/usr/include/qt5/QtCore/qmap.h \
/usr/include/qt5/QtCore/qdebug.h \
/usr/include/qt5/QtCore/qtextstream.h \
/usr/include/qt5/QtCore/qlocale.h \
/usr/include/qt5/QtCore/qset.h \
/usr/include/qt5/QtCore/qcontiguouscache.h \
/usr/include/qt5/QtCore/qurl.h \
/usr/include/qt5/QtCore/qurlquery.h \
/usr/include/qt5/QtCore/qfile.h \
/usr/include/qt5/QtCore/qfiledevice.h \
/usr/include/qt5/QtGui/qvector2d.h \
/usr/include/qt5/QtGui/qtouchdevice.h \
/usr/include/qt5/QtGui/qguiapplication.h \
/usr/include/qt5/QtGui/qinputmethod.h \
/usr/include/qt5/QtWidgets/QWidget \
/usr/include/qt5/QtWidgets/QGridLayout \
/usr/include/qt5/QtWidgets/qgridlayout.h \
/usr/include/qt5/QtWidgets/qlayout.h \
/usr/include/qt5/QtWidgets/qlayoutitem.h \
/usr/include/qt5/QtWidgets/qboxlayout.h \
/usr/include/qt5/QtWidgets/QSpinBox \
/usr/include/qt5/QtWidgets/qspinbox.h \
/usr/include/qt5/QtWidgets/qabstractspinbox.h \
/usr/include/qt5/QtGui/qvalidator.h \
/usr/include/qt5/QtWidgets/QLabel \
/usr/include/qt5/QtWidgets/qlabel.h \
/usr/include/qt5/QtWidgets/qframe.h \
/usr/include/qt5/QtWidgets/QGraphicsScene \
/usr/include/qt5/QtWidgets/qgraphicsscene.h \
/usr/include/qt5/QtGui/qpen.h \
/usr/include/qt5/QtWidgets/QGraphicsView \
/usr/include/qt5/QtWidgets/qgraphicsview.h \
/usr/include/qt5/QtGui/qpainter.h \
/usr/include/qt5/QtGui/qtextoption.h \
/usr/include/qt5/QtWidgets/qscrollarea.h \
/usr/include/qt5/QtWidgets/qabstractscrollarea.h \
/usr/include/qt5/QtWidgets/QGraphicsPixmapItem \
/usr/include/qt5/QtWidgets/qgraphicsitem.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp
moc_function.o: moc_function.cpp
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_function.o moc_function.cpp
####### Install
install: FORCE
uninstall: FORCE
FORCE:
I found out that all I had to do was include the libraries that i needed into "LIBS" in the Makefile. So this is the solution,at the end of LIBS in the Makefile or at the bottom add the line
`LIBS += pkg-config --libs opencv`
this line can actually be added anywhere in the "Compiler, tools and options" section of the Makefile(refer to the Makefile code posted in the original question).
Additionally, my lack of "namespace" was also an issue!
As clang is trying to tell you, you forgot the openCV namespace.
use either:
cv::Mat cvImage;
or
using namespace cv;
See the documentation.