首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >不同操作系统之间的编译器行为不一致(Mac OS/Windows使用ubuntu docker容器)(“无符号”的多个定义)

不同操作系统之间的编译器行为不一致(Mac OS/Windows使用ubuntu docker容器)(“无符号”的多个定义)
EN

Stack Overflow用户
提问于 2020-10-13 09:30:47
回答 1查看 166关注 0票数 2

我正在尝试编译我在MacOS中的docker容器中编写的c++程序,但我总是得到不一致的编译器行为。我的程序使用docker容器(使用完全相同的设置)在Windows中编译和运行,但每当我试图在Mac的docker容器中编译时,它都会给我这个错误。有时程序会编译并运行,但有时它会编译,但不会运行,而是会给我一个分段错误。大多数情况下,它将无法编译,因为下面附加了一条消息。我尝试创建新的docker镜像,但似乎不起作用。任何帮助都将不胜感激。

编辑:删除图像并将其格式化为代码。对于我试图在这个环境中编译的所有C++程序,编译器错误都会显示出来。

Edit2:包含docker文件设置。

代码语言:javascript
运行
复制
root@b756b8b2e26b:~/p2# make
[CP] solutions/client.exe --> obj64/client.exe
[CXX] server/server.cc --> obj64/server.o
[CXX] server/server_storage.cc --> obj64/server_storage.o
[CXX] common/pool.cc --> obj64/pool.o
[LD] obj64/server.o obj64/server_storage.o obj64/pool.o ofiles/crypto.o ofiles/err.o ofiles/file.o ofiles/net.o ofiles/vec.o ofiles/server_args.o ofiles/server_commands.o ofiles/server_parsing.o --> obj64/server.exe
/usr/bin/ld: warning: size of symbol `' changed from 7 in obj64/server_storage.o to 82 in obj64/server_storage.o
/usr/bin/ld: obj64/server_storage.o: in function `no symbol':
:(.text+0xb10): multiple definition of `no symbol'; obj64/server_storage.o::(.text+0xb10): first defined here
/usr/bin/ld: obj64/server_storage.o: in function `no symbol':
:(.text+0xb70): multiple definition of `no symbol'; obj64/server_storage.o::(.text+0xb10): first defined here
/usr/bin/ld: obj64/server_storage.o: in function `no symbol':
:(.text+0xef0): multiple definition of `no symbol'; obj64/server_storage.o::(.text+0xb10): first defined here
/usr/bin/ld: obj64/server_storage.o: in function `no symbol':
:(.text+0x1180): multiple definition of `no symbol'; obj64/server_storage.o::(.text+0xb10): first defined here
/usr/bin/ld: obj64/server_storage.o: in function `no symbol':
:(.text+0x1560): multiple definition of `no symbol'; obj64/server_storage.o::(.text+0xb10): first defined here
/usr/bin/ld: obj64/server_storage.o: in function `no symbol':
:(.text+0x1970): multiple definition of `no symbol'; obj64/server_storage.o::(.text+0xb10): first defined here
/usr/bin/ld: obj64/server_storage.o: in function `no symbol':
:(.text+0x2370): multiple definition of `no symbol'; obj64/server_storage.o::(.text+0xb10): first defined here
/usr/bin/ld: obj64/server_storage.o: in function `no symbol':
:(.text+0x2380): multiple definition of `no symbol'; obj64/server_storage.o::(.text+0xb10): first defined here
/usr/bin/ld: obj64/server_storage.o: in function `no symbol':
:(.text+0x2760): multiple definition of `no symbol'; obj64/server_storage.o::(.text+0xb10): first defined here
/usr/bin/ld: obj64/server_storage.o: in function `no symbol':
:(.text+0x2b50): multiple definition of `no symbol'; obj64/server_storage.o::(.text+0xb10): first defined here
/usr/bin/ld: obj64/server_storage.o: in function `no symbol':
:(.text+0x2fd0): multiple definition of `no symbol'; obj64/server_storage.o::(.text+0xb10): first defined here
/usr/bin/ld: obj64/server_storage.o: in function `no symbol':
:(.text+0x3b10): multiple definition of `no symbol'; obj64/server_storage.o::(.text+0xb10): first defined here
/usr/bin/ld: obj64/server_storage.o: in function `no symbol':
:(.text+0x40b0): multiple definition of `no symbol'; obj64/server_storage.o::(.text+0xb10): first defined here
/usr/bin/ld: obj64/server_storage.o: in function `no symbol':
:(.text+0x4630): multiple definition of `no symbol'; obj64/server_storage.o::(.text+0xb10): first defined here
/usr/bin/ld: obj64/server_storage.o: in function `no symbol':
:(.text+0x5fd0): multiple definition of `no symbol'; obj64/server_storage.o::(.text+0xb10): first defined here
/usr/bin/ld: obj64/server_storage.o: in function `no symbol':
:(.text+0x5fd0): multiple definition of `no symbol'; obj64/server_storage.o::(.text+0xb10): first defined here
/usr/bin/ld: error in obj64/server_storage.o(.eh_frame); no .eh_frame_hdr table will be created
/usr/bin/ld: obj64/server.o: in function `main.cold':
/root/p2/server/server.cc:43: undefined reference to `Storage::~Storage()'
/usr/bin/ld: obj64/server.o: in function `main':
/root/p2/server/server.cc:43: undefined reference to `Storage::Storage(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long)'
/usr/bin/ld: /root/p2/server/server.cc:44: undefined reference to `Storage::load()'
/usr/bin/ld: /root/p2/server/server.cc:63: undefined reference to `Storage::shutdown()'
/usr/bin/ld: /root/p2/server/server.cc:43: undefined reference to `Storage::~Storage()'
/usr/bin/ld: /root/p2/server/server.cc:45: undefined reference to `Storage::~Storage()'
/usr/bin/ld: ofiles/server_commands.o: in function `server_cmd_all(int, Storage&, evp_cipher_ctx_st*, std::vector<unsigned char, std::allocator<unsigned char> > const&)':
(.text+0xd46): undefined reference to `Storage::get_all_users(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: ofiles/server_commands.o: in function `server_cmd_set(int, Storage&, evp_cipher_ctx_st*, std::vector<unsigned char, std::allocator<unsigned char> > const&)':
(.text+0xf99): undefined reference to `Storage::set_user_data(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&)'
/usr/bin/ld: ofiles/server_commands.o: in function `server_cmd_get(int, Storage&, evp_cipher_ctx_st*, std::vector<unsigned char, std::allocator<unsigned char> > const&)':
(.text+0x11ce): undefined reference to `Storage::get_user_data(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: ofiles/server_commands.o: in function `server_cmd_reg(int, Storage&, evp_cipher_ctx_st*, std::vector<unsigned char, std::allocator<unsigned char> > const&)':
(.text+0x13be): undefined reference to `Storage::add_user(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: ofiles/server_commands.o: in function `server_cmd_bye(int, Storage&, evp_cipher_ctx_st*, std::vector<unsigned char, std::allocator<unsigned char> > const&)':
(.text+0x153e): undefined reference to `Storage::auth(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: ofiles/server_commands.o: in function `server_cmd_sav(int, Storage&, evp_cipher_ctx_st*, std::vector<unsigned char, std::allocator<unsigned char> > const&)':
(.text+0x169e): undefined reference to `Storage::auth(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: (.text+0x16ad): undefined reference to `Storage::persist()'
/usr/bin/ld: ofiles/server_commands.o: in function `server_cmd_kva(int, Storage&, evp_cipher_ctx_st*, std::vector<unsigned char, std::allocator<unsigned char> > const&)':
(.text+0x1836): undefined reference to `Storage::kv_all(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: ofiles/server_commands.o: in function `server_cmd_kvi(int, Storage&, evp_cipher_ctx_st*, std::vector<unsigned char, std::allocator<unsigned char> > const&)':
(.text+0x1a99): undefined reference to `Storage::kv_insert(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&)'
/usr/bin/ld: ofiles/server_commands.o: in function `server_cmd_kvu(int, Storage&, evp_cipher_ctx_st*, std::vector<unsigned char, std::allocator<unsigned char> > const&)':
(.text+0x1cb9): undefined reference to `Storage::kv_upsert(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<unsigned char, std::allocator<unsigned char> > const&)'
/usr/bin/ld: ofiles/server_commands.o: in function `server_cmd_kvg(int, Storage&, evp_cipher_ctx_st*, std::vector<unsigned char, std::allocator<unsigned char> > const&)':
(.text+0x1e4e): undefined reference to `Storage::kv_get(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
/usr/bin/ld: ofiles/server_commands.o: in function `server_cmd_kvd(int, Storage&, evp_cipher_ctx_st*, std::vector<unsigned char, std::allocator<unsigned char> > const&)':
(.text+0x2014): undefined reference to `Storage::kv_delete(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status
make: *** [Makefile:82: obj64/server.exe] Error 1

docker文件设置如下:

代码语言:javascript
运行
复制
#initialize repos and upgrade the base system
RUN apt-get update -y
RUN apt-get upgrade -y

#Install additional software needed for development
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get install -y git man curl build-essential screen gdb libssl-dev psmisc valgrind

# Install Python.
    
RUN apt-get update && apt-get install -y --no-install-recommends \
        python3.5 \
        python3-pip \
        && \
        apt-get clean && \
        rm -rf /var/lib/apt/lists/*

#Change the working directory:
WORKDIR "/root"
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-11-02 06:35:01

我和你也有同样的问题。

看起来Docker 2.4.0.0默认使用gRPC-FUSE进行文件共享。不知何故,这搞乱了我的构建系统(cmake / make)。

我刚刚切换回osxfs,进入Preferences > General并禁用gRPC-FUSE。

这似乎(至少现在)为我解决了这个问题。如果在你的案例中也有同样的效果,你能尝试一下并发布一个更新吗?

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64327265

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档