How to link libraries to the emcc build command? (GLEW and freeglut)

2,682 views
Skip to first unread message

Sasha Fonseca

unread,
Feb 22, 2014, 12:24:30 PM2/22/14
to emscripte...@googlegroups.com
Hey,

I'm trying to build a small OpenGL program, which uses GLEW and FreeGLUT. I can compile this program just fine using the following gcc command:

gcc <program>.cpp -o <program> -lGL -lGLEW -lGLU -lglut

but I cannot build this with ./emcc. I know I must link these lbiraries somehow, but I can't figure it out. A little help would be great!

Thanks

Jukka Jylänki

unread,
Feb 22, 2014, 12:29:18 PM2/22/14
to emscripte...@googlegroups.com
In Emscripten you can just skip the command lines for GL, GLEW, and GLUT - those are supported in the core, and they will be automatically linked in when you use them. I'm not sure about the status of GLU - it could be that it's not supported. If you just drop the -l directives, do you get further? What are the issues you are seeing? Note that Emscripten does not support desktop GL fully, it has a partial emulation path, and also GLEW and GLUT are partial implementations, so they might need some support work for unusual use cases.


--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Sasha Fonseca

unread,
Feb 22, 2014, 12:34:37 PM2/22/14
to emscripte...@googlegroups.com
[sashaFedora@localhost emscripten]$ ./em++ Teste/tutorial04.cpp -lGL -lGLU -lGLEW -lglut -o main.html
WARNING  root: emcc: cannot find library "GL"
WARNING  root: emcc: cannot find library "GLU"
WARNING  root: emcc: cannot find library "GLEW"
WARNING  root: emcc: cannot find library "glut"
Teste/tutorial04.cpp:4:10: fatal error: 'GL/freeglut.h' file not found
#include <GL/freeglut.h>
         ^
1 error generated.
ERROR    root: compiler frontend failed to generate LLVM bitcode, halting


and:

[sashaFedora@localhost emscripten]$ ./em++ Teste/tutorial04.cpp -o main.html
Teste/tutorial04.cpp:4:10: fatal error: 'GL/freeglut.h' file not found
#include <GL/freeglut.h>
         ^
1 error generated.
ERROR    root: compiler frontend failed to generate LLVM bitcode, halting
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.

Jukka Jylänki

unread,
Feb 22, 2014, 12:56:53 PM2/22/14
to emscripte...@googlegroups.com
Give a look here: https://github.com/kripken/emscripten/tree/master/system/include/GL

Emscripten comes with GL/freeglut_std.h and GL/glut.h. I'm not that well versed with the minute differences of these, but perhaps one of these headers will do the same job for you?


To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.

Sasha Fonseca

unread,
Feb 22, 2014, 1:19:45 PM2/22/14
to emscripte...@googlegroups.com
And what about glm?
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

Jukka Jylänki

unread,
Feb 22, 2014, 1:30:03 PM2/22/14
to emscripte...@googlegroups.com
GLM is a template-based header-only library that should build out of the box, there's no linking required. If it has some flags that enable SIMD, then those should be disabled. I recently read a success story building GLM at least, so I think that should be good to go.


To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.

Byun Juhoon

unread,
Mar 24, 2014, 11:25:15 AM3/24/14
to emscripte...@googlegroups.com
Hey Sasha did you fix it up?
I have a same issue;
I don't know how to compile GL, GLUT library with .o files 

2014년 2월 23일 일요일 오전 2시 24분 30초 UTC+9, Sasha Fonseca 님의 말:

james morrissey

unread,
Apr 1, 2015, 5:47:27 AM4/1/15
to emscripte...@googlegroups.com
I have the same issue, my OpenGL is relying glm for matrices calculations.
Have you found any solution ? 
 

Floh

unread,
Apr 1, 2015, 11:46:30 AM4/1/15
to emscripte...@googlegroups.com
I'm using glm with emscripten in Oryol (https://github.com/floooh/oryol), works out of the box without any custom settings (except may be the GLM_FORCE_RADIANS define to set the angular unit to radians, which is not emscripten specific, but I'm not sure whether this is still necessary in the newer versions).

Just make sure that the glm headers are in emcc header search path ('-I' gcc/emcc option, or in cmake the 'include_directories' macro).

Cheers,
-Floh.
Reply all
Reply to author
Forward
0 new messages