How to use CuteLogger in a Qt qmake based project, on macOS? - c++

I was able to build the CuteLogger library on macOS with
git clone git#github.com:dept2/CuteLogger.git
debug
mkdir x64d
cd x64d
cmake .. -DCMAKE_TOOLCHAIN_FILE=~/vcpk/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Debug
cmake --build . --config Debug
release
mkdir x64
cd x64
cmake .. -DCMAKE_TOOLCHAIN_FILE=~/vcpk/scripts/buildsystems/vcpkg.cmake -DCMAKE_BUILD_TYPE=Release
cmake --build . --config Release
That led to
x64d/libCuteLogger.dylib ~40M
x64/libCuteLogger.dylib ~33M
which I included in another project, the one which comes in the cutelogger README
#include <QCoreApplication>
#include <Logger.h>
#include <ConsoleAppender.h>
int main(int argc, char* argv[])
{
QCoreApplication app(argc, argv);
ConsoleAppender* consoleAppender = new ConsoleAppender;
consoleAppender->setFormat("[%{type:-7}] <%{Function}> %{message}\n");
cuteLogger->registerAppender(consoleAppender);
LOG_INFO("Starting the application");
int result = app.exec();
if (result)
LOG_WARNING() << "Something went wrong." << "Result code is" << result;
return result;
}
And I build this with qmake
QT -= gui
CONFIG(debug, debug|release) {
d = d
} else {
}
INCLUDEPATH += ../include
LIBS += -L$$PWD/../x64$$d -lCuteLogger
SOURCES += \
main.cpp
mySetOfExtraFiles.files += $$PWD/../x64$$d/libCuteLogger.dylib
mySetOfExtraFiles.path = Contents/Frameworks
QMAKE_BUNDLE_DATA += mySetOfExtraFiles
But running it gives
objc[23564]: Class QMacAutoReleasePoolTracker is implemented in both /Users/user/QtProjects/Cutelogger/x64d/libCuteLogger.dylib (0x1122ae5a0)
and /Users/user/QtProjects/CuteLoggerProject/_x64d/CuteLoggeProject.app/Contents/MacOS/CuteLoggeProject (0x10f0ec0f0). One of the two will be used. Which one is undefined.
objc[23564]: Class QT_ROOT_LEVEL_POOL__THESE_OBJECTS_WILL_BE_RELEASED_WHEN_QAPP_GOES_OUT_OF_SCOPE is implemented in both /Users/user/QtProjects/Cutelogger/x64d/libCuteLogger.dylib (0x1122ae618)
and /Users/user/QtProjects/CuteLoggerProject/_x64d/CuteLoggeProject.app/Contents/MacOS/CuteLoggeProject (0x10f0ec168). One of the two will be used. Which one is undefined.
objc[23564]: Class KeyValueObserver is implemented in both /Users/user/QtProjects/Cutelogger/x64d/libCuteLogger.dylib (0x1122ae640)
and /Users/user/QtProjects/CuteLoggerProject/_x64d/CuteLoggeProject.app/Contents/MacOS/CuteLoggeProject (0x10f0ec190). One of the two will be used. Which one is undefined.
objc[23564]: Class RunLoopModeTracker is implemented in both /Users/user/QtProjects/Cutelogger/x64d/libCuteLogger.dylib (0x1122ae690)
and /Users/user/QtProjects/CuteLoggerProject/_x64d/CuteLoggeProject.app/Contents/MacOS/CuteLoggeProject (0x10f0ec1e0). One of the two will be used. Which one is undefined.
So, what is that Class ... is implemented in both ...?

Related

Trying to build a test with Opencv and QT

Recently build OPENCV 3.4.3 with CMAKE 3.12.4 and MINGW64(32bit) 8.1.0 in Windows 7. Have QT 5.6 and i trying to test this build as QT Console App, but when i compiling with QT only get the message "Press "RETURN" to close this window...".
.PRO file:
CONFIG += c++11
TARGET = test
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
OTHER_FILES += test.png
INCLUDEPATH += C:\Users\Test\Desktop\opencv\build\include
LIBS += C:\Users\Test\Desktop\mingw\bin\libopencv_*.dll
main.cpp:
#include <QCoreApplication>
#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv/cv.h"
using namespace std;
int main(int argc, char *argv[]) {
QCoreApplication a(argc, argv);
cout << "Hello World!" << endl;
cv::Mat mat;
mat = cv::imread("test.png");
cvNamedWindow("hello");
cv::imshow("hello",mat);
return a.exec();
}
What im doing wrong?
Imo the problem is not in your code, I just run it (using Qt5.5, Win10, openCV 4 and mingw64), even if I had to change cvNamedWindow to cv::namedWindow.
I have two hints:
did you build openCV with mingw64? If not, do so.
are the openCV dlls in the path when you run the application? You can also copy all opencv dlls in the program folder to check that quickly...

OpenCV simple code compiles successfully but crashes on runtime

My goal is to run a simple OpenCV contribute (extra) module in Qt 5.5.1.
Steps:
1) created a Qt Application app;
2) changed the main.cpp file to :
#include <QApplication>
#include <opencv2/core/utility.hpp>
#include <opencv2/tracking.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>
#include <cstring>
#include <QDebug>
using namespace std;
using namespace cv;
int main(int argc, char*argv[])
{
qDebug() <<"start!" << endl;
QApplication a(argc, argv);
string trackingAlg = "KCF";
MultiTracker trackers(trackingAlg);
qDebug() <<"success!" << endl;
return a.exec();
}
and here is my .pro file:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = tracker4
CONFIG += c++11
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += /usr/local/include/opencv
LIBS += `pkg-config opencv --libs`
LIBS += -L/usr/local/lib -lopencv_core -lopencv_imgcodecs -lopencv_highgui -lopencv_videoio -lopencv_tracking
The program compiles successfully, but in the runtime, it crashes without even running the main() function. I don't get such an error when I run this in Code::Blocks but in Qt I still have this issue.
I am using Qt 5.5.1 and Ubuntu 14.04.
Can anyone generate this "seg fault" error in his/her machine?
For QT 5, build the OpenCV with QT=OFF.
For QT 4, build the OpenCV with QT=ON.

Segmentation Fault (Core dumped) Wt With Qt helloqt

I Wrote before but the details was not explained.
I explain step by step what I do;
Witty installation Guide Ubuntu
I did in order what ever said in this page.
sudo apt-get install gcc g++ libboost-all-dev cmake make
sudo apt-get install libssl-dev libfcgi-dev
sudo apt-get install libpq-dev libmysqlclient-dev firebird-dev
sudo apt-get install libpng12-dev libgraphicsmagick1-dev libhpdf-dev libpng12-dev libpango1.0-dev mesa-common-dev
sudo apt-get install asciidoc libqt4-dev
sudo apt-get install doxygen graphviz
wget -c http://kent.dl.sourceforge.net/sourceforge/witty/wt-3.3.4.tar.gz
tar xvxf wt-3.3.4.tar.gz
cd wt-3.3.4
mkdir build
cd build
cmake ..
make
make -C examples
and Test helloqt.wt test
./helloqt.wt --http-port 10000 --http-addr 0.0.0.0 --docroot .
Every things work fine
and then I changed someline for Qt events loop working
// Needed when using WQApplication with Qt eventloop = true
#include <QApplication>
Dictionary::Dictionary(const WEnvironment& env)
: WQApplication(env , true )
{
/*
* Note: do not create any Qt objects from here. Initialize your
* application from within the virtual create() method.
*/
}
.
.
.
int main(int argc, char **argv)
{
// Needed for Qt's eventloop threads to work
QApplication app(argc, argv);
return WRun(argc, argv, &createApplication);
}
still result is fine everything OK. eventloops( signal/slot working )
and I clean everything with
make clean
add line to cmakefiles.txt QtNetwork
.
.
.
IF(ENABLE_QT4)
FIND_PACKAGE(Qt4 REQUIRED QtCore QtGui QtNetwork)
IF(QT_FOUND)
INCLUDE(${QT_USE_FILE})
ENDIF(QT_FOUND)
ENDIF(ENABLE_QT4)
.
.
.
and also add to wtwithqt examples cmakelist.txt ${QT_QTNETWORK_LIBRARY}
FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui QtNetwork )
SET(QT_USE_QTNETWORK true)
INCLUDE(${QT_USE_FILE})
to below
IF(COMMAND cmake_policy)
CMAKE_POLICY(SET CMP0003 NEW)
ENDIF(COMMAND cmake_policy)
SET(BUILD_WTWITHQT true)
IF (NOT MULTI_THREADED_BUILD)
SET(BUILD_WTWITHQT false)
ENDIF (NOT MULTI_THREADED_BUILD)
IF (NOT QT_FOUND)
SET(BUILD_WTWITHQT false)
ENDIF (NOT QT_FOUND)
IF (NOT BUILD_WTWITHQT)
MESSAGE(STATUS "** Not building wtwithqt example.")
MESSAGE(STATUS " wtwithqt example requires a Qt4 installation.")
ELSE (NOT BUILD_WTWITHQT)
MESSAGE("\n\n " + ${QT_QTCORE_LIBRARY} + " \n" + ${QT_QTGUI_LIBRARY} + "\n" + ${QT_QTNETWORK_LIBRARY} + "\n" + ${QT_LIBRARIES} + "\n\n" )
FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui QtNetwork )
SET(QT_USE_QTNETWORK true)
INCLUDE(${QT_USE_FILE})
SUBDIRS(lib)
ADD_DEFINITIONS(-DWT_NO_SLOT_MACROS)
QT4_GENERATE_MOC(${CMAKE_CURRENT_SOURCE_DIR}/QtObject.h
${CMAKE_CURRENT_BINARY_DIR}/moccedQtObject.C)
WT_ADD_EXAMPLE(helloqt.wt
hello.C
QtObject.C
${CMAKE_CURRENT_BINARY_DIR}/moccedQtObject.C
)
TARGET_LINK_LIBRARIES(helloqt.wt
wtwithqt
${QT_QTCORE_LIBRARY}
${QT_QTGUI_LIBRARY}
${QT_QTNETWORK_LIBRARY}
${QT_LIBRARIES}
)
#
# If you have Wt installed somehwere, you should use the
# installed Wt header files for your own Wt projects.
# e.g. INCLUDE_DIRECTORIES(/usr/local/wt/include)
# instead of the following:
#
INCLUDE_DIRECTORIES(
${WT_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR}/lib
${QT_QTCORE_INCLUDE_DIR}
${QT_QTNETWORK_INCLUDE_DIR}
${QT_INCLUDE_DIR}
)
ENDIF (NOT BUILD_WTWITHQT)
and add to QTcpSocket to function below
QtObject.h
// This may look like C code, but it's really -- C++ --
#ifndef QTOBJECT_H_
#define QTOBJECT_H_
#include <QThread>
#include <QTcpSocket>
class Dictionary;
/*! \class QtObject
* \brief A simple Qt object with sample signal and slot.
*
* This simple object class demonstrates that the Qt signal/slot
* mechanism may be used alonglisde Wt's signal/slot mechanism.
*/
class QtObject : public QObject
{
Q_OBJECT;
public:
QtObject(Dictionary *wt_, QObject *parent = 0);
void passGreet(const QString&);
QTcpSocket* socket;
signals:
void greet(const QString&);
public slots:
void doGreet(const QString&);
void Connected();
private:
Dictionary *wt_;
};
#endif // QTOBJECT_H_
QtObject.C file
#include "HelloApplication.h"
#include "QtObject.h"
#include <QHostAddress>
QtObject::QtObject(Dictionary *wt, QObject *parent)
: QObject(parent),
wt_(wt)
{
socket = new QTcpSocket();
QHostAddress adr;
adr.setAddress("192.168.0.2");
socket->connectToHost(adr,17776);
QObject::connect(socket,SIGNAL(connected()),this,SLOT(Connected()));
}
void QtObject::passGreet(const QString& name)
{
emit greet(name);
}
void QtObject::doGreet(const QString& name)
{
wt_->doGreet(name);
}
void QtObject::Connected(){
std::cout << "\n\nCONNNECTED\n\n";
emit greet(QString("QString"));
}
From this time
cml#cml-All-Series:~/wt-3.3.4/build$ make clean
cml#cml-All-Series:~/wt-3.3.4/build$ cmake ..
cml#cml-All-Series:~/wt-3.3.4/build$ make -j8
cml#cml-All-Series:~/wt-3.3.4/build$ make -C examples/wtwithqt
cml#cml-All-Series:~/wt-3.3.4/build/examples/wtwithqt$ ./helloqt.wt charts.wt --http-port 10000 --http-addr 0.0.0.0 --docroot .
[2015-Aug-22 10:34:04.692004] 3116 - [info] "WServer/wthttp: initializing built-in wthttpd"
[2015-Aug-22 10:34:04.693292] 3116 - [info] "wthttp: started server: http://0.0.0.0:10000"
when click on browser 0.0.0.0:10000
page is incoming and
socket emitting Connected() signals and Connected() SLOT Work
print screen to std::cout << "\n\nCONNNECTED\n\n";
and application
crashed. Segmentation fault and Core Dumped
I can not find what is wrong?
I Debug Qt Creator
WWebWidget.C file stopped there
bool WWebWidget::canOptimizeUpdates()
{
-> return WApplication::instance()->session()->renderer().preLearning();
}
Qt Creator Debugger says ->
The inferior stopped because it received a signal from the Operating System.
Signal name :
SIGSEGV
Signal meaning :
Segmentation fault
There talking about the solution
in my code I delete WText object after there is no fail seg fault...
this is not solution for me but I can use it
Wt::WApplication* app = Wt::WApplication::instance();
app->enableUpdates(true);
Wt::WApplication::UpdateLock uilock(app);
if( uilock ){
button->setText("Test"); //Here is Editable Widget
app->trigerUpdate();
app->enableUpdates(false);
}
For a big work you lock application and
control if locked change any thing
ServerPUSH.c

Can't debug cpp code under Qt Creator when linking with CUDA libs

I have a problem with debugging a simple cpp code (it call some CUDA functions like cuInit(), cuDeviceGetCount()..). When I put a break point into the CPP code and start debugging I get this message:
This does not seem to be a "Debug" build.
When I remove all CUDA-calls and do not link the program against the cuda.lib and cudart.lib then the code is debuggable (it is possible to stop the program at the breakpoint and no error message is displayed).
Here is my CPP code:
#include <QtCore/QCoreApplication>
#include <QDebug>
#include <cuda.h>
#include <builtin_types.h>
int main(int argc, char* argv [])
{
QCoreApplication(argc, argv);
int deviceCount = 0;
int cudaDevice = 0;
char cudaDeviceName [100];
cuInit(0);
cuDeviceGetCount(&deviceCount);
cuDeviceGet(&cudaDevice, 0);
cuDeviceGetName(cudaDeviceName, 100, cudaDevice);
qDebug() << "Number of devices: " << deviceCount;
qDebug() << "Device name:" << cudaDeviceName;
}
Here is my .pro file:
QT += core
QT -= gui
TARGET = cudatest
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
#################################
# Begin CUDA configuration
win32 {
CUDA_PATH = "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v6.5"
CUDA_INC_DIR = $$CUDA_PATH/include
contains(QMAKE_TARGET.arch, x86_64) {
SYSTEMNAME = x64
SYSTEMTYPE = 64
} else {
SYSTEMNAME = Win32
SYSTEMTYPE = 32
}
CUDA_LIB_DIR = $$CUDA_PATH/lib/$$SYSTEMNAME
QMAKE_CXXFLAGS_RELEASE -= -MD
QMAKE_CXXFLAGS_RELEASE += -MT
QMAKE_CXXFLAGS_DEBUG -= -MDd
QMAKE_CXXFLAGS_DEBUG += -MTd
}
INCLUDEPATH += $$CUDA_INC_DIR
LIBS += -L$$CUDA_LIB_DIR -lcuda -lcudart
#End CUDA configuration
########################
Environment:
Qt Creator 3.2.2
CUDA v6.5
CPP Compiler: VC++ 2013 Express
Debugger: C:\Program Files (x86)\Windows Kits\8.1\Debuggers\x86\cdb.exe
Qt 5.3.2 (compiled by VC++ 2013, 32bit)
I tried to do the same with VC++ 2010 Proffesional with the same result.
Can anyone give me a suggestion where could be the problem?
Thank you.
its probably because you are using Visual Express 2013. It says here that there is no compiler support for VS 2013 Express for CUDA v6.5(Under the Table 2. Windows Compiler Support in CUDA 6.5) You need to install the complete version of Visual Studio.

libjpegTurbo: libjpeg-62 File not recognized

I tried to use libjpeg-turbo with qt.
I downloaded libjpeg-turbo and installed. I wanted to use it within a project but I got the following fault:
C:\libjpeg-turbo-gcc64\bin\libjpeg-62.dll:-1: Error: file not
recognized: File format not recognized
As soon as I removed the libjpeg-62.dll I received the following fault:
C:\test\main.cpp:8: Error: undefined reference to
`tjInitCompress'
Why is the libjpeg-62 not recognizing the file format?
Thanks for help,
Willy
PS. Here is the code:
test.pro
QT += core
QT -= gui
TARGET = test
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += C:\libjpeg-turbo-gcc64\include
LIBS += -LC:\libjpeg-turbo-gcc64\bin -llibjpeg-62
main.cpp
#include <QCoreApplication>
#include <turbojpeg.h>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
tjhandle _jpegCompressor = tjInitCompress();
return a.exec();
}
Ok now it works,
it was the wrong version of libjpeg-turbo. Now I use the libjpeg-turbo-gcc and not the libjpeg-turbo-gcc64. Also i change the Libs-Path to
LIBS += "C://libjpeg-turbo-gcc64//bin//libjpeg-62.dll"
MfG Willy