Reputation: 345
I am trying to compile 2 .cpp files which use OpenGL and fltk on MacOs .
On a device using linux (Fedora ) I use the command :
g++-9 -std=c++17 window.cpp prova.cpp -o test -lfltk -lGL -lglut -lGLU -lfltk_gl
and everything works well .
On Mac_Os terminal instead I try with :
g++ -framework GLUT -framework OpenGL -lGLU -lfltk -lglut -lGL -framework Cocoa window.cpp prova.cpp
and I get an infinite number of errors (which i don't get on linux) and warnings such :
(Define GL_SILENCE_DEPRECATION to silence these warnings) [-Wdeprecated-declarations]
inline void gl_rectf(int x,int y,int w,int h) {glRecti(x,y,x+w,y+h);}
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Headers/gl.h:2588:13: note:
'glMatrixMode' has been explicitly marked deprecated here
extern void glMatrixMode (GLenum mode) OPENGL_DEPRECATED(10.0, 10.14);
^
prova.cpp:211:5: warning: 'glLoadIdentity' is deprecated: first deprecated in macOS 10.14 - OpenGL API deprecated. (Define
GL_SILENCE_DEPRECATION to silence these warnings) [-Wdeprecated-declarations]
glLoadIdentity();
Now, I also tried to use the g++-10 which i installed via homebrew doing the following :
g++-10 -framework OpenGL -framework GLUT window.cpp prova.cpp
but i get
1 | #include <FL/Fl.H>
| ^~~~~~~~~
compilation terminated.
prova.cpp:9:10: fatal error: FL/gl.h: No such file or directory
9 | #include <FL/gl.h>
| ^~~~~~~~~
(and this could be the problem) so I included myself the fltk lib :
g++-10 -framework OpenGL -framework GLUT -I /usr/local/Cellar/fltk/1.3.5/include window.cpp prova.cpp
now getting a strage output :
Undefined symbols for architecture x86_64:
"__Z12glutIdleFuncPFvvE", referenced from:
__Z14CreateMyWindowiPPc in ccApCsrQ.o
"__Z13glutSolidConeddii", referenced from:
__Z11displayConev in ccyWlxbb.o
"__Z15glutSwapBuffersv", referenced from:
__Z11displayConev in ccyWlxbb.o
"__Z16glutCreateWindowPKc", referenced from:
__Z14CreateMyWindowiPPc in ccApCsrQ.o
"__Z18glutInitWindowSizeii", referenced from: // .... and so on
This is a kind of error in macOS that you get (i think) when you don't include a framework .
Is there anyone who knows which is the problem in this ? (the 2 .cpp files perfectly work on linux so it is a problem of MacOs)
Upvotes: 1
Views: 246
Reputation: 14467
Along with -I /usr/local ....
option, which solves problems with include files, try adding the
-L /usr/local/Cellar/fltk/1.3.5/lib (look up the exact folder name with .a and .so files)
optional which tells the linker from g++-10 package to look for library file itself in the directory. Also you might have to use the -lfltk
in case you are linking to FLTK explicitly.
Upvotes: 1