~scoopta/wlrobs#13: 
Possible missing keyword in header files?

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 :).

Status
RESOLVED FIXED
Submitter
~webpigeon
Assigned to
Submitted
1 year, 5 months ago
Updated
1 year, 5 months ago
Labels
bug

~scoopta 1 year, 5 months ago

Hmmm, so it should have been marked extern from the beginning and I fixed it with b97d352dd1ab however, that now makes me curious as it's built successfully everywhere thus far. What build chain are you using? Is it gcc or clang and if it's gcc what version? If it's clang that probably explains it already as I don't use or test clang on any of my projects.

~webpigeon 1 year, 5 months ago

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 :) ).

Register here or Log in to comment, or comment via email.