mjpg-streamer icon indicating copy to clipboard operation
mjpg-streamer copied to clipboard

linker error multiple definition of `client_infos'

Open arimakai opened this issue 4 years ago • 5 comments

Hi, I found error /bin/ld: CMakeFiles/output_http.dir/output_http.c.o:(.bss+0xa50): multiple definition of `client_infos'; CMakeFiles/output_http.dir/httpd.c.o:(.bss+0x8): first defined here collect2: error: ld returned 1 exit status make[2]: *** [plugins/output_http/CMakeFiles/output_http.dir/build.make:116: plugins/output_http/output_http.so] Error 1 make[1]: *** [CMakeFiles/Makefile2:479: plugins/output_http/CMakeFiles/output_http.dir/all] Error 2 make: *** [Makefile:147: all] Error 2

When I checked code output_http.c and httpd.c both scripts have include httpd.h I fixed this problem by move struct { client_info **infos; unsigned int client_count; pthread_mutex_t mutex; } client_infos; in httpd.h to httpd.c

Can you review this point?

*Note: compiled on fedora 32 aarch64, GCC 10.0.1, cmake 3.17.0

arimakai avatar Jun 29 '20 08:06 arimakai

Could you try editing the main CMakeLists.txt file (https://github.com/jacksonliam/mjpg-streamer/blob/master/mjpg-streamer-experimental/CMakeLists.txt#L86), above the line set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--enable-new-dtags") Add a new line with: set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcommon")

jacksonliam avatar Jul 03 '20 13:07 jacksonliam

@jacksonliam Works with that change (after cleaning out CMakeCache.txt).

The issue is with client_info and client_infos being defined in the header file.

ollpu avatar Jul 10 '20 14:07 ollpu

Have the same issue after having ENABLE_HTTP_MANAGEMENT enabled.

The workaround did not fix it for me though...

EDIT: in worked with the original workaround by moving the struct around, not with the linker flags

mikegleasonjr avatar Nov 26 '20 21:11 mikegleasonjr

I had the same problem with the output_http plugin and moving the client_infos struct from httpd.h to httpd.c also resolved it.

stefan-sherwood avatar Feb 27 '22 16:02 stefan-sherwood

Building with ENABLE_HTTP_MANAGEMENT is fixed in my fork.

LMBernardo avatar Sep 04 '22 22:09 LMBernardo