C why i cant compile wayland source code in Freebsd via clang, cc and gcc?!

i have this simple code in wayland :
Code:
#include <stdio.h>
#include <wayland-client.h>

int
main(int argc, char *argv[])
{
    struct wl_display *display = wl_display_connect(NULL);
    if (!display) {
        fprintf(stderr, "Failed to connect to Wayland display.\n");
        return 1;
    }
    fprintf(stderr, "Connection established!\n");

    wl_display_disconnect(display);
    return 0;
}
and i installed wayland in my Freebsd system :
:~ $ sudo find / -name wayland-client.h /usr/local/include/wayland-client.h

but when i try to compile, i get this errors (problems !):
Code:
$ gcc 1.c -o 1 -I/usr/local/include
/usr/local/bin/ld: /tmp//cczWwzQl.o: in function `main':
1.c:(.text+0x15): undefined reference to `wl_display_connect'
/usr/local/bin/ld: 1.c:(.text+0x6f): undefined reference to `wl_display_disconnect'
collect2: error: ld returned 1 exit status


$ cc 1.c -o 1 -I/usr/local/include
ld: error: undefined symbol: wl_display_connect
>>> referenced by 1.c
>>>               /tmp/1-a24f58.o:(main)

ld: error: undefined symbol: wl_display_disconnect
>>> referenced by 1.c
>>>               /tmp/1-a24f58.o:(main)
cc: error: linker command failed with exit code 1 (use -v to see invocation)


$ clang 1.c -o 1 -I/usr/local/include
ld: error: undefined symbol: wl_display_connect
>>> referenced by 1.c
>>>               /tmp/1-51afd9.o:(main)

ld: error: undefined symbol: wl_display_disconnect
>>> referenced by 1.c
>>>               /tmp/1-51afd9.o:(main)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
 
Also, keep in mind that linking binaries compiled by different compilers (i.e. GCC and clang) will typically not work in practice. If the wayland-client library you are linking against was compiled with clang you should also use clang for your program - or compile everything with GCC.
 
Back
Top