#13 Possible missing keyword in header files? 1 year, 7 months ago

Comment by ~webpigeon on ~scoopta/wlrobs

My toolchain is gcc from the Fedora repos:

gcc (GCC) 10.0.1 20200328 (Red Hat 10.0.1-0.11) Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I managed to build it on my work machine earlier in the year, but that might have been either an older commit, an older version of gcc or possibly both (I'd check but I can't get to work at the moment due to isolation rules :) ).

#13 Possible missing keyword in header files? 1 year, 7 months ago

Ticket created by ~webpigeon on ~scoopta/wlrobs

I tried to compile this on Fedora 32 today and it refused:

ninja: Entering directory `build'
[2/2] Linking target libwlrobs.so
FAILED: libwlrobs.so 
cc  -o libwlrobs.so 'wlrobs@sha/src_main.c.o' 'wlrobs@sha/proto_xdg-output-unstable-v1-protocol.c.o' 'wlrobs@sha/src_scpy_source.c.o' 'wlrobs@sha/proto_wlr-screencopy-unstable-v1-protocol.c.o' -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -shared -fPIC -Wl,--start-group -Wl,-soname,libwlrobs.so /usr/lib64/libwayland-client.so /usr/lib64/libobs.so -lrt /usr/lib64/libX11.so -Wl,--end-group
/usr/bin/ld: wlrobs@sha/src_scpy_source.c.o:(.data.rel.local+0x0): multiple definition of `scpy_source'; wlrobs@sha/src_main.c.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

I did some googling and found out that the problem seemed to be the definition of the struct in the headers. As it's being declared twice (once in main and once in the backend's .c file).

I made the following change in the header:

extern struct obs_source_info scpy_source;

and then it compiled again :), not sure if I was meant to do that (I don't do a lot of C) but it seemed to work :).