Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Compiling "terrain.cpp" of the examples folder in CGAL 4.6 with OpenGL and GLUT in Mac (Yosemite 10.10.2)

Subject: CGAL users discussion list

List archive

[cgal-discuss] Compiling "terrain.cpp" of the examples folder in CGAL 4.6 with OpenGL and GLUT in Mac (Yosemite 10.10.2)


Chronological Thread 
  • From: Amal Dev P <>
  • To:
  • Subject: [cgal-discuss] Compiling "terrain.cpp" of the examples folder in CGAL 4.6 with OpenGL and GLUT in Mac (Yosemite 10.10.2)
  • Date: Wed, 2 Sep 2015 00:39:15 +0530
  • Authentication-results: mail2-smtp-roc.national.inria.fr; spf=None ; spf=Pass ; spf=None
  • Ironport-phdr: 9a23:0rmqgROvuXH0EVPRUbsl6mtUPXoX/o7sNwtQ0KIMzox0KP/4rarrMEGX3/hxlliBBdydsKIYzbKO+4nbGkU+or+5+EgYd5JNUxJXwe43pCcHRPC/NEvgMfTxZDY7FskRHHVs/nW8LFQHUJ2mPw6anHS+4HYoFwnlMkItf6KuStKU15z//tvx0qOQSj0AvCC6b7J2IUf+hiTqne5Sv7FfLL0swADCuHpCdrce72ppIVWOg0S0vZ/or9YwuxhX7vku/soFXaThdLkjVpRZCi4nOiY7/p7Frx7GGCKK739UfmgI2iIAVwHJ9FfnRp7quy3znuV40Siee8bxSOZnCnyZ8653RUqw2288PDkj/TSPhw==

Hai,

While trying to integrate OpenGL and GLUT with "terrain.cpp" of examples folder in CGAL 4.6 using Mac (Yosemite) and Xcode 6.3, I am getting the following errors initially:

​-------------------------------------------------------​

​​
Linking CXX executable terrain

Undefined symbols for architecture x86_64:

  "_glBegin", referenced from:

      drawFilledCircle(float, float, float) in terrain.cpp.o

      pointset() in terrain.cpp.o

  "_glClear", referenced from:

      display() in terrain.cpp.o

  "_glClearColor", referenced from:

      _main in terrain.cpp.o

  "_glColor3f", referenced from:

      pointset() in terrain.cpp.o

      _main in terrain.cpp.o

  "_glEnd", referenced from:

      drawFilledCircle(float, float, float) in terrain.cpp.o

      pointset() in terrain.cpp.o

  "_glFlush", referenced from:

      display() in terrain.cpp.o

  "_glLineWidth", referenced from:

      pointset() in terrain.cpp.o

      _main in terrain.cpp.o

  "_glLoadIdentity", referenced from:

      reshape(int, int) in terrain.cpp.o

  "_glMatrixMode", referenced from:

      reshape(int, int) in terrain.cpp.o

  "_glOrtho", referenced from:

      reshape(int, int) in terrain.cpp.o

  "_glPointSize", referenced from:

      pointset() in terrain.cpp.o

  "_glVertex2f", referenced from:

      drawFilledCircle(float, float, float) in terrain.cpp.o

      pointset() in terrain.cpp.o

  "_glViewport", referenced from:

      reshape(int, int) in terrain.cpp.o

  "_glutCreateWindow", referenced from:

      _main in terrain.cpp.o

  "_glutDestroyWindow", referenced from:

      kbd(unsigned char, int, int) in terrain.cpp.o

  "_glutDisplayFunc", referenced from:

      _main in terrain.cpp.o

  "_glutInit", referenced from:

      _main in terrain.cpp.o

  "_glutInitDisplayMode", referenced from:

      _main in terrain.cpp.o

  "_glutInitWindowSize", referenced from:

      _main in terrain.cpp.o

  "_glutKeyboardFunc", referenced from:

      _main in terrain.cpp.o

  "_glutMainLoop", referenced from:

      _main in terrain.cpp.o

  "_glutReshapeFunc", referenced from:

      _main in terrain.cpp.o

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

make[2]: *** [terrain] Error 1

make[1]: *** [CMakeFiles/terrain.dir/all] Error 2

make: *** [all] Error 2

​----------------------------------------------------------

Later I found out we have to link OpenGL as well as GLUT with the program​. For that I added the following lines in CMakeLists.txt:

-----------------------------------------------------------
find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIR})
add_executable(Triangulation_2_example terrain.cpp)
target_link_libraries(Triangulation_2_example ${
​OPENGL
_LIBRARY}) 
​-------------------------------------------------------------

Which reduced the errors as follows: 

-----------------------------------------------------------

Linking CXX executable Triangulation_2_example

Undefined symbols for architecture x86_64:

  "_glutCreateWindow", referenced from:

      _main in terrain.cpp.o

  "_glutDestroyWindow", referenced from:

      kbd(unsigned char, int, int) in terrain.cpp.o

  "_glutDisplayFunc", referenced from:

      _main in terrain.cpp.o

  "_glutInit", referenced from:

      _main in terrain.cpp.o

  "_glutInitDisplayMode", referenced from:

      _main in terrain.cpp.o

  "_glutInitWindowSize", referenced from:

      _main in terrain.cpp.o

  "_glutKeyboardFunc", referenced from:

      _main in terrain.cpp.o

  "_glutMainLoop", referenced from:

      _main in terrain.cpp.o

  "_glutReshapeFunc", referenced from:

      _main in terrain.cpp.o

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

make[2]: *** [Triangulation_2_example] Error 1

make[1]: *** [CMakeFiles/Triangulation_2_example.dir/all] Error 2

make: *** [all] Error 2

-----------------------------------------------------------

​Whereas adding only the following lines in CMakeLists.txt:

-----------------------------------------------------------
find_package(GLUT REQUIRED)
include_directories(${GLUT_INCLUDE_DIR})
add_executable(Triangulation_2_example terrain.cpp)
target_link_libraries(Triangulation_2_example ${GLUT_LIBRARY}) 
-----------------------------------------------------------

results in the errors as follows:

-----------------------------------------------------------

Linking CXX executable Triangulation_2_example

Undefined symbols for architecture x86_64:

  "_glBegin", referenced from:

      drawFilledCircle(float, float, float) in terrain.cpp.o

      pointset() in terrain.cpp.o

  "_glClear", referenced from:

      display() in terrain.cpp.o

  "_glClearColor", referenced from:

      _main in terrain.cpp.o

  "_glColor3f", referenced from:

      pointset() in terrain.cpp.o

      _main in terrain.cpp.o

  "_glEnd", referenced from:

      drawFilledCircle(float, float, float) in terrain.cpp.o

      pointset() in terrain.cpp.o

  "_glFlush", referenced from:

      display() in terrain.cpp.o

  "_glLineWidth", referenced from:

      pointset() in terrain.cpp.o

      _main in terrain.cpp.o

  "_glLoadIdentity", referenced from:

      reshape(int, int) in terrain.cpp.o

  "_glMatrixMode", referenced from:

      reshape(int, int) in terrain.cpp.o

  "_glOrtho", referenced from:

      reshape(int, int) in terrain.cpp.o

  "_glPointSize", referenced from:

      pointset() in terrain.cpp.o

  "_glVertex2f", referenced from:

      drawFilledCircle(float, float, float) in terrain.cpp.o

      pointset() in terrain.cpp.o

  "_glViewport", referenced from:

      reshape(int, int) in terrain.cpp.o

ld: symbol(s) not found for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation)

make[2]: *** [Triangulation_2_example] Error 1

make[1]: *** [CMakeFiles/Triangulation_2_example.dir/all] Error 2

make: *** [all] Error 2

-----------------------------------------------------------

So I understood that we have to link both OpenGL as well as GLUT and I added the following commands in CMakeLists.txt:

-----------------------------------------------------------
find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIR})
find_package(GLUT REQUIRED)
include_directories(${GLUT_INCLUDE_DIR})
set(CMAKE_CXX_FLAGS "-g -Wall")
add_executable(Triangulation_2_example terrain.cpp)
target_link_libraries(Triangulation_2_example ${GLUT_LIBRARY} ${OPENGL_LIBRARY})
-----------------------------------------------------------

And this is giving me the initial error again (the one without linking OpenGL as well as GLUT).

Any help is appreciated.

Thanks in advance

--
Warm Regards
       Amal Dev P.,
       PhD Scholar,
       Advanced Geometric Computing Lab,
       Department of Engineering Design,
       IIT Madras, India - 600 036


  • [cgal-discuss] Compiling "terrain.cpp" of the examples folder in CGAL 4.6 with OpenGL and GLUT in Mac (Yosemite 10.10.2), Amal Dev P, 09/01/2015

Archive powered by MHonArc 2.6.18.

Top of Page