2

私は現在、MS VS2005 で開発された C++ アプリケーションを Linux に移植していますが、残念ながらこれは初めてのことです。Qt 4.6、Opencascade 6.5.1、および Qwt 6.0.1 を使用しています。ほとんどのコードは正常にコンパイルされますが、ある時点で X を使用してクライアントの画面サイズを決定しようとしており、X ライブラリを含めようとするとすぐに大量のエラーが発生します。クラス ヘッダーには、次の行が含まれます。

#ifdef WNT
#include <windows.h>
#else
#include <X11/X.h>
#include <X11/Xlib.h>
#endif //WNT

行しかない場合#include <X11/X.h>、次のエラーが発生します。

In file included from v0000/plot_curve.h:7,
                 from v0000/utility.h:9,
                 from v0000/settings.h:16,
                 from v0000/dialog.cpp:10:
../../../qwt-6.0.1/include/qwt_symbol.h:35: error: expected identifier before numeric constant
../../../qwt-6.0.1/include/qwt_symbol.h:35: error: expected `}' before numeric constant
... <many more of these in this file>
In file included from v0000/plot_curve.h:7,
                 from v0000/utility.h:9,
                 from v0000/settings.h:16,
                 from v0000/dialog.cpp:10:
../../../qwt-6.0.1/include/qwt_symbol.h:10:1: unterminated #ifndef
In file included from v0000/utility.h:9,
                 from v0000/settings.h:16,
                 from v0000/dialog.cpp:10:
v0000/plot_curve.h:1:1: unterminated #ifndef
In file included from v0000/settings.h:16,
                 from v0000/dialog.cpp:10:
v0000/utility.h:1:1: unterminated #ifndef
In file included from v0000/dialog.cpp:10:
v0000/settings.h:1:1: unterminated #ifndef

そして#include <X11/Xlib.h>行のみで:

In file included from ../../../../lib/inc/gce_MakeDir.hxx:20,
                 from v0000/bounding_box.cpp:17:
../../../../lib/inc/gce_Root.hxx:49: error: expected unqualified-id before ')' token
In file included from ../../../../lib/inc/gce_Root.hxx:71,
                 from ../../../../lib/inc/gce_MakeDir.hxx:20,
                 from v0000/bounding_box.cpp:17:
../../../../lib/inc/gce_Root.lxx:11: error: expected unqualified-id before "int"

X が必要なコードは現在非アクティブ化されているため、2 つのインクルードがなくても、すべて正常にコンパイルされます。

私は本当に問題の根本を突き止めることができないようです。X のインクルード パスは正しく、qt と occ のサンプル アプリケーションは動作します (つまり、X を使用していると推測され、インストールは問題ないはずです)。また、インクルード ガードでエラーを見つけることができませんでした。

// 要求に応じて編集します。エラーが発生したファイルのソース コードは次のとおりです。

qwt_symbol.h: (qwt)

/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
 * Qwt Widget Library
 * Copyright (C) 1997   Josef Wilgen
 * Copyright (C) 2002   Uwe Rathmann
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the Qwt License, Version 1.0
 *****************************************************************************/

#ifndef QWT_SYMBOL_H
#define QWT_SYMBOL_H

#include "qwt_global.h"
#include <QPolygonF>

class QPainter;
class QRect;
class QSize;
class QBrush;
class QPen;
class QColor;
class QPointF;

//! A class for drawing symbols
class QWT_EXPORT QwtSymbol
{
public:
    /*!
      Symbol Style
      \sa setStyle(), style()
     */
    enum Style
    {
        //! No Style. The symbol cannot be drawn.
        NoSymbol = -1,

        //! Ellipse or circle
        Ellipse,

        //! Rectangle
        Rect,

        //!  Diamond
        Diamond,

        //! Triangle pointing upwards
        Triangle,

        //! Triangle pointing downwards
        DTriangle,

        //! Triangle pointing upwards
        UTriangle,

        //! Triangle pointing left
        LTriangle,

        //! Triangle pointing right
        RTriangle,

        //! Cross (+)
        Cross,

        //! Diagonal cross (X)
        XCross,

        //! Horizontal line
        HLine,

        //! Vertical line
        VLine,

        //! X combined with +
        Star1,

        //! Six-pointed star
        Star2,

        //! Hexagon
        Hexagon,

        /*!
         Styles >= QwtSymbol::UserSymbol are reserved for derived
         classes of QwtSymbol that overload drawSymbols() with
         additional application specific symbol types.
         */
        UserStyle = 1000
    };

public:
    QwtSymbol( Style = NoSymbol );
    QwtSymbol( Style, const QBrush &, const QPen &, const QSize & );
    QwtSymbol( const QwtSymbol & );
    virtual ~QwtSymbol();

    QwtSymbol &operator=( const QwtSymbol & );
    bool operator==( const QwtSymbol & ) const;
    bool operator!=( const QwtSymbol & ) const;

    void setSize( const QSize & );
    void setSize( int width, int height = -1 );
    const QSize& size() const;

    virtual void setColor( const QColor & );

    void setBrush( const QBrush& b );
    const QBrush& brush() const;

    void setPen( const QPen & );
    const QPen& pen() const;

    void setStyle( Style );
    Style style() const;

    void drawSymbol( QPainter *, const QPointF & ) const;
    void drawSymbols( QPainter *, const QPolygonF & ) const;

    virtual QSize boundingSize() const;

protected:
    virtual void drawSymbols( QPainter *,
        const QPointF *, int numPoints ) const;

private:
    class PrivateData;
    PrivateData *d_data;
};

/*!
  \brief Draw the symbol at a specified position

  \param painter Painter
  \param pos Position of the symbol in screen coordinates
*/
inline void QwtSymbol::drawSymbol(
    QPainter *painter, const QPointF &pos ) const
{
    drawSymbols( painter, &pos, 1 );
}

/*!
  \brief Draw symbols at the specified points

  \param painter Painter
  \param points Positions of the symbols in screen coordinates
*/

inline void QwtSymbol::drawSymbols(
    QPainter *painter, const QPolygonF &points ) const
{
    drawSymbols( painter, points.data(), points.size() );
}

#endif

gce_root.hxx: (オープンカスケード)

// This file is generated by WOK (CPPExt).
// Please do not edit this file; modify original file instead.
// The copyright and license terms as defined for the original file apply to 
// this header file considered to be the "object code" form of the original source.

#ifndef _gce_Root_HeaderFile
#define _gce_Root_HeaderFile

#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif

#ifndef _gce_ErrorType_HeaderFile
#include <gce_ErrorType.hxx>
#endif
#ifndef _Standard_Boolean_HeaderFile
#include <Standard_Boolean.hxx>
#endif


//! This class implements the common services for <br>
//!           all classes of gce which report error. <br>
class gce_Root  {
public:

  void* operator new(size_t,void* anAddress) 
  {
    return anAddress;
  }
  void* operator new(size_t size) 
  {
    return Standard::Allocate(size); 
  }
  void  operator delete(void *anAddress) 
  {
    if (anAddress) Standard::Free((Standard_Address&)anAddress); 
  }

  //! Returns true if the construction is successful. <br>
        Standard_Boolean IsDone() const;

//! Returns the status of the construction: <br>
//! -   gce_Done, if the construction is successful, or <br>
//! -   another value of the gce_ErrorType enumeration <br>
//!   indicating why the construction failed. <br>
        gce_ErrorType Status() const;





protected:



gce_ErrorType TheError;


private:





};


#include <gce_Root.lxx>



// other Inline functions and methods (like "C++: function call" methods)


#endif

gce_root.lxx: (オープンカスケード)

// File:    gce_Root.cxx
// Created: Tue Sep 29 12:34:39 1992
// Author:  Remi GILET
//      <reg@sdsun2>

inline Standard_Boolean gce_Root::IsDone () const
{
  return TheError == gce_Done;
}

inline gce_ErrorType gce_Root::Status() const
{ 
  return TheError;
}
4

3 に答える 3

1

Bool など、Qt が X11 に必要な型を定義していないことを確認しましたか?

Compiler does not see QX11Infoを見てください。これは、Qt に X11 を含める際の一般的な問題をカバーしているためです。

Bool 以外にも undef が必要になる場合があります。

于 2016-06-07T11:03:54.417 に答える