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

[Building error]: /usr/bin/ld: CMakeFiles/zimg.dir/zaccess.c.o:(.bss+0x0): multiple definition of `settings'; CMakeFiles/zimg.dir/main.c.o:(.bss+0x20): first defined here #268

Open
gadefox opened this issue Sep 14, 2021 · 4 comments

Comments

@gadefox
Copy link

gadefox commented Sep 14, 2021

I'm trying to build the lib from the source (make in the root) and I'm getting the following error. Any idea??

/usr/bin/ld: CMakeFiles/zimg.dir/zaccess.c.o:(.bss+0x0): multiple definition of settings'; CMakeFiles/zimg.dir/main.c.o:(.bss+0x20): first defined here /usr/bin/ld: CMakeFiles/zimg.dir/zaccess.c.o:(.bss+0xd80): multiple definition of thread_key'; CMakeFiles/zimg.dir/main.c.o:(.bss+0xda0): first defined here
/usr/bin/ld: CMakeFiles/zimg.dir/zcache.c.o:(.bss+0x0): multiple definition of settings'; CMakeFiles/zimg.dir/main.c.o:(.bss+0x20): first defined here /usr/bin/ld: CMakeFiles/zimg.dir/zcache.c.o:(.bss+0xd80): multiple definition of thread_key'; CMakeFiles/zimg.dir/main.c.o:(.bss+0xda0): first defined here
/usr/bin/ld: CMakeFiles/zimg.dir/zdb.c.o:(.bss+0x0): multiple definition of settings'; CMakeFiles/zimg.dir/main.c.o:(.bss+0x20): first defined here /usr/bin/ld: CMakeFiles/zimg.dir/zdb.c.o:(.bss+0xd80): multiple definition of thread_key'; CMakeFiles/zimg.dir/main.c.o:(.bss+0xda0): first defined here
/usr/bin/ld: CMakeFiles/zimg.dir/zhttpd.c.o:(.bss+0x0): multiple definition of settings'; CMakeFiles/zimg.dir/main.c.o:(.bss+0x20): first defined here /usr/bin/ld: CMakeFiles/zimg.dir/zhttpd.c.o:(.bss+0xd80): multiple definition of thread_key'; CMakeFiles/zimg.dir/main.c.o:(.bss+0xda0): first defined here
/usr/bin/ld: CMakeFiles/zimg.dir/zimg.c.o:(.bss+0x0): multiple definition of settings'; CMakeFiles/zimg.dir/main.c.o:(.bss+0x20): first defined here /usr/bin/ld: CMakeFiles/zimg.dir/zimg.c.o:(.bss+0xd80): multiple definition of thread_key'; CMakeFiles/zimg.dir/main.c.o:(.bss+0xda0): first defined here
/usr/bin/ld: CMakeFiles/zimg.dir/zlog.c.o:(.bss+0x0): multiple definition of settings'; CMakeFiles/zimg.dir/main.c.o:(.bss+0x20): first defined here /usr/bin/ld: CMakeFiles/zimg.dir/zlog.c.o:(.bss+0xd80): multiple definition of thread_key'; CMakeFiles/zimg.dir/main.c.o:(.bss+0xda0): first defined here
/usr/bin/ld: CMakeFiles/zimg.dir/zlscale.c.o:(.bss+0xd80): multiple definition of thread_key'; CMakeFiles/zimg.dir/main.c.o:(.bss+0xda0): first defined here /usr/bin/ld: CMakeFiles/zimg.dir/zlscale.c.o:(.bss+0x0): multiple definition of settings'; CMakeFiles/zimg.dir/main.c.o:(.bss+0x20): first defined here
/usr/bin/ld: CMakeFiles/zimg.dir/zscale.c.o:(.bss+0x0): multiple definition of settings'; CMakeFiles/zimg.dir/main.c.o:(.bss+0x20): first defined here /usr/bin/ld: CMakeFiles/zimg.dir/zscale.c.o:(.bss+0xd80): multiple definition of thread_key'; CMakeFiles/zimg.dir/main.c.o:(.bss+0xda0): first defined here
/usr/bin/ld: CMakeFiles/zimg.dir/zspinlock.c.o:(.bss+0x0): multiple definition of settings'; CMakeFiles/zimg.dir/main.c.o:(.bss+0x20): first defined here /usr/bin/ld: CMakeFiles/zimg.dir/zspinlock.c.o:(.bss+0xd80): multiple definition of thread_key'; CMakeFiles/zimg.dir/main.c.o:(.bss+0xda0): first defined here
/usr/bin/ld: CMakeFiles/zimg.dir/zutil.c.o:(.bss+0x0): multiple definition of settings'; CMakeFiles/zimg.dir/main.c.o:(.bss+0x20): first defined here /usr/bin/ld: CMakeFiles/zimg.dir/zutil.c.o:(.bss+0xd80): multiple definition of thread_key'; CMakeFiles/zimg.dir/main.c.o:(.bss+0xda0): first defined here
/usr/bin/ld: CMakeFiles/zimg.dir/home/fox/.build/zimg-3.1.0/deps/libevhtp/evthr.c.o:(.bss+0x0): multiple definition of thread_key'; CMakeFiles/zimg.dir/main.c.o:(.bss+0xda0): first defined here /usr/bin/ld: CMakeFiles/zimg.dir/home/fox/.build/zimg-3.1.0/deps/libevhtp/evhtp.c.o:(.bss+0x0): multiple definition of thread_key'; CMakeFiles/zimg.dir/main.c.o:(.bss+0xda0): first defined here
/usr/bin/ld: CMakeFiles/zimg.dir/home/fox/.build/zimg-3.1.0/deps/multipart-parser-c/multipart_parser.c.o:(.bss+0x0): multiple definition of settings'; CMakeFiles/zimg.dir/main.c.o:(.bss+0x20): first defined here /usr/bin/ld: CMakeFiles/zimg.dir/home/fox/.build/zimg-3.1.0/deps/multipart-parser-c/multipart_parser.c.o:(.bss+0xd80): multiple definition of thread_key'; CMakeFiles/zimg.dir/main.c.o:(.bss+0xda0): first defined here

@daidehu6831
Copy link

The default "-fcommon" flag changed to "-fno-common" in GCC 10.
This problem is fixed by adding -DCMAKE_C_FLAGS=-fcommon into Makefile when running cmake.

image

@ZhangPengchao
Copy link

ZhangPengchao commented Jul 13, 2022 via email

@libin47
Copy link

libin47 commented Nov 27, 2024

遇到了同样的问题,方案如下:

  • 修改src/zcommon.h文件
    将其中的
struct setting{...} settings;

改为

struct setting{};
extern struct setting settings;
  • 新建src/zcommon.c
#include "zcommon.h"
struct setting settings;
  • 修改deps/libevhtp/evthr.h文件
pthread_key_t thread_key;
改为
extern pthread_key_t thread_key;
  • 修改deps/libevhtp/evthr.c文件
    在30行后新加一行
pthread_key_t thread_key;

然后删掉build目录,重新make就可以了

@ZhangPengchao
Copy link

ZhangPengchao commented Nov 27, 2024 via email

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