[R] Patch for rgl with gcc 4.0 in R 2.3.0 on OS X

Duncan Murdoch murdoch at stats.uwo.ca
Mon Jun 26 15:17:49 CEST 2006


I think this has already been fixed.  The rgl repository had a disk 
crash and is being restored today, but you can see a recent build on my 
web page,

http://www.stats.uwo.ca/faculty/murdoch/software/

We are planning a new release very soon; the disk crash is a bit of a 
nuisance, though.

Duncan Murdoch

On 6/26/2006 9:08 AM, Balaji S. Srinivasan wrote:
> Hi,
> 
> I recently had a problem installing the rgl package on OS X and put together
> a simple patch. The patched package is available here:
> 
> http://jinome.stanford.edu/files/rgl_0.66-patched_for_gcc4.tar.gz
> 
> It can be installed with "R CMD INSTALL rgl_0.66-patched_for_gcc4.tar.gz" as
> normal at the command line.
> 
> Also -- as of right now rgl is not in the repository of version 2.3 packages
> (or at least did not come up when I ran new.packages() at the R prompt). I'm
> not sure if this build error was the problem, but if so this
> version now works perfectly. For those who are interested, I have included
> details on what exactly went wrong and the fix:
> 
> 1) What went wrong -- here is the output of the initial build attempt. The
> install fails because of an invalid integer conversion, which I eventually
> figured out was
> due to gcc-4 flagging it as an error, whereas gcc-3 and earlier would have
> called it a warning.
> 
> [root:/root/downloads/rgl_patch]$R CMD INSTALL rgl_0.66.tar.gz
> * Installing *source* package 'rgl' ...
> checking for libpng-config... yes
> configure: using libpng-config
> configure: using libpng dynamic linkage
> configure: creating ./config.status
> config.status: creating src/Makevars
> ** libs
> ** arch - i386
> g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include
> -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON
> -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H
> -I/opt/local/include/libpng12 -msse3   -fPIC -fno-common  -g -O2
> -march=pentium-m -mtune=prescott -c BBoxDeco.cpp -o BBoxDeco.o
> g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include
> -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON
> -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H
> -I/opt/local/include/libpng12 -msse3   -fPIC -fno-common  -g -O2
> -march=pentium-m -mtune=prescott -c Background.cpp -o Background.o
> g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include
> -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON
> -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H
> -I/opt/local/include/libpng12 -msse3   -fPIC -fno-common  -g -O2
> -march=pentium-m -mtune=prescott -c Color.cpp -o Color.o
> g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include
> -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON
> -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H
> -I/opt/local/include/libpng12 -msse3   -fPIC -fno-common  -g -O2
> -march=pentium-m -mtune=prescott -c Disposable.cpp -o Disposable.o
> g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include
> -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON
> -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H
> -I/opt/local/include/libpng12 -msse3   -fPIC -fno-common  -g -O2
> -march=pentium-m -mtune=prescott -c FaceSet.cpp -o FaceSet.o
> g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include
> -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON
> -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H
> -I/opt/local/include/libpng12 -msse3   -fPIC -fno-common  -g -O2
> -march=pentium-m -mtune=prescott -c Light.cpp -o Light.o
> g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include
> -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON
> -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H
> -I/opt/local/include/libpng12 -msse3   -fPIC -fno-common  -g -O2
> -march=pentium-m -mtune=prescott -c LineSet.cpp -o LineSet.o
> g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include
> -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON
> -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H
> -I/opt/local/include/libpng12 -msse3   -fPIC -fno-common  -g -O2
> -march=pentium-m -mtune=prescott -c LineStripSet.cpp -o LineStripSet.o
> g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include
> -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON
> -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H
> -I/opt/local/include/libpng12 -msse3   -fPIC -fno-common  -g -O2
> -march=pentium-m -mtune=prescott -c Material.cpp -o Material.o
> g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include
> -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON
> -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H
> -I/opt/local/include/libpng12 -msse3   -fPIC -fno-common  -g -O2
> -march=pentium-m -mtune=prescott -c PointSet.cpp -o PointSet.o
> g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include
> -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON
> -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H
> -I/opt/local/include/libpng12 -msse3   -fPIC -fno-common  -g -O2
> -march=pentium-m -mtune=prescott -c PrimitiveSet.cpp -o PrimitiveSet.o
> g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include
> -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON
> -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H
> -I/opt/local/include/libpng12 -msse3   -fPIC -fno-common  -g -O2
> -march=pentium-m -mtune=prescott -c QuadSet.cpp -o QuadSet.o
> g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include
> -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON
> -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H
> -I/opt/local/include/libpng12 -msse3   -fPIC -fno-common  -g -O2
> -march=pentium-m -mtune=prescott -c RenderContext.cpp -o RenderContext.o
> g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include
> -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON
> -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H
> -I/opt/local/include/libpng12 -msse3   -fPIC -fno-common  -g -O2
> -march=pentium-m -mtune=prescott -c Shape.cpp -o Shape.o
> g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include
> -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON
> -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H
> -I/opt/local/include/libpng12 -msse3   -fPIC -fno-common  -g -O2
> -march=pentium-m -mtune=prescott -c SphereMesh.cpp -o SphereMesh.o
> g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include
> -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON
> -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H
> -I/opt/local/include/libpng12 -msse3   -fPIC -fno-common  -g -O2
> -march=pentium-m -mtune=prescott -c SphereSet.cpp -o SphereSet.o
> g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include
> -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON
> -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H
> -I/opt/local/include/libpng12 -msse3   -fPIC -fno-common  -g -O2
> -march=pentium-m -mtune=prescott -c SpriteSet.cpp -o SpriteSet.o
> g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include
> -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON
> -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H
> -I/opt/local/include/libpng12 -msse3   -fPIC -fno-common  -g -O2
> -march=pentium-m -mtune=prescott -c String.cpp -o String.o
> g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include
> -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON
> -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H
> -I/opt/local/include/libpng12 -msse3   -fPIC -fno-common  -g -O2
> -march=pentium-m -mtune=prescott -c Surface.cpp -o Surface.o
> g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include
> -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON
> -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H
> -I/opt/local/include/libpng12 -msse3   -fPIC -fno-common  -g -O2
> -march=pentium-m -mtune=prescott -c TextSet.cpp -o TextSet.o
> g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include
> -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON
> -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H
> -I/opt/local/include/libpng12 -msse3   -fPIC -fno-common  -g -O2
> -march=pentium-m -mtune=prescott -c Texture.cpp -o Texture.o
> g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include
> -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON
> -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H
> -I/opt/local/include/libpng12 -msse3   -fPIC -fno-common  -g -O2
> -march=pentium-m -mtune=prescott -c TriangleSet.cpp -o TriangleSet.o
> g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include
> -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON
> -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H
> -I/opt/local/include/libpng12 -msse3   -fPIC -fno-common  -g -O2
> -march=pentium-m -mtune=prescott -c Viewpoint.cpp -o Viewpoint.o
> g++-4.0 -arch i386 -I/Library/Frameworks/R.framework/Resources/include
> -I/Library/Frameworks/R.framework/Resources/include/i386 -DRGL_USE_CARBON
> -I/System/Library/Frameworks/AGL.framework/Headers -DHAVE_PNG_H
> -I/opt/local/include/libpng12 -msse3   -fPIC -fno-common  -g -O2
> -march=pentium-m -mtune=prescott -c api.cpp -o api.o
> api.cpp: In function 'void rgl_user2window(int*, int*, double*, double*,
> double*, double*, int*)':
> api.cpp:608: error: invalid conversion from 'int*' to 'const GLint*'
> api.cpp:608: error:   initializing argument 6 of 'GLint gluProject(GLdouble,
> GLdouble, GLdouble, const GLdouble*, const GLdouble*, const GLint*,
> GLdouble*, GLdouble*, GLdouble*)'
> api.cpp: In function 'void rgl_window2user(int*, int*, double*, double*,
> double*, double*, int*)':
> api.cpp:633: error: invalid conversion from 'int*' to 'const GLint*'
> api.cpp:633: error:   initializing argument 6 of 'GLint
> gluUnProject(GLdouble, GLdouble, GLdouble, const GLdouble*, const GLdouble*,
> const GLint*, GLdouble*, GLdouble*, GLdouble*)'
> make: *** [api.o] Error 1
> chmod: cannot access
> `/Library/Frameworks/R.framework/Versions/2.3/Resources/library/rgl/libs/i386/*':
> No such file or directory
> ERROR: compilation failed for package 'rgl'
> ** Removing
> '/Library/Frameworks/R.framework/Versions/2.3/Resources/library/rgl'
> 
> ---------------------
> 
> 2) The fix is below. It seems that gcc-4.0 does not want to convert an int*
> directly to a const GLint*, maybe because it might be possible to
> fool around with the underlying variable. To deal with this, I defined a
> GLint named viewgl and set it equal to the dereferenced value
> of the int* view. I then passed in the address of viewgl to the gluProject
> routine. This eliminated the error messages and allowed compilation.
> 
> 
> -----RELEVANT SECTION OF rgl/src/api.cpp BEFORE ---
> 
> void rgl_user2window(int* successptr, int* idata, double* point, double*
> pixel, double* model, double* proj, int* view)
> {
>   int success = RGL_FAIL;
>   GLdouble* vertex = pixel;
>   int columns = idata[0];
> 
>   Device* device = deviceManager->getAnyDevice();
> 
>   if ( device ) {
>         for (int i=0; i<columns; i++) {
>                 gluProject(point[0],point[1],point[2],model,proj,view,
>                 vertex,vertex+1,vertex+2);
>                 vertex[0] /= view[2];
>                 vertex[1] /= view[3];
>                 point += 3;
>                 vertex += 3;
>         }
>         success = RGL_SUCCESS;
>   }
> 
>   *successptr = success;
> }
> 
> void rgl_window2user(int* successptr, int* idata, double* point, double*
> pixel, double* model, double* proj, int* view)
> {
>   int success = RGL_FAIL;
>   GLdouble* vertex = point;
>   int columns = idata[0];
> 
>   Device* device = deviceManager->getAnyDevice();
> 
>   if ( device ) {
>         for (int i=0; i<columns; i++) {
>                 pixel[0] *= view[2];
>                 pixel[1] *= view[3];
>                 gluUnProject(pixel[0],pixel[1],pixel[2],model,proj,view,
>                 vertex,vertex+1,vertex+2);
>                 pixel += 3;
>                 vertex += 3;
>         }
>         success = RGL_SUCCESS;
>   }
> 
>   *successptr = success;
> }
> 
> 
> 
> ----RELEVANT SECTION OF rgl/src/api.cpp AFTER ----
> 
> void rgl_user2window(int* successptr, int* idata, double* point, double*
> pixel, double* model, double* proj, int* view)
> {
>   int success = RGL_FAIL;
>   GLdouble* vertex = pixel;
>   int columns = idata[0];
> 
>   //To fix gcc-4.0 error about "invalid conversion of int* to const GLint*,
> initialize
>   //a GLint variable viewgl and set it to the dereferenced value of view.
> This is now safe.
>   GLint viewgl = *view;
> 
>   Device* device = deviceManager->getAnyDevice();
> 
>   if ( device ) {
>         for (int i=0; i<columns; i++) {
>                 gluProject(point[0],point[1],point[2],model,proj,&viewgl,
> //pass address of viewgl
>                 vertex,vertex+1,vertex+2);
>                 vertex[0] /= view[2];
>                 vertex[1] /= view[3];
>                 point += 3;
>                 vertex += 3;
>         }
>         success = RGL_SUCCESS;
>   }
> 
>   *successptr = success;
> }
> 
> void rgl_window2user(int* successptr, int* idata, double* point, double*
> pixel, double* model, double* proj, int* view)
> {
>   int success = RGL_FAIL;
>   GLdouble* vertex = point;
>   int columns = idata[0];
> 
>   //To fix gcc-4.0 error about "invalid conversion of int* to const GLint*,
> initialize
>   //a GLint variable viewgl and set it to the dereferenced value of view.
> This is now safe.
>   GLint viewgl = *view;
> 
>   Device* device = deviceManager->getAnyDevice();
> 
>   if ( device ) {
>         for (int i=0; i<columns; i++) {
>                 pixel[0] *= view[2];
>                 pixel[1] *= view[3];
>                 gluUnProject(pixel[0],pixel[1],pixel[2],model,proj,&viewgl,
> //pass address of viewgl
>                 vertex,vertex+1,vertex+2);
>                 pixel += 3;
>                 vertex += 3;
>         }
>         success = RGL_SUCCESS;
>   }
> 
>   *successptr = success;
> }
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html



More information about the R-help mailing list