bazukas / obs-linuxbrowser

OBS Linux Browser Plugin
GNU General Public License v2.0
502 stars 47 forks source link

Build system incompatible with Ubuntu 16.10 and lower / Compile error due to CEF API changes in newer releases. #94

Closed gyles19 closed 5 years ago

gyles19 commented 5 years ago

I just wasted most of my day off trying to build this for Ubuntu 16.04. This version of the plugin can't even be built on Ubuntu 16.04 or 18.04 (The LTS releases.) Only the bleeding edge 18.10 can build it and I don't have that OS installed anywhere yet.

To build this plugin you MUST have:

cmake 3.8.something gcc-8.x (total show stopper on Ubuntu < 18.10.)

I managed to work around the cmake requirement by building cmake from source, but I draw that line at custom building all of gcc and all of the system libraries.

I'm pretty irritated right now. Rm -rf the whole project off my system. Please be more specific with the version dependencies that exclude 90% of the ubuntu users out here.

NexAdn commented 5 years ago

Unfortunately, I must have made mistake when I was refactoring the build script.

https://gist.github.com/NexAdn/e72d2674cbe71bf514f3d4cec0b50cf4

This patch should fix your issue. It lowers the minimum required CMake version to 3.0 ([1]) and should fix the requirement for GCC >= 8 by requiring C++11 standard explicitly ([2]). Could you please confirm that the above patch enables you to build obs-linuxbrowser with default Ubuntu packages?

[1] Tested with 3.1. Unfortunately I was unable to build a version lower than 3.1. [2] Before that, it was stated as a requirement using compile features, but obviously that didn't work well on your system.

gyles19 commented 5 years ago

Thank you for your response! I've come back to make another attempt. It still fails, but it gets further than it did before.

I downloaded the latest 64-bit binary for cef standard distribution, followed your directions and built the wrapper library without any visible errors.

I did a git-clone of the current obs-linuxbrowser master branch. Then I did a wget of the zip file of your patch from the email, and applied that, and verified it changed the CMakeLists.txt file. Then I followed the cmake/make directions from the README.md on Github, mostly. (The README.md says to issue "mkdir build; cd build" before running the cmake, but the cmake fails within the build directory because it can't find the CMakeLists.txt file. So I "cd .." and run from there, which seems to work. I think the README.md also needs some correction.)

The output from that build step in the obs-linuxbrowser src root is attached. build.log

The gist of it is:

In file included from /home/joi/src/obs-linuxbrowser/src/browser/browser-app.hpp:25:0,
                 from /home/joi/src/obs-linuxbrowser/src/browser/browser-app.cpp:29:
/home/joi/src/obs-linuxbrowser/src/browser/browser-client.hpp:40:15: error: conflicting return type specified for ‘virtual bool BrowserClient::
GetViewRect(CefRefPtr<CefBrowser>, CefRect&)’
  virtual bool GetViewRect(CefRefPtr<CefBrowser> browser, CefRect& rect) OVERRIDE;
               ^
In file included from /home/joi/src/cef_binary_3.3578.1860.g36610bd_linux64/include/cef_client.h:54:0,
                 from /home/joi/src/obs-linuxbrowser/src/browser/browser-client.hpp:20,
                 from /home/joi/src/obs-linuxbrowser/src/browser/browser-app.hpp:25,
                 from /home/joi/src/obs-linuxbrowser/src/browser/browser-app.cpp:29:
/home/joi/src/cef_binary_3.3578.1860.g36610bd_linux64/include/../include/cef_render_handler.h:85:16: error:   overriding ‘virtual void CefRende
rHandler::GetViewRect(CefRefPtr<CefBrowser>, CefRect&)’
   virtual void GetViewRect(CefRefPtr<CefBrowser> browser, CefRect& rect) = 0;
                ^

I'll leave this stuff on my drive for further testing. I'm willing to provide compiled deb binaries for ubuntu if you wish, if we can get this working.

NexAdn commented 5 years ago

So it seems like the patch is working. I'll push it to upstream soon.

The problem that you couldn't build from the build/ directory is most likely because you've executed cmake . instead of cmake ... I have to admit that the difference might be very subtle, but unfortunately that's the syntax CMake uses. I should add some text to emphasize the importance of using two dots.

The error you get seems to be related to the newer CEF version. They must've changed something in the API. Related source code: https://github.com/bazukas/obs-linuxbrowser/blob/c4758561920f047a54a2ff145aaa3c89a0c561bd/src/browser/browser-client.hpp#L40

gyles19 commented 5 years ago

Thank you again for responding.

Regarding the build dir thing, I re-read the README.md and had misinterpreted the .. as a "insert more stuff here" ellipsis. So I took it literally and tried using the build directory again. This time, I got:

joi@tardis:~/src/obs-linuxbrowser/build$ cmake -DCEF_ROOT_DIR=~/src/cef_binary_3.3440.1803.gde363ee_linux64 ..
-- Looking for OBS Studio in prefix /usr
-- Looking for Chromium Embedded Framework in /home/joi/src/cef_binary_3.3440.1803.gde363ee_linux64
-- Configuring done
-- Generating done
-- Build files have been written to: /home/joi/src/obs-linuxbrowser
joi@tardis:~/src/obs-linuxbrowser/build$ make
make: *** No targets specified and no makefile found.  Stop.

So, it looks like cmake is still writing the makefile to the source root, not my cwd in that build directory. Cmake did create a directory with structure there. Is there still some assumption I'm missing? For what its worth, the 3.13.2 version of cmake is first in my PATH, a leftover from my first attempts. Perhaps the behavior of the newest cmake differs?

I've downloaded cef_binary_3.3440.1803.gde363ee_linux64, followed the directions for building that version's wrapper library, and after some fudging realized I needed to remove the CMakeCache.txt file before restarting the build of the obs-linuxbrowser part. I had attempted a 'make clean' that seemed to work, but it didn't remove the cache. A quick google shows there is some debate regarding how much cmake should clean up after itself. I'm an old-school dev and haven't used cmake before, I grew up using the autotools stuff. make clean, make realclean, and make distclean are all targets I tried.

And we have success! It has built successfully! And it also seems to be functional. At least, the default settings of a newly created 'Linux Browser' showing the OBS Studio website are visible within my OBS scenes. Interestingly, it's working with the current version available from OBS directly for Ubuntu 16.04, 22.0.2-0obsproject1~xenial. I had expected I'd need to pin the obs package to the earlier version 21.1.2, and I may find I need to do that once I start trying to actually use an Overlay.

Is there anything else you'd like me to try? My next step is to try using Overlays.

NexAdn commented 5 years ago

Thank you for the fast response!

The reason for the second build not to appear inside the build/ directory is most likely due to the old cache files, but it seems you have figured that out for yourself. The problem with that can be easily solved by executing the first cmake command from the build/ directory so you can reset the build by just executing rm -r build/ afterwards.

obs-linuxbrowser can be built with all recent versions (i think up to M20) as it doesn't use any newer APIs. It is only of importance that the version OBS version you are running obs-linuxbrowser with is equal or higher to the version obs-linuxbrowser has been built with.

But what I don't really understand is why the build now succeeded, because last time it seemed like the CEF authors changed something in the API which made the build fail. I'll have to inspect that a little further.

EDIT: One thing I'd really like you to test is a clean build with the default Ubuntu packages (especially cmake and gcc), not the self compiled latest releases.

gyles19 commented 5 years ago

Well, I did download the most recently known-good version of cef for the latest attempt, so having it succeed didn't seem unusual. (I found the list of known-good cef versions on one of the issue tickets. Comments in an issue is where someone said gcc 8+ was required to build, too.)

Next chance I have, I'll remove the cmake in /usr/local/bin/ and try again. The gcc is still the ubuntu 16.04 standard.

gyles19 commented 5 years ago

I've started completely from scratch. I cloned a fresh copy of the repo, and removed the locally built latest version of cmake I'd installed before. I applied the patch you provided for the CmakeLists.txt file, and then I followed the README.md instructions for building from source. It all worked the first time, using the earlier version of cef mentioned in issue #63. I was able to make, and then make install, and I'm now looking at a streamlabs alert widget inside my obs studio and I can see it on my twitch live dashboard.

It seems once you do any sort of cmake action, it litters the working dir with side effects that persist and greatly confuse any subsequent build attempts. cmake really, really needs to provide a 'make distclean' target, otherwise one just has to reclone the repo into a new working dir for every fresh attempt.

NexAdn commented 5 years ago

Thank you for your response. I'm happy to hear that the problem seems to be resolved. Regarding the CEF version problems, I'll have to inspect the problem a little further. CEF has always been somehow problematic concerning new versions (#63 being the best example for this).

The problem with CMake littering the directories can be tackled by using out-of-source builds (e.g. in the build/ directory). This avoids the need for such make instructions like distclean altogether, as you can just rm -fr your build dir and everything is cleaned up again. Whether or not CMake should include such make targets, isn't something we should discuss here. I am not a CMake developer and this is project is not part of CMake.

I will leave the issue open as a reminder for me to inspect the CEF issue you've experienced. I'm going to push the CMake patch next weekend when I'm back home.