Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to compile backend? #2

Open
futurepr0n opened this issue Aug 1, 2023 · 16 comments
Open

How to compile backend? #2

futurepr0n opened this issue Aug 1, 2023 · 16 comments

Comments

@futurepr0n
Copy link

Hi there! Trying to build off your work and test out the example you made. I am trying to build the backend but having some trouble. Can you tell me, did you ever have this error and manage to get past it?

[ 88%] Linking CXX executable OverLaid
ld: warning: directory not found for option '-L/opt/homebrew/lib'
Undefined symbols for architecture x86_64:
  "_glfwGetX11Display", referenced from:
      _main in main.cpp.o
  "_glfwGetX11Window", referenced from:
      _main in main.cpp.o
ld: symbol(s) not found for architecture x86_64
@TheLogicMaster
Copy link
Owner

Hmm, do you have all of the libraries listed in the CMakeLists file installed? I've only built on Linux, so I'm not sure of the experience on other platforms, but it does need to be compiled for Linux, so compiling on the Steam Deck could be an easy way.

@futurepr0n
Copy link
Author

You know what, I managed to get passed that issue - it looked like I was not properly linking to the right libraries but now I am having a new issue:

futurepr0n@Marks-MBP backend % ./build.sh         
-- The C compiler identification is AppleClang 14.0.0.14000029
-- The CXX compiler identification is AppleClang 14.0.0.14000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found GLEW: /usr/local/lib/cmake/glew/glew-config.cmake  
-- Found OpenGL: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/System/Library/Frameworks/OpenGL.framework   
-- Found X11: /usr/local/include   
-- Looking for XOpenDisplay in /usr/local/lib/libX11.dylib;/usr/local/lib/libXext.dylib
-- Looking for XOpenDisplay in /usr/local/lib/libX11.dylib;/usr/local/lib/libXext.dylib - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - not found
-- Found nlohmann_json: /usr/local/share/cmake/nlohmann_json/nlohmann_jsonConfig.cmake (found version "3.11.2") 
-- Configuring done
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
GLEW_LIBRARY
    linked by target "OverLaid" in directory /Users/futurepr0n/Development/Steam Deck/Projects/OverPLaid/backend

-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.

I am happy to try building from scratch in linux instead of trying to bash my head at this with my mac. Could you possibly let me know what distro you are using? I will create a VM and try working on this from scratch if I can't seem to get passed this GLEW_LIBRARY issue.

@TheLogicMaster
Copy link
Owner

Well, it needs to either be compiled on Linux or cross compiled on another platform for Linux, and I haven't tested doing so since I use Linux natively. Compiling in the Docker environment that Decky uses would work, but require some setup/Docker knowledge. I use Ubuntu, but any distro that has the development libraries in the package manager should work fine.

@futurepr0n
Copy link
Author

If you can recommend me a docker container to pull in order to get started I could try using that. I can try in a native ubuntu environment I was just trying to see how far on my mbp I could get.

Appreciate your quick responses, and the work you've put in so far, this looks like a neat extension

@TheLogicMaster
Copy link
Owner

https://github.com/SteamDeckHomebrew/holo-docker
That should be the Docker image that is close to the actual Steam OS setup, but it's been a while since I messed with all of that.

Should just work on Ubuntu, but the normal development tool packages for CMake and such are needed, as well as the dev versions of the used libraries.

Keep in mind that the plugin hasn't been tested for a few months, so the frontend UI likely needs a few modifications to work on current Steam OS versions, but the commits to my other plugin Animation Changer should describe the fixes that were done, along with updating the Decky Frontend Library dependency which fixes most issues.

@futurepr0n
Copy link
Author

hm thanks! I will check it out, I ended up looking at that Dockerfile from the backend directory. I had trouble just trying to get it to run though,


futurepr0n@Marks-MBP backend % docker build -t holo-base:latest .
[+] Building 18.0s (6/6) FINISHED                                                                                                                             
 => [internal] load build definition from Dockerfile                                                                                                     0.0s
 => => transferring dockerfile: 183B                                                                                                                     0.0s
 => [internal] load .dockerignore                                                                                                                        0.0s
 => => transferring context: 2B                                                                                                                          0.0s
 => [internal] load metadata for ghcr.io/steamdeckhomebrew/holo-base:latest                                                                              0.0s
 => [1/2] FROM ghcr.io/steamdeckhomebrew/holo-base:latest                                                                                                0.0s
 => [2/2] RUN pacman --noconfirm -S glfw-x11 glew cmake nlohmann-json                                                                                   14.9s
 => exporting to image                                                                                                                                   3.0s
 => => exporting layers                                                                                                                                  3.0s
 => => writing image sha256:5fd6f80b48f277e800fb19149f343dd7638b5a991314357ffb2628f1743c0683                                                             0.0s 
 => => naming to docker.io/library/holo-base:latest           
futurepr0n@Marks-MBP backend % docker run -d --name DeckyTest holo-base:latest
785d5dff2ed8f63c13c3f76316dc16d6092cbd385ea15b88aff1600d7bc25b24
docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "/backend/entrypoint.sh": stat /backend/entrypoint.sh: no such file or directory: unknown.

I will try running again from the ubuntu machine I got, but basically was successful getting the first step of just using the pnpm run build to work, but when I went to build the backend, I started getting these errors I am slowly working through.

What exactly does one need to compile the back end in order to do? Is that necessary to deploy the whole plugin? first you would run the pnpm run build, and then after its necessary to compile the backend ?

Does the dockerfile in backend/ need to be initialized before you can run build.sh? sorry for all the questions. I feel like im a step or two away from being successful

@TheLogicMaster
Copy link
Owner

It's been a while so I don't quite remember, but you probably need to mount certain directories into the container when building. Probably would have to look at the Decky workflow that builds the backends.

When the plugin runs, it just needs to have the built executable in the right directory and it should work. When testing, I would build it and manually copy it over.

The main thing is you probaby need to mount the correct build directory and such for it to build correctly and actually save the executable, but I don't quite remember the required arguments.

@TheLogicMaster
Copy link
Owner

The contents of the build script may also be useful to look at.

@futurepr0n
Copy link
Author

futurepr0n commented Aug 2, 2023

thanks, with some hackery I was able to compile:


futurepr0n@Marks-MBP backend % docker run --rm -v "${PWD}:/${PWD}" -u `id -u`:`id -g` -w "${PWD}" holo-base:latest ./build.sh
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/sbin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/sbin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found GLEW: /usr/include (found version "2.2.0") 
CMake Warning (dev) at /usr/share/cmake/Modules/FindOpenGL.cmake:315 (message):
  Policy CMP0072 is not set: FindOpenGL prefers GLVND by default when
  available.  Run "cmake --help-policy CMP0072" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  FindOpenGL found both a legacy GL library:

    OPENGL_gl_LIBRARY: /usr/lib/libGL.so

  and GLVND libraries for OpenGL and GLX:

    OPENGL_opengl_LIBRARY: /usr/lib/libOpenGL.so
    OPENGL_glx_LIBRARY: /usr/lib/libGLX.so

  OpenGL_GL_PREFERENCE has not been set to "GLVND" or "LEGACY", so for
  compatibility with CMake 3.10 and below the legacy GL library will be used.
Call Stack (most recent call first):
  CMakeLists.txt:15 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Found OpenGL: /usr/lib/libOpenGL.so   
-- Found X11: /usr/include   
-- Looking for XOpenDisplay in /usr/lib/libX11.so;/usr/lib/libXext.so
-- Looking for XOpenDisplay in /usr/lib/libX11.so;/usr/lib/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Found nlohmann_json: /usr/share/cmake/nlohmann_json/nlohmann_jsonConfig.cmake (found version "3.11.2") 
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/futurepr0n/Development/Steam Deck/Projects/OverPLaid/backend/build
[ 11%] Building CXX object CMakeFiles/imgui.dir/imgui/backends/imgui_impl_glfw.cpp.o
[ 22%] Building CXX object CMakeFiles/imgui.dir/imgui/backends/imgui_impl_opengl3.cpp.o
[ 33%] Building CXX object CMakeFiles/imgui.dir/imgui/imgui.cpp.o
[ 44%] Building CXX object CMakeFiles/imgui.dir/imgui/imgui_draw.cpp.o
[ 55%] Building CXX object CMakeFiles/imgui.dir/imgui/imgui_tables.cpp.o
[ 66%] Building CXX object CMakeFiles/imgui.dir/imgui/imgui_widgets.cpp.o
[ 77%] Linking CXX static library libimgui.a
[ 77%] Built target imgui
[ 88%] Building CXX object CMakeFiles/OverPLaid.dir/main.cpp.o
[100%] Linking CXX executable OverPLaid
[100%] Built target OverPLaid
futurepr0n@Marks-MBP backend % 

So looks like im getting somewhere, thanks for the help! I might still need to tweak some stuff, but I got a bit of a start going.

What exactly would next step be?

Lets say I have ran all the readme now, I have a build/ dir with:

futurepr0n@Marks-MBP build % ls -al        
total 9984
drwxr-xr-x   8 futurepr0n  staff      256  2 Aug 08:43 .
drwxr-xr-x  11 futurepr0n  staff      352  2 Aug 08:43 ..
-rw-r--r--   1 futurepr0n  staff    31412  2 Aug 08:43 CMakeCache.txt
drwxr-xr-x  14 futurepr0n  staff      448  2 Aug 08:44 CMakeFiles
-rw-r--r--   1 futurepr0n  staff    11819  2 Aug 08:43 Makefile
-rwxr-xr-x   1 futurepr0n  staff  2379752  2 Aug 08:44 OverPLaid
-rw-r--r--   1 futurepr0n  staff     1711  2 Aug 08:43 cmake_install.cmake
-rw-r--r--   1 futurepr0n  staff  1902062  2 Aug 08:43 libimgui.a

I would take OverPlaid and I need to move that onto the Deck in plugins? or how exactly do I package what I built with pnpm and build.sh now? Almost there... hah, thanks

What I have left now is:
Project Base Dir:
Screen Shot 2023-08-02 at 9 02 46 AM

backend directory:

Screen Shot 2023-08-02 at 9 03 21 AM

build directory:
Screen Shot 2023-08-02 at 9 04 04 AM

Out directory:
Screen Shot 2023-08-02 at 9 03 40 AM

Install pnpm and run pnpm i in the repo directory. (done)
Build with: pnpm run build. (done)
Run the build.sh script for compiling the backend (done)
Copying the project to the SDH plugins directory ~/homebrew/plugins at this point will install it.
The contents of the backend/out need to be copied to OverLaid/bin when installing.
The VSCode task handles copying the project to the Deck cleanly without any unnecessary files and handles file permissions.

Am I supposed to create OverLaid/bin myself? or is there supposed to be a directory with OverLaid created and it should have bin/ already in there with more stuff?

I am seeing the VSCode stuff is supposed to copy everything over to the steamdeck, I could do this manually but Im just not sure if i have the build process proper - should I build the npm after building the backend? or what am I supposed to do after if I wanted to manually package it all and put on the Deck in the plugin dir. Do I need everything from the Main Repo Directory? and then ontop of that add a /bin directory with the contents of /out?

@TheLogicMaster
Copy link
Owner

I'm not sure if the VSCode is supposed to copy backend stuff or not, but probably just make the bin directory and paste the Overlaid binary file in it. There's definitely issues in the frontend source that may entirely prevent the UI from working, though, especially with dialogs and the quick access menu checks, plus the Decky frontend lib version needs updating.

@TheLogicMaster
Copy link
Owner

It doesn't hurt to paste the whole directory, but only a few of the files are actually needed, and VSCode should copy most of them.

@JesusLuvsYooh
Copy link

JesusLuvsYooh commented Aug 16, 2023

@futurepr0n Not sure if you figured it out in the end, but heres what you need in the directory after building.
(theres no harm in having the other files too, no idea what this plugin requires)

Screenshot 2023-08-16 at 08 20 05

Then Zip it, and upload through Decky Loaders Developer section (on steam decks game mode).

@futurepr0n
Copy link
Author

futurepr0n commented Aug 16, 2023 via email

@JesusLuvsYooh
Copy link

JesusLuvsYooh commented Aug 18, 2023

I got a step further, no crashes. @futurepr0n
I can create text and text background colour, the image picture doe not work, but enabled or editing the overlay does not make one appear on screen.

Honestly we probably need @TheLogicMaster to jump in and release an update,
(or to give us some pointers, if LogicM does not have the time to test and build, we'l happily do that for you)
After, we can always compare whats different from current version to new version to help us understand, as i also just started with all this, so learning too :)

@futurepr0n
Copy link
Author

@JesusLuvsYooh Any chance you could take a look at my update - https://github.com/futurepr0n/OverPLaid to merge your code and/or provide what you did in your updates? I am going to try and pursue this, Im not sure why my fork doesnt allow me to make issues but we can take that over there and close that - thanks for your help both of you. Thanks for the great start and your help TLM

@TheLogicMaster
Copy link
Owner

Just pushed a commit which updates the frontend lib, fixes quick access menu detection, and gets the image widget mostly working. I saw a few weird issues like the enable toggle not working (The toggle event wasn't even being called), but everything worked after moving between menus to refresh everything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants