stefantalpalaru / gentoo-overlay

Gentoo overlay
GNU General Public License v2.0
43 stars 11 forks source link

electricsheep compile fails with undeclared OpenGL functions #26

Closed ExecutorElassus closed 5 years ago

ExecutorElassus commented 5 years ago

Trying to compile today, it fails with the following:

../DisplayOutput/OpenGL/ShaderGL.cpp: In destructor ‘virtual DisplayOutput::CShaderGL::~CShaderGL()’:
../DisplayOutput/OpenGL/ShaderGL.cpp:41:3: error: ‘glDeleteObjectARB’ was not declared in this scope
   glDeleteObjectARB( m_VertexShader );
   ^~~~~~~~~~~~~~~~~
../DisplayOutput/OpenGL/ShaderGL.cpp:41:3: note: suggested alternative: ‘glDeleteTextures’
   glDeleteObjectARB( m_VertexShader );
   ^~~~~~~~~~~~~~~~~
   glDeleteTextures
../DisplayOutput/OpenGL/ShaderGL.cpp:44:3: error: ‘glDeleteObjectARB’ was not declared in this scope
   glDeleteObjectARB( m_FragmentShader );
   ^~~~~~~~~~~~~~~~~
../DisplayOutput/OpenGL/ShaderGL.cpp:44:3: note: suggested alternative: ‘glDeleteTextures’
   glDeleteObjectARB( m_FragmentShader );
   ^~~~~~~~~~~~~~~~~
   glDeleteTextures
../DisplayOutput/OpenGL/ShaderGL.cpp:47:3: error: ‘glDeleteObjectARB’ was not declared in this scope
   glDeleteObjectARB( m_Program );
   ^~~~~~~~~~~~~~~~~
../DisplayOutput/OpenGL/ShaderGL.cpp:47:3: note: suggested alternative: ‘glDeleteTextures’
   glDeleteObjectARB( m_Program );
   ^~~~~~~~~~~~~~~~~
   glDeleteTextures
../DisplayOutput/OpenGL/ShaderGL.cpp: In member function ‘virtual bool DisplayOutput::CShaderGL::Bind()’:
../DisplayOutput/OpenGL/ShaderGL.cpp:55:2: error: ‘glUseProgramObjectARB’ was not declared in this scope
  glUseProgramObjectARB( m_Program );
  ^~~~~~~~~~~~~~~~~~~~~
../DisplayOutput/OpenGL/ShaderGL.cpp: In member function ‘virtual bool DisplayOutput::CShaderGL::Unbind()’:
../DisplayOutput/OpenGL/ShaderGL.cpp:82:2: error: ‘glUseProgramObjectARB’ was not declared in this scope
  glUseProgramObjectARB( 0 );
  ^~~~~~~~~~~~~~~~~~~~~
../DisplayOutput/OpenGL/ShaderGL.cpp: In member function ‘virtual bool DisplayOutput::CShaderGL::Build(const char*, const char* ’:
../DisplayOutput/OpenGL/ShaderGL.cpp:128:14: error: ‘glCreateProgramObjectARB’ was not declared in this scope
  m_Program = glCreateProgramObjectARB();
              ^~~~~~~~~~~~~~~~~~~~~~~~
../DisplayOutput/OpenGL/ShaderGL.cpp:133:20: error: ‘glCreateShaderObjectARB’ was not declared in this scope
   m_VertexShader = glCreateShaderObjectARB( GL_VERTEX_SHADER_ARB );
                    ^~~~~~~~~~~~~~~~~~~~~~~
../DisplayOutput/OpenGL/ShaderGL.cpp:136:3: error: ‘glShaderSourceARB’ was not declared in this scope
   glShaderSourceARB( m_VertexShader, strIndex + 1, shaderStrings, NULL );
   ^~~~~~~~~~~~~~~~~
../DisplayOutput/OpenGL/ShaderGL.cpp:136:3: note: suggested alternative: ‘glShadeModel’
   glShaderSourceARB( m_VertexShader, strIndex + 1, shaderStrings, NULL );

Is the package obsolete, or do I need to update a dependency?

Cheers.

stefantalpalaru commented 5 years ago

I can't replicate this error. What version did you try to emerge and did you have my whole overlay added when you did that?

stefantalpalaru commented 5 years ago

Looks like you're missing "media-libs/glee" - an explicit dependency.

ExecutorElassus commented 5 years ago

Ah. I have "glee-5.40" installed via an ebuild on my local overlay. I'll update that to use the one from yours and see if that fixes it.

Update: hrm. I installed your glee ebuild, and still get the same error. Somewhat at a loss here.

stefantalpalaru commented 5 years ago

I installed your glee ebuild, and still get the same error. Somewhat at a loss here.

I'm not getting notified for comment updates, so just make a new comment next time.

Run "qlist -e glee" - do you see a "/usr/include/GL/GLee.h" in there? That's the header file that on line 4777 defines the first symbol that you're missing in your debug output:

#define glDeleteObjectARB GLeeFuncPtr_glDeleteObjectARB

Now, if all that is as it should be, try to figure out your include path for "GLee.h" - is it shadowed by another header with the same name that appears sooner in the path?

ExecutorElassus commented 5 years ago

Thanks for the help. Starting at line 4774 I see:

#define GLEE_H_DEFINED_glDeleteObjectARB
  typedef void (APIENTRYP GLEEPFNGLDELETEOBJECTARBPROC) (GLhandleARB obj);
  GLEE_EXTERN GLEEPFNGLDELETEOBJECTARBPROC GLeeFuncPtr_glDeleteObjectARB;
  #define glDeleteObjectARB GLeeFuncPtr_glDeleteObjectARB
#endif

As for the include path: I … don't know how to figure that out, or what "shadowing" is. How do I determine this?

Sorry; I'm not good at this :(

stefantalpalaru commented 5 years ago

After electricsheep's configure phase, you should have this line in the resulting Makefile:

GLEE_CFLAGS = -I/usr/include/GL/

That's where it should find the "GLee.h" header when it tries to include it from "DisplayOutput/OpenGL/RendererGL.cpp".

In that same directory as "RendererGL.cpp", I see an old version of "GLee.c" and "GLee.h". Those shouldn't be used on Linux, but if you have the current dir in your include path, it would be a problem.

ExecutorElassus commented 5 years ago

Yes, that's in the makefile. I don't have the current directory as part of my include path (I think?). I'm still stuck :(

stefantalpalaru commented 5 years ago

Now I can replicate the problem, but I don't know how to fix it.

It seems other people encountered it as well: https://forum.manjaro.org/t/electricsheep-wont-build/66114

ExecutorElassus commented 5 years ago

so … progress? How did you cause the problem to occur? What changed?

I don't know if it would help, but before it stopped working, sometimes the flam3-animate process would get stuck running at 100% CPU. The animation would flicker periodically as some text flashed to the background screen. Is there anywhere that text output might be logged? I'm curious what the error was.

stefantalpalaru commented 5 years ago

How did you cause the problem to occur? What changed?

A global package upgrade on ~amd64. It's not the compiler, because I tried an older version, and it's not Glee that stayed the same. Something else must have changed to trigger what looks like a circular header inclusion problem.

Is there anywhere that text output might be logged? I'm curious what the error was.

I don't think it's logged by default. You have to run it with ... &>log.txt

Rogach commented 5 years ago

Seems that GL/glext.h now exports functions for GL_ARB_shader_objects extension, so they define GL_ARB_shader_objects, which results in relevant section being skipped in /usr/include/GLee.h.

By default GL/glext.h skips defining prototypes for functions, but it can be enabled - I used -DGL_GLEXT_PROTOTYPES option to gcc, and compilation finished without errors.

stefantalpalaru commented 5 years ago

Thanks! Now I'm hitting a linking problem:

libtool: link: x86_64-pc-linux-gnu-g++ -DLINUX_GNU=1 -DSHAREDIR=\"/usr/share/electricsheep/\" -I/usr/include/libgtop-2.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/GL/ -I/usr/include/libpng16 -D__STDC_CONSTANT_MACROS -Wno-write-strings -DHAVE_AVC_VID2=1 -O3 -march=native -mlwp -pipe -Wl,-O1 -Wl,--sort-common -o electricsheep Player.o main.o Voting.o Hud.o Upload.o Download.o Networking.o LoadDDS.o Image.o RendererGL.o glx.o ShaderGL.o TextureFlatGL.o wgl.o FontGL.o mgl.o Shader.o Texture.o Font.o TextureFlat.o Renderer.o LoadPNG.o DisplayOutput.o tinyxmlparser.o tinyxml.o tinystr.o tinyxmlerror.o diriterator.o storage.o luastorage.o ContentDecoder.o SheepUploader.o ContentDownloader.o SheepGenerator.o SheepDownloader.o Sheep.o Shepherd.o LuaState.o Common.o AlignedBuffer.o isaac.o pool.o Log.o Rect.o luaxml.o Exception.o md5.o  -Wl,--as-needed -lavcodec -lavformat -lswscale -lavutil /usr/lib64//liblua.so -ldl -lm -L/usr/lib -lGLee -lcurl -lpng16 -lz -lgtop-2.0 -lglib-2.0 -lXrender -lX11 -lrt -lGL -lglut -ltinyxml -lboost_system -lboost_filesystem -lboost_thread
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: glx.o: in function `DisplayOutput::CUnixGL::Initialize(unsigned int, unsigned int, bool)':
glx.cpp:(.text+0x9f0): undefined reference to `glXSwapIntervalSGI'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: glx.cpp:(.text+0xbde): undefined reference to `glXSwapIntervalSGI'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: glx.o: in function `DisplayOutput::CUnixGL::toggleVSync()':
glx.cpp:(.text+0x107f): undefined reference to `glXSwapIntervalSGI'
/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: glx.cpp:(.text+0x1097): undefined reference to `glXSwapIntervalSGI'
Rogach commented 5 years ago

I do not see -lglee in the link command - could that be the culprit?

stefantalpalaru commented 5 years ago

There's "-lGLee" which should hit the existing "/usr/lib64/libGLee.so".

stefantalpalaru commented 5 years ago

I found the problem: eselect opengl does not affect link-time paths, so on my system it was linking against a crippled Mesa libGL.so and using, at runtime, another libGL.so from the selected Nvidia binary driver. "glXSwapIntervalSGI" is missing from the former and found in the latter.

The silly workaround is to add a USE flag for Nvidia cards and explicitly add the binary driver's path to LDFLAGS:

use video_cards_nvidia && append-ldflags -L/usr/$(get_libdir)/opengl/nvidia/lib
ExecutorElassus commented 5 years ago

I know you closed it, but I used layman to sync to the new ebuild, and remerged it, and I'm still getting all the errors from the first post. When I do emerge -pv electricsheep, I see this:

 # emerge -pv electricsheep

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R   *] x11-misc/electricsheep-9999::stefantalpalaru  0 KiB

and not the -9999-r1 version of the new ebuild. Is this expected behavior?

stefantalpalaru commented 5 years ago

How, if I deleted that version? Do you have an older instance of this repo manually added to Portage somehow?

ExecutorElassus commented 5 years ago

ah, indeed. I had an old layman tree lying around. I deleted it. Now I have the issue that the -r1 ebuild requires ffmpeg-3.4.5:0/55.57.57, when I have -4.1:0/56.58.58 on my system. Is that a hard requirement? Should I open a separate issue?

Thanks for your work on this.

Update: I removed the version from the ffmpeg dependency in my local -r1 ebuild, and it compiles and runs fine. So maybe it needs a ">=" rather than a "=" dependency?

stefantalpalaru commented 5 years ago

Thanks for the ffmpeg tip! New versions available in the overlay.

I also ended up disabling V-sync because Glee triggers a linking error when that extension is not available.

malipivo commented 5 years ago

Hello, when installing electricsheep from git clone/source (SHA1 ID 4949c31cfdb0d4363cfa726aa3aa8325e540773f) on (X)Ubuntu 18.04.02, instead of "make" I ran: make CXXFLAGS+="-DGL_GLEXT_PROTOTYPES=1" or make CXXFLAGS+="-DGL_GLEXT_PROTOTYPES" or make CXXFLAGS+=-DGL_GLEXT_PROTOTYPES Now, it seems everything is working.

stefantalpalaru commented 5 years ago

We already patch Makefile.am to do that: https://github.com/stefantalpalaru/gentoo-overlay/blob/master/x11-misc/electricsheep/files/electricsheep-glext-prototypes.patch

caffeinatedgaze commented 5 years ago

I found the problem: eselect opengl does not affect link-time paths, so on my system it was linking against a crippled Mesa libGL.so and using, at runtime, another libGL.so from the selected Nvidia binary driver. "glXSwapIntervalSGI" is missing from the former and found in the latter.

The silly workaround is to add a USE flag for Nvidia cards and explicitly add the binary driver's path to LDFLAGS:

use video_cards_nvidia && append-ldflags -L/usr/$(get_libdir)/opengl/nvidia/lib

I have the same issue on Ubuntu 18. Is there a way to apply this solution there?

stefantalpalaru commented 5 years ago

Try looking inside the "debian" subdir of the package source, modify the "rules" file and recompile the package. There's documentation here: https://wiki.debian.org/BuildingAPackage

blaze33 commented 5 years ago

I had the same issue on Ubuntu 19.04, turns out I forgot to run ./autogen.sh before ./configure and make.

zaileion commented 3 years ago

Hello, when installing electricsheep from git clone/source (SHA1 ID 4949c31cfdb0d4363cfa726aa3aa8325e540773f) on (X)Ubuntu 18.04.02, instead of "make" I ran: make CXXFLAGS+="-DGL_GLEXT_PROTOTYPES=1" or make CXXFLAGS+="-DGL_GLEXT_PROTOTYPES" or make CXXFLAGS+=-DGL_GLEXT_PROTOTYPES Now, it seems everything is working.

I have compiled this on ubuntu using the above options to fix the make error but on Debian sid it throws the following error

g++: error: DGL_GLEXT_PROTOTYPES: No such file or directory make[1]: [Makefile:563: electricsheep] Error 1 make[1]: Leaving directory '/home/zaileion/Downloads/electricsheep-master/client_generic/Client' make: [Makefile:513: all-recursive] Error 1

to fix the error use the following option

make CXXFLAGS+=-pthread

and it compiles with 0 errors