VL_feat Matlab GCC can't compile [duplicate] - c++

This question already has an answer here:
mex compilation error C2440: 'initializing': cannot convert from 'const mwSize *' to 'const int32_t *'
(1 answer)
Closed 6 months ago.
I was trying to compile the function c_eoverlap in matlab following the instruction here:
http://www.robots.ox.ac.uk/~vgg/research/affine/evaluation.html#eval_soft
Of course, it wouldn't work out... My Matlab version is 2018a which is pretty new and the gcc -v outputs the following
Also attach this long error log, as I am pretty new to C++, please let me know if there is any other information needed, appreciate for your help!
>> mex repeatability/c_eoverlap.cxx
Building with 'Xcode Clang++'.
Error using mex
/Users/lucius/Desktop/ua/805/a1/repeatability/c_eoverlap.cxx:34:14: error: cannot initialize
a variable of type 'const int *' with an rvalue of type 'const mwSize *' (aka 'const unsigned
long *')
int const *dims1 = mxGetDimensions(prhs[0]);
^ ~~~~~~~~~~~~~~~~~~~~~~~~
/Users/lucius/Desktop/ua/805/a1/repeatability/c_eoverlap.cxx:36:14: error: cannot initialize
a variable of type 'const int *' with an rvalue of type 'const mwSize *' (aka 'const unsigned
long *')
int const *dims2 = mxGetDimensions(prhs[1]);
^ ~~~~~~~~~~~~~~~~~~~~~~~~
/Users/lucius/Desktop/ua/805/a1/repeatability/c_eoverlap.cxx:38:14: error: cannot initialize
a variable of type 'const int *' with an rvalue of type 'const mwSize *' (aka 'const unsigned
long *')
int const *dims3 = mxGetDimensions(prhs[2]);
^ ~~~~~~~~~~~~~~~~~~~~~~~~
/Users/lucius/Desktop/ua/805/a1/repeatability/c_eoverlap.cxx:46:13: error: no matching
function for call to 'mxCreateNumericArray_730'
plhs[0] = mxCreateNumericArray(2, odim, mxDOUBLE_CLASS, mxREAL);
^~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:282:30: note: expanded from macro
'mxCreateNumericArray'
#define mxCreateNumericArray mxCreateNumericArray_730
^~~~~~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:1256:1: note: candidate function not
viable: no known conversion from 'int *' to 'const mwSize *' (aka 'const unsigned long *')
for 2nd argument
mxCreateNumericArray(mwSize ndim, const mwSize *dims, mxClassID classid, mxComplexity flag);
^
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:282:30: note: expanded from macro
'mxCreateNumericArray'
#define mxCreateNumericArray mxCreateNumericArray_730
^
/Users/lucius/Desktop/ua/805/a1/repeatability/c_eoverlap.cxx:47:13: error: no matching
function for call to 'mxCreateNumericArray_730'
plhs[1] = mxCreateNumericArray(2, odim, mxDOUBLE_CLASS, mxREAL);
^~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:282:30: note: expanded from macro
'mxCreateNumericArray'
#define mxCreateNumericArray mxCreateNumericArray_730
^~~~~~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:1256:1: note: candidate function not
viable: no known conversion from 'int *' to 'const mwSize *' (aka 'const unsigned long *')
for 2nd argument
mxCreateNumericArray(mwSize ndim, const mwSize *dims, mxClassID classid, mxComplexity flag);
^
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:282:30: note: expanded from macro
'mxCreateNumericArray'
#define mxCreateNumericArray mxCreateNumericArray_730
^
/Users/lucius/Desktop/ua/805/a1/repeatability/c_eoverlap.cxx:48:13: error: no matching
function for call to 'mxCreateNumericArray_730'
plhs[2] = mxCreateNumericArray(2, odim, mxDOUBLE_CLASS, mxREAL);
^~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:282:30: note: expanded from macro
'mxCreateNumericArray'
#define mxCreateNumericArray mxCreateNumericArray_730
^~~~~~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:1256:1: note: candidate function not
viable: no known conversion from 'int *' to 'const mwSize *' (aka 'const unsigned long *')
for 2nd argument
mxCreateNumericArray(mwSize ndim, const mwSize *dims, mxClassID classid, mxComplexity flag);
^
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:282:30: note: expanded from macro
'mxCreateNumericArray'
#define mxCreateNumericArray mxCreateNumericArray_730
^
/Users/lucius/Desktop/ua/805/a1/repeatability/c_eoverlap.cxx:49:13: error: no matching
function for call to 'mxCreateNumericArray_730'
plhs[3] = mxCreateNumericArray(2, odim, mxDOUBLE_CLASS, mxREAL);
^~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:282:30: note: expanded from macro
'mxCreateNumericArray'
#define mxCreateNumericArray mxCreateNumericArray_730
^~~~~~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:1256:1: note: candidate function not
viable: no known conversion from 'int *' to 'const mwSize *' (aka 'const unsigned long *')
for 2nd argument
mxCreateNumericArray(mwSize ndim, const mwSize *dims, mxClassID classid, mxComplexity flag);
^
/Applications/MATLAB_R2018a.app/extern/include/matrix.h:282:30: note: expanded from macro
'mxCreateNumericArray'
#define mxCreateNumericArray mxCreateNumericArray_730
^
/Users/lucius/Desktop/ua/805/a1/repeatability/c_eoverlap.cxx:198:3: warning: 'delete[]'
applied to a pointer that was allocated with 'new'; did you mean 'delete'?
[-Wmismatched-new-delete]
delete []tdesc_out;
^ ~~~
/Users/lucius/Desktop/ua/805/a1/repeatability/c_eoverlap.cxx:62:22: note: allocated with
'new' here
float *tdesc_out = new float[dims2[1]*dims1[1]];
^
/Users/lucius/Desktop/ua/805/a1/repeatability/c_eoverlap.cxx:199:3: warning: 'delete[]'
applied to a pointer that was allocated with 'new'; did you mean 'delete'?
[-Wmismatched-new-delete]
delete []tover_out;
^ ~~~
/Users/lucius/Desktop/ua/805/a1/repeatability/c_eoverlap.cxx:63:22: note: allocated with
'new' here
float *tover_out = new float[dims2[1]*dims1[1]];
^
2 warnings and 7 errors generated.

You need to add -compatibleArrayDims to your mex command:
mex -compatibleArrayDims c_eoverlap.cxx
The code is written for older MATLABs that used 32-bit integers (int) for array sizes. Nowadays these are 64-bits (mwSize). This option forces the interface to work like it did in the older MATLABs. See the mex documentation for details.
There are some scary warnings about using delete[] instead of delete. It's just warnings, so it will compile, but you don't know if the code will do what it is supposed to.

Related

using the correct to_chars overload

I'm using Clang 14 (on Apple M1), which has full support for C++ 17, and I'm trying to utilize the new to_chars function. Here's my very simple test file:
#include <charconv>
#include <iostream>
int main() {
char a[10];
double pi = 3.141592;
std::to_chars_result res = std::to_chars(a, a+10, pi);
*res.ptr = '\0';
std::cout << a << std::endl;
}
My compile command is clang -std=c++17 test_to_chars.cpp, and the output is below:
test_to_chars.cpp:8:30: error: call to deleted function 'to_chars'
std::to_chars_result res = std::to_chars(a, a+10, pi);
^~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/charconv:166:6: note: candidate function has been explicitly deleted
void to_chars(char*, char*, bool, int = 10) = delete;
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/charconv:450:1: note: candidate template ignored: requirement 'is_integral<double>::value' was not satisfied [with _Tp = double]
to_chars(char* __first, char* __last, _Tp __value)
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/charconv:458:1: note: candidate function template not viable: requires 4 arguments, but 3 were provided
to_chars(char* __first, char* __last, _Tp __value, int __base)
^
test_to_chars.cpp:8:24: error: no viable conversion from 'void' to 'std::to_chars_result'
std::to_chars_result res = std::to_chars(a, a+10, pi);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/charconv:154:25: note: candidate constructor (the implicit copy constructor) not viable: cannot convert argument of incomplete type 'void' to 'const std::to_chars_result &' for 1st argument
struct _LIBCPP_TYPE_VIS to_chars_result
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/charconv:154:25: note: candidate constructor (the implicit move constructor) not viable: cannot convert argument of incomplete type 'void' to 'std::to_chars_result &&' for 1st argument
2 errors generated.
I'm calling to_chars(char*, char*, double) but for some reason it's using an implicit conversion and trying to call to_chars(char*, char*, bool, int = 10) instead, which is a deleted function.
Is there a way for me to tell C++ that I don't want it to convert my double parameter to a bool?
I'm using Clang 14 (on Apple M1), which has full support for C++ 17
This is unfortunately not correct. While the compiler itself has full C++17 support, the stdlib of your clang version (Apple clang 14) does not implement any floating point charconv features.
See the entry "Elementary string conversions" in the cppreference table.
It is important to note that you are not running "clang 14", but "Apple clang 14". Your code snippet compiles just fine on normal clang 14.

Error: 'argument' does not name a type, supposed problems with .cpp and .h files

I read about this issue (seems quite common) for hours without finding any applicable solution to my situation. I understand that there might be a problem related to the included files and libraries, but I'm not actually able to find what's wrong.
It's an Arduino script that uses the MQTT client library. It works beautifully with the old PubSubClient.h lib.
Now I wanted to update the lib with a recent one. The function definitions are changed so I made the changes in the sketch and switched the lib in the Arduino/library directory, then restarted the Arduino IDE. I get lot of "error: 'argument' does not name a type" and I really don't know what to fix.
Here you can find the .h and .cpp files organization to understand what's happening.
//device.ino file
#include "device.h"
//device.h file
#ifndef DEVICE_H
#define DEVICE_H
#include <WiFiClient.h>
#include <WiFiClientSecure.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <ESP8266HTTPUpdateServer.h>
#include <PubSubClient.h>
#include <ArduinoJson.h>
#include <jsmn.h>
#include <Arduino.h>
#include <pgmspace.h>
#include "mqtt.h"
#endif
mqtt.h file
#ifndef MQTT_H
#define MQTT_H
#include "device.h"
#endif
mqtt.cpp file
#include "mqtt.h"
WiFiClient wifi_client;
PubSubClient mqtt_client(wifi_client);
mqtt_client.setServer(mqtt_server, MQTT_BROKER_PORT);
mqtt_client.setCallback(mqtt_callback);
Finally the errors the compiler throws out:
mqtt.cpp:19: error:
'mqtt_client' does not name a type
mqtt_client.setServer(mqtt_server, MQTT_BROKER_PORT);
^
mqtt.cpp:20: error: 'mqtt_client' does not name a type
mqtt_client.setCallback(mqtt_callback);
^
sketch\mqtt.cpp: In function 'void mqtt_publish_mex(String, String, bool)':
mqtt.cpp:27: error: no matching function for call to 'PubSubClient::publish(String&, String&, bool&)'
if (mqtt_client.publish(topic, jmex, retained)) {
^
sketch\mqtt.cpp:27:54: note: candidates are:
In file included from sketch\Walvola.h:25:0,
from sketch\mqtt.h:4,
from sketch\mqtt.cpp:1:
C:\Users\Fabrizio & Dario\Documents\Arduino\libraries\pubsubclient\src/PubSubClient.h:130:12: note: boolean PubSubClient::publish(const char*, const char*)
boolean publish(const char* topic, const char* payload);
^
C:\Users\Fabrizio & Dario\Documents\Arduino\libraries\pubsubclient\src/PubSubClient.h:130:12: note: candidate expects 2 arguments, 3 provided
C:\Users\Fabrizio & Dario\Documents\Arduino\libraries\pubsubclient\src/PubSubClient.h:131:12: note: boolean PubSubClient::publish(const char*, const char*, boolean)
boolean publish(const char* topic, const char* payload, boolean retained);
^
C:\Users\Fabrizio & Dario\Documents\Arduino\libraries\pubsubclient\src/PubSubClient.h:131:12: note: no known conversion for argument 1 from 'String' to 'const char*'
C:\Users\Fabrizio & Dario\Documents\Arduino\libraries\pubsubclient\src/PubSubClient.h:132:12: note: boolean PubSubClient::publish(const char*, const uint8_t*, unsigned int)
boolean publish(const char* topic, const uint8_t * payload, unsigned int plength);
^
C:\Users\Fabrizio & Dario\Documents\Arduino\libraries\pubsubclient\src/PubSubClient.h:132:12: note: no known conversion for argument 1 from 'String' to 'const char*'
C:\Users\Fabrizio & Dario\Documents\Arduino\libraries\pubsubclient\src/PubSubClient.h:133:12: note: boolean PubSubClient::publish(const char*, const uint8_t*, unsigned int, boolean)
boolean publish(const char* topic, const uint8_t * payload, unsigned int plength, boolean retained);
^
C:\Users\Fabrizio & Dario\Documents\Arduino\libraries\pubsubclient\src/PubSubClient.h:133:12: note: candidate expects 4 arguments, 3 provided
sketch\mqtt.cpp: In function 'void mqtt_log(String)':
mqtt.cpp:347: error: no matching function for call to 'PubSubClient::publish(const String&, String&)'
mqtt_client.publish(mqtt_controllers_topic_debug, json_string);
^
sketch\mqtt.cpp:347:70: note: candidates are:
In file included from sketch\Walvola.h:25:0,
from sketch\mqtt.h:4,
from sketch\mqtt.cpp:1:
C:\Users\Fabrizio & Dario\Documents\Arduino\libraries\pubsubclient\src/PubSubClient.h:130:12: note: boolean PubSubClient::publish(const char*, const char*)
boolean publish(const char* topic, const char* payload);
^
C:\Users\Fabrizio & Dario\Documents\Arduino\libraries\pubsubclient\src/PubSubClient.h:130:12: note: no known conversion for argument 1 from 'const String' to 'const char*'
C:\Users\Fabrizio & Dario\Documents\Arduino\libraries\pubsubclient\src/PubSubClient.h:131:12: note: boolean PubSubClient::publish(const char*, const char*, boolean)
boolean publish(const char* topic, const char* payload, boolean retained);
^
C:\Users\Fabrizio & Dario\Documents\Arduino\libraries\pubsubclient\src/PubSubClient.h:131:12: note: candidate expects 3 arguments, 2 provided
C:\Users\Fabrizio & Dario\Documents\Arduino\libraries\pubsubclient\src/PubSubClient.h:132:12: note: boolean PubSubClient::publish(const char*, const uint8_t*, unsigned int)
boolean publish(const char* topic, const uint8_t * payload, unsigned int plength);
^
C:\Users\Fabrizio & Dario\Documents\Arduino\libraries\pubsubclient\src/PubSubClient.h:132:12: note: candidate expects 3 arguments, 2 provided
C:\Users\Fabrizio & Dario\Documents\Arduino\libraries\pubsubclient\src/PubSubClient.h:133:12: note: boolean PubSubClient::publish(const char*, const uint8_t*, unsigned int, boolean)
boolean publish(const char* topic, const uint8_t * payload, unsigned int plength, boolean retained);
^
C:\Users\Fabrizio & Dario\Documents\Arduino\libraries\pubsubclient\src/PubSubClient.h:133:12: note: candidate expects 4 arguments, 2 provided
In file included from sketch\mqtt.h:4:0,
from sketch\mqtt.cpp:1:
sketch\mqtt.cpp: In function 'void mqtt_callback(char*, byte*, unsigned int)':
mqtt.cpp:375: error: request for member 'payload_string' in 'payload', which is of non-class type 'byte* {aka unsigned char*}'
log(payload.payload_string());
^
sketch\Walvola.h:89:67: note: in definition of macro 'log'
#define log(mex) if (DEBUG) {Serial.println(walvola_time + "::" + mex);Serial.flush(); if(MQTT_DEBUG) {mqtt_log(walvola_time + "::" + mex);}}
^
mqtt.cpp:375: error: request for member 'payload_string' in 'payload', which is of non-class type 'byte* {aka unsigned char*}'
log(payload.payload_string());
^
sketch\Walvola.h:89:135: note: in definition of macro 'log'
#define log(mex) if (DEBUG) {Serial.println(walvola_time + "::" + mex);Serial.flush(); if(MQTT_DEBUG) {mqtt_log(walvola_time + "::" + mex);}}
^
mqtt.cpp:379: error: request for member 'payload_string' in 'payload', which is of non-class type 'byte* {aka unsigned char*}'
if (mqtt2JSONkvs(payload.payload_string())) {
^
mqtt.cpp:404: error: a function-definition is not allowed here before '{' token
{
^
mqtt.cpp:512: error: expected '}' at end of input
}
^
PiĆ¹ di una libreria trovata per "WiFiClient.h"
Usata: C:\Users\Fabrizio & Dario\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi
Non usata: C:\Program Files (x86)\Arduino\libraries\WiFi
Non usata: C:\Program Files (x86)\Arduino\libraries\WiFi
Non usata: C:\Program Files (x86)\Arduino\libraries\WiFi
Non usata: C:\Program Files (x86)\Arduino\libraries\WiFi
exit status 1
'mqtt_client' does not name a type
Thanks for the help!
when writing
WiFiClient wifi_client;
PubSubClient mqtt_client(wifi_client);
mqtt_client.setServer(mqtt_server, MQTT_BROKER_PORT);
mqtt_client.setCallback(mqtt_callback);
the first two lines are quite ok => you are declaring global variables named wifi_client and mqtt_client
The problem comes with the calls
mqtt_client.setServer(mqtt_server, MQTT_BROKER_PORT);
mqtt_client.setCallback(mqtt_callback);
You can declare variables at global scope, but you cannot call functions outside a function (unless is for a global variable initialization), this is why you get this error. The example you point is different as the variables are in a function, thus calling methodes on them just after is legal: you are in a function context.
So you need to move your calls in the main() function, for example, so that the code gets valid.
That said, putting global variables in the header could make you more trouble is you include you file from different cpp files, the compiler will complain about multiple definitions, but that is not (yet) the question here.

Conversion of const size_t in mex

I tried to use the yaafe library from http://yaafe.sourceforge.net/manual/install.html. Everything is installed and works fine. However I would like to use the matlab interface and I tried to compile the yaafemex.cpp provided using the following command mex yaafemex.cpp but I have this error on Matlab
Building with 'Xcode Clang++'.
Error using mex
/Users/TMAC/Documents/MATLAB/Add-Ons/Collections/Yaafe/yaafemex.cpp:107:22: error: no matching function for call
to 'mxCreateNumericArray_730'
mxArray* featdata = mxCreateNumericArray(2,dims,mxDOUBLE_CLASS,mxREAL);
^~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2017a.app/extern/include/matrix.h:1111:30: note: expanded from macro 'mxCreateNumericArray'
#define mxCreateNumericArray mxCreateNumericArray_730
^~~~~~~~~~~~~~~~~~~~~~~~
/Applications/MATLAB_R2017a.app/extern/include/matrix.h:782:1: note: candidate function not viable: no known conversion
from 'int [2]' to 'const size_t *' (aka 'const unsigned long *') for 2nd argument
mxCreateNumericArray_730(size_t ndim, const size_t *dims, mxClassID classid, mxComplexity flag);
^
1 error generated.
Portions of code (I haven't changed the intitial code provided by yaafe library)
yaafemex.cpp
/* write data */
int dims[2] = {buf->info().size , buf->availableTokens()};
mxArray* featdata = mxCreateNumericArray(2,dims,mxDOUBLE_CLASS,mxREAL); //line 107
double* featdataPtr = (double*) mxGetData(featdata);
buf->read(featdataPtr,buf->availableTokens());
buf->consumeTokens(buf->availableTokens());
mxSetField(feat,0,"data",featdata);
matrix.h
/*
* Create a numeric array and initialize all its data elements to 0.
*
* Similar to mxCreateNumericMatrix, in a standalone application,
* out-of-memory will mean a NULL pointer is returned.
*/
LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *
mxCreateNumericArray_730(size_t ndim, const size_t *dims, mxClassID classid, mxComplexity flag); //line 782
LIBMMWMATRIX_PUBLISHED_API_EXTERN_C mxArray *
mxCreateNumericArray_700(int ndim, const int *dims, mxClassID classid, mxComplexity flag);
int dims[2] = {buf->info().size , buf->availableTokens()};
Is signed, mxCreateNumericArray expects const size_t *, which is an unsigned numeric type. You either need to explicitly cast dims or define dims with the appropriate type.
Concretely, I'd edit the definition of dims in yaafe as follows:
size_t dims[2] = {static_cast<size_t>(buf->info().size) , static_cast<size_t>(buf->availableTokens())};

Error compiling Nana example (nana v1.1.2/1.1.3) with gcc 4.8.4/clang3.4

I tried the latest nana (1.1.2/1.1.3) downloaded from Github. The library compiles fine. When I try to compile and link any sample program, with linux (gcc 4.8.4, clang 3.4) I get the following errors:
enter In file included from /installs/nana/include/nana/gui/wvl.hpp:20:
In file included from /installs/nana/include/nana/gui/widgets/form.hpp:16:
In file included from /installs/nana/include/nana/gui/widgets/widget.hpp:17:
/installs/nana/include/nana/internationalization.hpp:69:7: error: invalid operands to binary expression ('std::wstringstream' (aka 'basic_stringstream<wchar_t>') and 'nana::string' (aka 'basic_string<char>'))
ss << nana::string(nana::charset(arg));
~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8 /system_error:186:5: note: candidate function [with _CharT = wchar_t, _Traits = std::char_traits<wchar_t>] not viable: no known conversion from 'nana::string' (aka 'basic_string<char>') to 'const std::error_code' for 2nd argument
operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e)
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/ostream:108:7: note: candidate function not viable: no known conversion from 'nana::string' (aka 'basic_string<char>') to '__ostream_type &(*)(__ostream_type &)' for 1st argument
operator<<(__ostream_type& (*__pf)(__ostream_type&))
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/ostream:117:7: note: candidate function not viable: no known conversion from 'nana::string' (aka 'basic_string<char>') to '__ios_type &(*)(__ios_type &)' for 1st argument
operator<<(__ios_type& (*__pf)(__ios_type&))
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/ostream:127:7: note: candidate function not viable: no known conversion from 'nana::string' (aka 'basic_string<char>') to 'std::ios_base &(*)(std::ios_base &)' for 1st argument
operator<<(ios_base& (*__pf) (ios_base&))
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/ostream:166:7: note: candidate function not viable: no known conversion from 'nana::string' (aka 'basic_string<char>') to 'long' for 1st argument
operator<<(long __n)
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/ostream:170:7: note: candidate function not viable: no known conversion from 'nana::string' (aka 'basic_string<char>') to 'unsigned long' for 1st argument
operator<<(unsigned long __n)
^
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/ostream:174:7: note: candidate function not viable: no known conversion from 'nana::string' (aka 'basic_string<char>') to 'bool' for 1st argument
operator<<(bool __n)here
CMAKE:
cmake_minimum_required(VERSION 3.2)
project(nana_ui)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11
-DSTD_CODECVT_NOT_SUPPORTED")
SET(NANA_BASE "/installs/nana")
include_directories(${NANA_BASE}/include
/usr/include/freetype2)
link_directories(${NANA_BASE}/lib)
set(SOURCE_FILES main.cpp)
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} ${NANA_BASE}/lib/libnana.a
X11 pthread rt Xft png asound)
Example cpp:
#include <nana/gui.hpp>
#include <nana/gui/widgets/label.hpp>
int main()
{
using namespace nana;
form fm;
label lb(fm, fm.size());
lb.caption(L"Hello, World");
fm.show();
exec();
}
Any Help is appreciated.
Adding #define NANA_UNICODE in config.hpp, then recompile the library and examples

Qt - getting the current date in mmmm YYYY format (as a string)

I'm trying to retrieve the current date as a string in mmmm YYYY format with QDate. However, I can't pass QDate::currentDate with an argument. Another problem is the fact that the function argument I am passing this in is QString, meaning that g++ throws conversion errors. How can get around this?
Here the code at the moment:
QDate date = QDate::currentDate();
Core::MessageUser(this->CurrentEdit->User, warning, QString::number(date),
title, true, dependency);
The compiler error I am constantly getting whatever I do is this:
mainwindow.cpp: In member function 'bool Huggle::MainWindow::Warn(QString, Huggle::RevertQuery*)':
mainwindow.cpp:463:77: error: no matching function for call to 'QString::number(QDate&)'
Core::MessageUser(this->CurrentEdit->User, warning, QString::number(date),
^
mainwindow.cpp:463:77: note: candidates are:
In file included from /usr/include/qt5/QtCore/qobject.h:48:0,
from /usr/include/qt5/QtWidgets/qwidget.h:46,
from /usr/include/qt5/QtWidgets/qmainwindow.h:45,
from /usr/include/qt5/QtWidgets/QMainWindow:1,
from mainwindow.h:14,
from mainwindow.cpp:11:
/usr/include/qt5/QtCore/qstring.h:556:20: note: static QString QString::number(int, int)
static QString number(int, int base=10);
^
/usr/include/qt5/QtCore/qstring.h:556:20: note: no known conversion for argument 1 from 'QDate' to 'int'
/usr/include/qt5/QtCore/qstring.h:557:20: note: static QString QString::number(uint, int)
static QString number(uint, int base=10);
^
/usr/include/qt5/QtCore/qstring.h:557:20: note: no known conversion for argument 1 from 'QDate' to 'uint {aka unsigned int}'
/usr/include/qt5/QtCore/qstring.h:558:20: note: static QString QString::number(long int, int)
static QString number(long, int base=10);
^
/usr/include/qt5/QtCore/qstring.h:558:20: note: no known conversion for argument 1 from 'QDate' to 'long int'
/usr/include/qt5/QtCore/qstring.h:559:20: note: static QString QString::number(ulong, int)
static QString number(ulong, int base=10);
^
/usr/include/qt5/QtCore/qstring.h:559:20: note: no known conversion for argument 1 from 'QDate' to 'ulong {aka long unsigned int}'
/usr/include/qt5/QtCore/qstring.h:560:20: note: static QString QString::number(qlonglong, int)
static QString number(qlonglong, int base=10);
^
/usr/include/qt5/QtCore/qstring.h:560:20: note: no known conversion for argument 1 from 'QDate' to 'qlonglong {aka long long int}'
/usr/include/qt5/QtCore/qstring.h:561:20: note: static QString QString::number(qulonglong, int)
static QString number(qulonglong, int base=10);
^
/usr/include/qt5/QtCore/qstring.h:561:20: note: no known conversion for argument 1 from 'QDate' to 'qulonglong {aka long long unsigned int}'
/usr/include/qt5/QtCore/qstring.h:562:20: note: static QString QString::number(double, char, int)
static QString number(double, char f='g', int prec=6);
^
/usr/include/qt5/QtCore/qstring.h:562:20: note: no known conversion for argument 1 from 'QDate' to 'double'
make: *** [mainwindow.o] Error 1
I think you need to call:
Core::MessageUser(this->CurrentEdit->User, warning, date.toString(),
title, true, dependency);
instead
UPDATE
If you need to print out only the year value:
Core::MessageUser(this->CurrentEdit->User, warning, QString::number(date.year()),
title, true, dependency);