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

Unable to compile on arch linux #1

Closed
iliesh opened this issue Mar 25, 2024 · 12 comments
Closed

Unable to compile on arch linux #1

iliesh opened this issue Mar 25, 2024 · 12 comments

Comments

@iliesh
Copy link

iliesh commented Mar 25, 2024

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
@cococry
Copy link
Owner

cococry commented Mar 25, 2024

It seems that leif is not built, try doing

make rebuild install

and then

lyssa

@iliesh
Copy link
Author

iliesh commented Mar 25, 2024

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)

@cococry
Copy link
Owner

cococry commented Mar 26, 2024

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

@iliesh
Copy link
Author

iliesh commented Mar 27, 2024

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

@cococry
Copy link
Owner

cococry commented Mar 27, 2024

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)

@iliesh
Copy link
Author

iliesh commented Mar 31, 2024

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?

@cococry
Copy link
Owner

cococry commented Mar 31, 2024

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.

@icefishii
Copy link

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?

@iliesh
Copy link
Author

iliesh commented Apr 12, 2024

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
Copy link
Author

iliesh commented Apr 12, 2024

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.

@xXDrkLeoXx
Copy link

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.

@iliesh
Copy link
Author

iliesh commented Jun 4, 2024

Yes, that works now. Thank you @xXDrkLeoXx !

@iliesh iliesh closed this as completed Jun 4, 2024
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

4 participants