Linux/Debian 7.0 で既に動作するアプリケーションを MacOS 10.6.8 でコンパイルしようとしています。このコードは、GPU/OPenCL および OpenGL ライブラリで Qt フレームワークを使用します。
しかし、このファイル ヘッダー (GLWidget.hpp) のコンパイルで問題が発生します (元の Linux バージョンをここに置きます)。
#ifndef GLWIDGET_H
#define GLWIDGET_H
#include <QGLWidget>
#include <GL/glu.h>
#include <QTimer>
#include "NBody.hpp"
#include "Timer.h"
class GLWidget : public QGLWidget
{
Q_OBJECT
public:
GLWidget(QWidget *parent = NULL);
~GLWidget();
...
このバージョンでは、MacOS のコンパイルを使用しています。
/usr/bin/g++-4.2 -c -pipe -O2 -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.6 -Wall -W -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/opt/local/include -I/Developer/GPU\ Computing/OpenCL/common/inc -I/opt/local/share/qt4/mkspecs/macx-g++ -I. -I. -I/opt/local/Library/Frameworks/QtCore.framework/Versions/4/Headers -I/opt/local/Library/Frameworks/QtGui.framework/Versions/4/Headers -I/opt/local/Library/Frameworks/QtOpenGL.framework/Versions/4/Headers -I. -I/opt/local/Library/Frameworks/QtOpenGL.framework/Versions/4/Headers -I/opt/local/Library/Frameworks/QtGui.framework/Versions/4/Headers -I/opt/local/Library/Frameworks/QtCore.framework/Versions/4/Headers -I/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers -I/System/Library/Frameworks/AGL.framework/Headers -I. -F/opt/local/Library/Frameworks -I//Developer/GPU\ Computing/shared/inc -I/System/Library/Frameworks/OpenCL.framework/Headers -o GLWidget.o GLWidget.cpp
GLWidget.cpp: In member function ‘virtual void GLWidget::initializeGL()’:
GLWidget.cpp:82: error: ‘GL_CLAMP_VERTEX_COLOR’ was not declared in this scope
GLWidget.cpp:82: error: ‘glClampColor’ was not declared in this scope
GLWidget.cpp: In function ‘bool loadPngImage(char*, int&, int&, bool&, GLubyte**)’:
GLWidget.cpp:297: error: ‘png_infopp_NULL’ was not declared in this scope
GLWidget.cpp:313: error: ‘png_infopp_NULL’ was not declared in this scope
GLWidget.cpp:347: error: ‘png_voidp_NULL’ was not declared in this scope
GLWidget.cpp:349: error: invalid use of incomplete type ‘struct png_info_def’
/opt/local/include/png.h:739: error: forward declaration of ‘struct png_info_def’
GLWidget.cpp:350: error: invalid use of incomplete type ‘struct png_info_def’
/opt/local/include/png.h:739: error: forward declaration of ‘struct png_info_def’
GLWidget.cpp:351: error: invalid use of incomplete type ‘struct png_info_def’
/opt/local/include/png.h:739: error: forward declaration of ‘struct png_info_def’
GLWidget.cpp:359: error: invalid use of incomplete type ‘struct png_info_def’
/opt/local/include/png.h:739: error: forward declaration of ‘struct png_info_def’
GLWidget.cpp:378: error: ‘png_infopp_NULL’ was not declared in this scope
GLWidget.cpp: In member function ‘void GLWidget::draw()’:
GLWidget.cpp:483: error: ‘GL_VERTEX_PROGRAM_POINT_SIZE_NV’ was not declared in this scope
make: *** [GLWidget.o] Error 1
実際には、glClampColor
関数はスコープで宣言されていません。したがって、この関数が宣言されている場所を検索したところ、次のファイルで見つかりました。
/Developer/GPU Computing/C/common/inc/GL/glew.h
次に、それを PATH に追加し、GLWidget.hpp に含めました。
#ifndef GLWIDGET_H
#define GLWIDGET_H
#include <QGLWidget>
#include <GL/glew.h>
#include <QTimer>
#include "NBody.hpp"
#include "Timer.h"
class GLWidget : public QGLWidget
{
Q_OBJECT
public:
GLWidget(QWidget *parent = NULL);
~GLWidget();
しかし、今、次のエラーが発生します。
/opt/local/bin/uic DiskGal_IC.ui -o ui_DiskGal_IC.h
/opt/local/bin/uic YourGalaxy.ui -o ui_YourGalaxy.h
/usr/bin/g++-4.2 -c -pipe -O2 -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.6 -Wall -W -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/opt/local/include -I/Developer/GPU\ Computing/OpenCL/common/inc -I/opt/local/share/qt4/mkspecs/macx-g++ -I. -I. -I/opt/local/Library/Frameworks/QtCore.framework/Versions/4/Headers -I/opt/local/Library/Frameworks/QtGui.framework/Versions/4/Headers -I/opt/local/Library/Frameworks/QtOpenGL.framework/Versions/4/Headers -I. -I/opt/local/Library/Frameworks/QtOpenGL.framework/Versions/4/Headers -I/opt/local/Library/Frameworks/QtGui.framework/Versions/4/Headers -I/opt/local/Library/Frameworks/QtCore.framework/Versions/4/Headers -I/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers -I/System/Library/Frameworks/AGL.framework/Headers -I. -F/opt/local/Library/Frameworks -I//Developer/GPU\ Computing/shared/inc -I/System/Library/Frameworks/OpenCL.framework/Headers -o DiskGal_IC.o DiskGal_IC.cpp
In file included from GLWidget.hpp:5,
from YourGalaxy.h:30,
from DiskGal_IC.h:25,
from DiskGal_IC.cpp:1:
//Developer/GPU Computing/shared/inc/GL/glew.h:66:2: error: #error gl.h included before glew.h
//Developer/GPU Computing/shared/inc/GL/glew.h:69:2: error: #error glext.h included before glew.h
In file included from GLWidget.hpp:5,
from YourGalaxy.h:30,
from DiskGal_IC.h:25,
from DiskGal_IC.cpp:1:
//Developer/GPU Computing/shared/inc/GL/glew.h:5855: error: ‘GLint64EXT’ has not been declared
//Developer/GPU Computing/shared/inc/GL/glew.h:5856: error: ‘GLuint64EXT’ has not been declared
//Developer/GPU Computing/shared/inc/GL/glew.h:9020: error: ‘PFNGLCOPYTEXSUBIMAGE3DPROC’ does not name a type
//Developer/GPU Computing/shared/inc/GL/glew.h:9021: error: ‘PFNGLDRAWRANGEELEMENTSPROC’ does not name a type
//Developer/GPU Computing/shared/inc/GL/glew.h:9022: error: ‘PFNGLTEXIMAGE3DPROC’ does not name a type
//Developer/GPU Computing/shared/inc/GL/glew.h:9023: error: ‘PFNGLTEXSUBIMAGE3DPROC’ does not name a type
//Developer/GPU Computing/shared/inc/GL/glew.h:9025: error: ‘PFNGLACTIVETEXTUREPROC’ does not name a type
//Developer/GPU Computing/shared/inc/GL/glew.h:9026: error: ‘PFNGLCLIENTACTIVETEXTUREPROC’ does not name a type
...
何をすればよいかわかりません。私の Makefile は、私の .pro で qmake によって生成されましたQT += opengl
。その後、OpenCL などの他のヘッダー/ライブラリを含めるように変更しました。この Makefile の上部は次のとおりです。
CC = /usr/bin/gcc-4.2
CXX = /usr/bin/g++-4.2
DEFINES = -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
CFLAGS = -pipe -O2 -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.6 -Wall -W $(DEFINES)
CXXFLAGS = -pipe -O2 -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.6 -Wall -W $(DEFINES)
GPU = /Developer/GPU\ Computing
INC_GSL = /opt/local/include
INCPATH = -I$(INC_GSL) -I$(GPU)/OpenCL/common/inc -I/opt/local/share/qt4/mkspecs/macx-g++ -I. -I. -I/opt/local/Library/Frameworks/QtCore.framework/Versions/4/Headers -I/opt/local/Library/Frameworks/QtGui.framework/Versions/4/Headers -I/opt/local/Library/Frameworks/QtOpenGL.framework/Versions/4/Headers -I. -I/opt/local/Library/Frameworks/QtOpenGL.framework/Versions/4/Headers -I/opt/local/Library/Frameworks/QtGui.framework/Versions/4/Headers -I/opt/local/Library/Frameworks/QtCore.framework/Versions/4/Headers -I/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers -I/System/Library/Frameworks/AGL.framework/Headers -I. -F/opt/local/Library/Frameworks -I/$(GPU)/shared/inc -I/System/Library/Frameworks/OpenCL.framework/Headers
LINK = /usr/bin/g++-4.2
LFLAGS = -headerpad_max_install_names -arch x86_64 -Xarch_x86_64 -mmacosx-version-min=10.6
LIBS = $(SUBLIBS) -F/opt/local/Library/Frameworks -F/opt/local/lib -F/System/Library/Frameworks -F/opt/local/Library/Frameworks -F/opt/local/lib -L/opt/local/lib -framework QtOpenGL -framework QtGui -framework QtCore -framework OpenGL -framework AGL -framework OpenCL -lgsl -lgslcblas -lfftw3 -L$(GPU)/shared/lib/darwin -lGLEW