简体   繁体   English

x86_64-w64-mingw32-g ++编译失败,g ++正常工作

[英]x86_64-w64-mingw32-g++ fails to compile, g++ works fine

I'm trying to cross-compile a program for windows on linux, but the mingw32 compiler is getting errors that aren't present with g++. 我正在尝试为Linux上的Windows交叉编译程序,但是mingw32编译器遇到了g ++不存在的错误。

the command: 命令:

g++ *.cpp -o game -lGL -lGLU -lglfw -lftgl -lopenal -lalut -I/usr/include/freetype2

compiles the program perfectly fine. 编译程序完全正常。 However the mingw32 equivalent (as far as I can tell) outputs the following errors: 但是,mingw32等效项(据我所知)输出以下错误:

    /usr/bin/x86_64-w64-mingw32-g++ *.cpp -o game.exe -I /usr/x86_64-w64-mingw32/include -L /usr/x86_64-w64-mingw32/lib -lGL -lglu -lglut -lglfw -lfreetype -lftgl -lopenal -lalut -I/usr/x86_64-w64-mingw32/include/freetype2

    In file included from gesplit.cpp:22:0:
text.h:14:45: error: macro "TEXT" passed 6 arguments, but takes just 1
       TEXT(string,int=12,int=0,int=0,int=0,int=0);
                                             ^
    text.h:15:52: error: macro "TEXT" passed 7 arguments, but takes just 1
       TEXT(WORLD&,string,int=12,int=0,int=0,int=0,int=0);
                                                    ^
    gesplit.cpp:85:102: error: macro "TEXT" passed 6 arguments, but takes just 1
     back(new TEXT("PRESS ENTER TO START",24,(screen.w/2)-250,(screen.h-24)/4,0,0));
                                                                                 ^
    gesplit.cpp:86:98: error: macro "TEXT" passed 6 arguments, but takes just 1
         ush_back(new TEXT("WASD - ARROW KEYS:     MOVE",12,40,(screen.h-24)/2+20,0,0));
                                                                             ^
    gesplit.cpp:87:96: error: macro "TEXT" passed 6 arguments, but takes just 1
     .push_back(new TEXT("P:                     PAUSE",12,40,(screen.h-24)/2,0,0));
                                                                               ^
    gesplit.cpp:88:99: error: macro "TEXT" passed 6 arguments, but takes just 1
     sh_back(new TEXT("SPACE:                 SHOOT",12,40,(screen.h-24)/2-20,0,0));
                                                                             ^
    gesplit.cpp:89:118: error: macro "TEXT" passed 6 arguments, but takes just 1
     SC:                   QUIT GAME LIKE A QUITTER",12,40,(screen.h-24)/2-40,0,0));
                                                                             ^ 
    gesplit.cpp:90:98: error: macro "TEXT" passed 6 arguments, but takes just 1
     ush_back(new TEXT("SPACE SHOOT",40,(screen.w/2)-220,(screen.h-24)*3/4+20,0,0));
                                                                             ^
    gesplit.cpp:91:94: error: macro "TEXT" passed 6 arguments, but takes just 1
     xt.push_back(new TEXT("ZAP-ZAP",40,(screen.w/2)-140,(screen.h-24)*3/4-20,0,0));
                                                                             ^
    gesplit.cpp:96:100: error: macro "TEXT" passed 7 arguments, but takes     just 1
     (new TEXT(new_world,("SCORE "+intToString(globalScore)),24,0,screen.h-24,0,0));
                                                                                 ^
    In file included from gesplit.cpp:22:0:
    text.h:14:3: error: declaration does not declare anything [-fpermissive]
       TEXT(string,int=12,int=0,int=0,int=0,int=0);
        ^
    text.h:15:3: error: declaration does not declare anything [-fpermissive]
       TEXT(WORLD&,string,int=12,int=0,int=0,int=0,int=0);
       ^
    gesplit.cpp: In function ‘int main(int, char**)’:
    gesplit.cpp:62:64: error: no matching function for call to       ‘TEXT::TEXT(const char [6], int, int, int, int, int)’
       TEXT pauseText("PAUSE",24,(screen.w/2)-62,(screen.h-24)/2,0,0);
                                                                ^
    In file included from gesplit.cpp:22:0:
    text.h:8:7: note: candidate: TEXT::TEXT()
     class TEXT:public OBJECT
       ^
    text.h:8:7: note:   candidate expects 0 arguments, 6 provided
    text.h:8:7: note: candidate: TEXT::TEXT(const TEXT&)
    text.h:8:7: note:   candidate expects 1 argument, 6 provided

It looks to me that mingw32 doesn't like the copy constructor where the TEXT class is using OBJECT's constructor. 在我看来,mingw32不喜欢TEXT类使用OBJECT的构造函数的复制构造函数。 I have several classes that use the same format and don't raise errors. 我有几个使用相同格式的类,并且不会引发错误。 It might be a problem with ftgl.h, because TEXT is the only class that uses it, but this looks too much like a syntax error. ftgl.h可能有问题,因为TEXT是唯一使用它的类,但这看起来太像语法错误。

text.cpp: text.cpp:

#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <GL/gl.h>
//#include <freetype2/freetype/config/ftheader.h>
//#include <freetype2/ft2build.h>
#include <FTGL/ftgl.h>
#include <FTGL/FTGLPixmapFont.h>
#include "person.h"
#include "object.h"
#include "world.h"
#include "text.h"
#include "coord.h"
#include "globals.h"
using namespace std;

TEXT::TEXT(WORLD& world_a,string text_a,int size_a,int x_a,int y_a,int     xvel_a,int yvel_a)
  :OBJECT(world_a,x_a,y_a,xvel_a,yvel_a)
{
  type="TEXT";
  layer=6;
  cout<<"begin text constructor"<<endl;
  text=text_a;
  cout<<"set text"<<endl;
  font = new FTPixmapFont("emulogic.ttf");
  cout<<"set font"<<endl;
  font->FaceSize(size_a);
  cout<<"end text constructor"<<endl;
}

TEXT::TEXT(string text_a,int size_a,int x_a,int y_a,int xvel_a,int yvel_a)
  :OBJECT(x_a,y_a,xvel_a,yvel_a)
{
  type="TEXT";
  layer=6;
  cout<<"begin text constructor"<<endl;
  text=text_a;
  cout<<"set text"<<endl;
  font = new FTPixmapFont("emulogic.ttf");
  cout<<"set font"<<endl;
  font->FaceSize(size_a);
  cout<<"end text constructor"<<endl;
}

void TEXT::render()
{
  glPushMatrix();
  glTranslatef(x,y,0);

  glPushAttrib(GL_ALL_ATTRIB_BITS);
  glDisable(GL_LIGHTING);
  glDisable(GL_DEPTH_TEST);

  /*glBegin(GL_QUADS);
  glColor4f(0.0f,0.0f,0.0f,0.3f);
  glVertex3f(0.0f,0.0f,0.0f);
  glVertex3f(screen.w,0.0f,0.0f);
  glVertex3f(screen.w,32.0f,0.0f);
  glVertex3f(0.0f,32.0f,0.0f);
  glEnd();
  */

  glColor4d(1.0,1.0,1.0,1.0);
  font->Render(text.c_str(),-1,FTPoint(x,y,0)); //text doesn't transform, so use FTPoint
  glPopAttrib();
  glPopMatrix();
}

bool TEXT::logic(int step)
{
  switch(step)
    {
    case 0:
      break;
    default:
      return true;
      break;
    }
  return false; 
}

void TEXT::setText(string text_a)
{
  text=text_a;
}

void TEXT::setFontSize(int size)
{
  font->FaceSize(size);
}

any/all help is appreciated. 任何/所有帮助表示赞赏。

On windows, TEXT is a macro function that tells the compiler to use the string passed to it as UTF-16 when UNICODE is defined, and as an ANSI string otherwise. 在Windows上,TEXT是宏函数,它告诉编译器在定义UNICODE时将传递给它的字符串用作UTF-16,否则将其用作ANSI字符串。 Since the preprocessor is executed before the actual compilation, it knows nothing of the class you defined. 由于预处理器是在实际编译之前执行的,因此它对您定义的类一无所知。 It thinks you are making a call to the macro function, which accepts just one argument. 它认为您正在调用宏函数,该函数仅接受一个参数。 This is why it's giving you the error. 这就是为什么它会给您错误。 Rename your class to solve the problem. 重命名您的班级以解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM