lyssa icon indicating copy to clipboard operation
lyssa copied to clipboard

Unable to compile on arch linux

Open iliesh opened this issue 11 months ago • 10 comments

Tried to compile on arch, but got an error:

~/lyssa on git main > make
[INFO]: Leif already built.
[INFO]: Building Lyssa.
g++ -O3 -ffast-math -DGLFW_INCLUDE_NONE  src/*.cpp -o bin/lyssa -Ivendor/miniaudio -Ivendor/leif/include -Ivendor/leif/vendor/glad/include -lleif -lclipboard -Lvendor/leif/lib -lglfw -ltag -lm -Lvendor/miniaudio/lib -lminiaudio
/usr/bin/ld: cannot find -lleif: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [Makefile:26: build] Error 1

iliesh avatar Mar 25 '24 12:03 iliesh

It seems that leif is not built, try doing

make rebuild install

and then

lyssa

cococry avatar Mar 25 '24 12:03 cococry

Yes, now it did compile, but crashing at the start:

~/lyssa on git main underwent 22s781ms> lyssa [LEIF ERROR]: Failed to open font file '/home/user/.leif/assets/fonts/inter.ttf'

[1] 2784 segmentation fault (core dumped) lyssa

Stack trace of thread 2784: #0 0x000079220c4b9157 fseek (libc.so.6 + 0x7f157) #1 0x0000585812de38a1 load_font (lyssa + 0x9f8a1) #2 0x0000585812de58b2 lf_load_font_asset (lyssa + 0xa18b2) #3 0x0000585812de5929 lf_default_theme (lyssa + 0xa1929) #4 0x0000585812de5c66 lf_init_glfw (lyssa + 0xa1c66) #5 0x0000585812d535c3 main (lyssa + 0xf5c3) #6 0x000079220c45fcd0 n/a (libc.so.6 + 0x25cd0) #7 0x000079220c45fd8a __libc_start_main (libc.so.6 + 0x25d8a) #8 0x0000585812d55d55 _start (lyssa + 0x11d55)

iliesh avatar Mar 25 '24 16:03 iliesh

i added the .leif folder to the install make script so if you clone again and folder the installation instructions, everything should work fine.

cococry avatar Mar 26 '24 20:03 cococry

No luck,

~/lyssa on git main > lyssa
[LEIF ERROR]: Failed to open font file '/home/user/.leif/assets/fonts/inter.ttf'

[1]    8424 segmentation fault (core dumped)  lyssa
~/lyssa on git main x ls -l /home/user/.leif/assets/fonts/inter.ttf
-rw-r--r-- 1 user users 547120 Mar 27 08:36 /home/user/.leif/assets/fonts/inter.ttf

iliesh avatar Mar 27 '24 08:03 iliesh

did you reclone the repo? and if yes, did you do make install?

if you did both, manually copy (lyssa dir)/vendor/leif/.leif into ~ (home dir)

cococry avatar Mar 27 '24 13:03 cococry

Yes, I reclone-d again this repo and did mare rebuild. I've tried with make install, and still the same isseu. The thing is that font actually exists on the filesystem:

[LEIF ERROR]: Failed to open font file '/home/user/.leif/assets/fonts/inter.ttf'

[1]    2969219 segmentation fault (core dumped)  lyssa

~/lyssa on git main x ls -l /home/user/.leif/assets/fonts/inter.ttf
-rw-r--r-- 1 user users 547120 Mar 31 10:56 /home/user/.leif/assets/fonts/inter.ttf

and user have all permission to that file.

Trying to trace all system calls when starting the app, and noticed this:

openat(AT_FDCWD, "/home/user/.leif\3/assets/fonts/inter.ttf", O_RDONLY) = -1 ENOENT (No such file or directory)
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
write(1, "[LEIF ERROR]: Failed to open fon"..., 82[LEIF ERROR]: Failed to open font file '/home/user/.leif/assets/fonts/inter.ttf'
) = 82
write(1, "\n", 1
)                       = 1
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=NULL} ---
+++ killed by SIGSEGV (core dumped) +++
[1]    2969706 segmentation fault (core dumped)  strace lyssa

not sure what \3 means here, maybe that's the problem?

iliesh avatar Mar 31 '24 11:03 iliesh

i already built lyssa on multiple arch systems and never got this kind of issue. you could try to fopen() the font file in another c file and test if it works there. but one issue that i know is that leif cannot start because of a outdated graphics driver. you could try updating your driver and see if it works. also you can try to compile a c program that starts a glfw window, updates it etc. (https://www.glfw.org/documentation.html) and after glfwMakeContextCurrent, call lf_init_glfw(width, height, glfw_win); and check the output.

cococry avatar Mar 31 '24 11:03 cococry

Yes, I reclone-d again this repo and did mare rebuild. I've tried with make install, and still the same isseu. The thing is that font actually exists on the filesystem:

[LEIF ERROR]: Failed to open font file '/home/user/.leif/assets/fonts/inter.ttf'

[1]    2969219 segmentation fault (core dumped)  lyssa

~/lyssa on git main x ls -l /home/user/.leif/assets/fonts/inter.ttf
-rw-r--r-- 1 user users 547120 Mar 31 10:56 /home/user/.leif/assets/fonts/inter.ttf

and user have all permission to that file.

Trying to trace all system calls when starting the app, and noticed this:

openat(AT_FDCWD, "/home/user/.leif\3/assets/fonts/inter.ttf", O_RDONLY) = -1 ENOENT (No such file or directory)
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
write(1, "[LEIF ERROR]: Failed to open fon"..., 82[LEIF ERROR]: Failed to open font file '/home/user/.leif/assets/fonts/inter.ttf'
) = 82
write(1, "\n", 1
)                       = 1
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=NULL} ---
+++ killed by SIGSEGV (core dumped) +++
[1]    2969706 segmentation fault (core dumped)  strace lyssa

not sure what \3 means here, maybe that's the problem?

getting the same error on my arch laptop, any update on this?

icefishii avatar Apr 09 '24 19:04 icefishii

i already built lyssa on multiple arch systems and never got this kind of issue. you could try to fopen() the font file in another c file and test if it works there. but one issue that i know is that leif cannot start because of a outdated graphics driver. you could try updating your driver and see if it works. also you can try to compile a c program that starts a glfw window, updates it etc. (https://www.glfw.org/documentation.html) and after glfwMakeContextCurrent, call lf_init_glfw(width, height, glfw_win); and check the output.

I'm not too familiar with c, but with the help of ChatGPT I came up with the following application:

#include <stdio.h>

int main() {
    // Path to the file
    const char *file_path = "/home/user/.leif/assets/fonts/inter.ttf";
    
    // Open the file in read mode
    FILE *file = fopen(file_path, "rb");
    
    // Check if file opening was successful
    if (file == NULL) {
        perror("Error opening file");
        return 1; // Return with error status
    }
    
    printf("File opened successfully!\n");
    
    // Close the file
    fclose(file);
    
    return 0; // Return success
}

I compiled it and I got success running it:

gcc app.c -o fontapp
./fontapp
File opened successfully!

iliesh avatar Apr 12 '24 16:04 iliesh

I tried to run this application and it run successfully:


int main(void)
{
    GLFWwindow* window;

    /* Initialize the library */
    if (!glfwInit())
        return -1;

    /* Create a windowed mode window and its OpenGL context */
    window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL);
    if (!window)
    {
        glfwTerminate();
        return -1;
    }

    /* Make the window's context current */
    glfwMakeContextCurrent(window);

    /* Loop until the user closes the window */
    while (!glfwWindowShouldClose(window))
    {
        /* Render here */
        glClear(GL_COLOR_BUFFER_BIT);

        /* Swap front and back buffers */
        glfwSwapBuffers(window);

        /* Poll for and process events */
        glfwPollEvents();
    }

    glfwTerminate();
    return 0;
}

Compiled it:

gcc app3.c -o hello_world -lglfw -lGL -lX11 -lpthread -lXrandr -lXi -ldl

I'm using hyprland, not sure if that matters.

iliesh avatar Apr 12 '24 16:04 iliesh

I also had the issue about the font loading for a long time but since the merge of this patch in the leif library, I don't encounter it anymore, you should try rebuilding it with the most up to date version of leif.

xXDrkLeoXx avatar Jun 03 '24 18:06 xXDrkLeoXx

Yes, that works now. Thank you @xXDrkLeoXx !

iliesh avatar Jun 04 '24 08:06 iliesh