qt linux“QMAKE_CXXFLAGS + = -std = c ++ 11”相当于windows? [英] qt linux "QMAKE_CXXFLAGS += -std=c++11" equivalent for windows?

查看:501
本文介绍了qt linux“QMAKE_CXXFLAGS + = -std = c ++ 11”相当于windows?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个新手,所以请原谅我,如果这真的很蠢。



最近我做了一个项目使用qt ubuntu和我使用QMAKE_CXXFLAGS + = -std = c ++ 11对于静态链接,一切都很好,所以我想为什么不重新编译它在Windows上,我做了。



这是node.h

  #ifndef NODE_H 
#define NODE_H
#include< iostream>
#include< string>
#includeqcustomplot.h
using namespace std;
class node
{
public:
double p [6];
string table [3000] [9];

double splitPoints [8];
double giniA [8]; //通过对相应属性进行分区获得的ginies数组
double gini; //数据集的gini
int rowc = 0; //行计数
int colc = 0;
int cc;
std :: string label;
string a [9];
node * left = NULL;
node * right = NULL;
void plotGraph(QCustomPlot * customPlot);
int optimize(int);


};

#endif // NODE_H

当我运行我的项目时以下错误消息:

 在.. \mining应用程序最终(希望)\ / mythread.h中包含的文件:4 ,
从.. \mining app final(希望)\ / mainwindow.h:8,
从.. \mining app final(希望)\main.cpp:2:
..\mining app final(希望)\ / node.h:16:错误:ISO C ++禁止初始化成员'rowc'
..\mining app final(希望)\ / node .h:16:error:making'rowc'static
..\mining app final(希望)\ / node.h:16:error:ISO C ++禁止非const静态成员的类初始化'rowc'
.. \mining app final(希望)\ / node.h:17:error:ISO C ++禁止成员'colc'的初始化
..\mining app final )\ / node.h:17:error:making'colc'static
..\mining app final(希望)\ / node.h:17:error:ISO C ++禁止类的初始化非const静态成员'colc'
.. \mining app final(希望)\ / node.h:21:error:ISO C ++禁止初始化成员'left'
.. \\挖掘应用程序最终(希望)\ / node.h:21:错误:使'left'静态
.. \mining app final(希望)\ / node.h:21:error:类初始化非整数类型的node *的静态数据成员
.. \mining app final(希望)\ / node.h:22:error:ISO C ++禁止初始化成员'right'
.. \mining app final(hopefully)\ / node.h:22:error:making'right'static
..\mining app final(hopefully)\ / node.h: 22:错误:无效的类内初始化非整型node *的静态数据成员
mingw32-make [1]:离开目录`C:/ build-blah-vai-Debug'
mingw32-make [1]:*** [debug / main.o]错误1
mingw32-make:*** [debug]错误2
01:36:17:进程C :\MinGw\bin\mingw32-make.exe退出代码2.
在构建/部署项目时出错blah(kit:vai)
执行步骤'Make'
01:36:17:经过时间:00:02。

任何人都可以指导我如何解决这个问题?



我目前正在使用Qt 4.8.5-mingw(Windows 7)

解决方案

使用任何c ++ 11特性我写了我自己的to_string()和to_Double()函数并使用它们,现在它的工作原理像一个魅力!



string toString(double)



 

code> string toString(double num)
{
std :: stringstream ss;

ss<< num;
std :: string s(ss.str());

return s;
}

double toDouble(string)

  double toDouble(string s)
{
int i,j;
double p = 0;

for(i = s.size() - 1;(s [i]!='。')&&(i> = 0); i--)
{
p + = 1.0;
}

if(s [i]!='。')
p = 0;

else
{
for(j = i; j s [j] = s [j + 1]
}
istringstream myStream(s);
unsigned int uintVar = 0;

myStream>> uintVar;

return(uintVar /(double)(pow(10.0,p)));
}


I am a newbie so please forgive me if this is really stupid.

Recently I made a project using qt in ubuntu and I used "QMAKE_CXXFLAGS += -std=c++11" for static linking,everything went well so I thought why not recompile it on windows,and I did.

This is node.h

#ifndef NODE_H
#define NODE_H
#include <iostream>
#include <string>
#include "qcustomplot.h"
using namespace std;
class node
{
public:
double p[6];
string table[3000][9];

double splitPoints[8];
double giniA[8];//array of ginies obtained by partitioning on corresponding attributes
double gini;//gini of a dataset
int rowc=0;//row count
int colc=0;
int cc;
std::string label;
string a[9];
node* left=NULL;
node* right=NULL;
void plotGraph(QCustomPlot *customPlot);
int optimize(int);


};

#endif // NODE_H

when I run my project I get the following error messages:

   In file included from ..\mining app final(hopefully)\/mythread.h:4,
             from ..\mining app final(hopefully)\/mainwindow.h:8,
             from ..\mining app final(hopefully)\main.cpp:2:
   ..\mining app final(hopefully)\/node.h:16: error: ISO C++ forbids initialization of  member 'rowc'
   ..\mining app final(hopefully)\/node.h:16: error: making 'rowc' static
   ..\mining app final(hopefully)\/node.h:16: error: ISO C++ forbids in-class   initialization of non-const static member 'rowc'
   ..\mining app final(hopefully)\/node.h:17: error: ISO C++ forbids initialization of member 'colc'
   ..\mining app final(hopefully)\/node.h:17: error: making 'colc' static
   ..\mining app final(hopefully)\/node.h:17: error: ISO C++ forbids in-class initialization of non-const static member 'colc'
   ..\mining app final(hopefully)\/node.h:21: error: ISO C++ forbids initialization of member 'left'
   ..\mining app final(hopefully)\/node.h:21: error: making 'left' static
   ..\mining app final(hopefully)\/node.h:21: error: invalid in-class initialization of static data member of non-integral type 'node*'
   ..\mining app final(hopefully)\/node.h:22: error: ISO C++ forbids initialization of   member 'right'
   ..\mining app final(hopefully)\/node.h:22: error: making 'right' static
   ..\mining app final(hopefully)\/node.h:22: error: invalid in-class initialization of         static data member of non-integral type 'node*'
   mingw32-make[1]: Leaving directory `C:/build-blah-vai-Debug'
   mingw32-make[1]: *** [debug/main.o] Error 1
   mingw32-make: *** [debug] Error 2
   01:36:17: The process "C:\MinGw\bin\mingw32-make.exe" exited with code 2.
   Error while building/deploying project blah (kit: vai)
   When executing step 'Make'
   01:36:17: Elapsed time: 00:02.

can anyone please guide me how to resolve this ?

I'm currently working on Qt 4.8.5-mingw (Windows 7)

解决方案

Well in order to avoid using any c++11 features I wrote my own "to_string()" and "to_Double()" functions and used them, Now It works like a charm !

Here are the functions:

string toString(double)

string toString(double num)
{
std::stringstream ss;

ss << num;
std::string s(ss.str());

return s;
}

double toDouble(string)

 double toDouble(string s)
 {
  int i,j;
  double p=0;

  for(i=s.size()-1;(s[i]!='.')&&(i>=0);i--)
  {
    p+=1.0;
  }

  if(s[i]!='.')
  p=0;

  else
  {
  for(j=i;j<s.size();j++)
  s[j]=s[j+1];
  }
  istringstream myStream(s);
  unsigned int uintVar = 0;

  myStream >> uintVar;

  return (uintVar/(double)(pow(10.0,p)));
 }

这篇关于qt linux“QMAKE_CXXFLAGS + = -std = c ++ 11”相当于windows?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆