Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

LinkError of OpenGL


My enviroment is windows 8.1 x64, Mathematica 9.0.1, opengl 1.1

targetDirectory = "E:\\Users\\Hyper\\Documents\\OpenGL";
sourceDirectory = "E:\\Users\\Hyper\\Documents\\OpenGL\\SourceFile";
includeDirectory = {"E:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\include",    
"E:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\include\\GL"};
libraryDirectory = {"E:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\lib"};
LinkerOptions = {"opengl32.lib", "glaux.lib", "glu.lib", "glu32.lib",    "glut.lib", "glut32.lib", "opengl.lib"};

mainFile = Import[sourceDirectory <> "\\opengl-test1.txt"]

(*
    #include <windows.h>   
   //#include <gl/glaux.h>
   //#include <gl/gl.h>
   //#include <gl/glu.h>
  //#include <gl/glut.h>
  #include <glaux.h>
  #include <gl.h>
  #include <glu.h>
  #include <glut.h>
  #pragma comment(lib, "opengl32.lib")
  #pragma comment(lib, "glaux.lib")#pragma comment(lib, "glu.lib")
  #pragma comment(lib, "glu32.lib")
  #pragma comment(lib, "glut.lib")
  #pragma comment(lib, "glut32.lib")
  #pragma comment(lib, "opengl.lib")
  int main(int argc, char* * argv)
{auxInitDisplayMode(AUX_SINGLE|AUX_RGBA);
auxInitPosition(0,0,500,500);
auxInitWindow(argv[0]);
glClearColor(0.0,0.0,0.0,0.0);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,1.0,1.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.0,1.0,-1.0,1.0,-1.0,1.0);
glBegin(GL_POLYGON); glVertex2f(-0.5,-0.5);
glVertex2f(-0.5,0.5);
glVertex2f(0.5,0.5);
glVertex2f(0.5,-0.5);
glEnd();
glFlush();
}
*)

exe = CreateExecutable[mainFile, "opengl-test1-x64",   "IncludeDirectories" -> includeDirectory, "Language" -> "C++",   "LibraryDirectories" -> libraryDirectory,   "TargetDirectory" -> targetDirectory, "Debug" -> True,   "LinkerOptions" -> LinkerOptions]

enter image description here


I can build and run this little example, in VC2010-IDE enviroment, so I'm not sure where goes wrong.

share|improve this question
    
It looks like several include statements in your mainfile are commented out (using //). That may be the problem. –  Sjoerd C. de Vries Jan 19 at 16:12
    
@SjoerdC.deVries Hi, the commented out include statements are used for include dir=VC\\include, I've also include the dir=VC\\include\\GL that is ` "E:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\include\\GL"}. Include errors maybe this : Cannot open include file: 'glaux.h': No such file or directory ; –  HyperGroups Jan 20 at 2:33
    
I'm sorry, but I don't understand what you're saying. Why didn't you include those header files? –  Sjoerd C. de Vries Jan 20 at 6:43
    
@SjoerdC.deVries Sorry, I've reformatted the code, I think now you can understand better. –  HyperGroups Jan 20 at 11:03
    
Did you take a look at what commands CreateExecutable is running? ("ShellCommandFunction"). I would take a look at that, figure out what's wrong with them, and start from there. –  Szabolcs Jan 20 at 22:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.