簡體   English   中英

跨操作系統的編譯器行為不一致(使用 ubuntu docker 容器的 Mac OS/Windows)(“無符號”的多重定義)

[英]Compiler behavior inconsistent across Operating System(Mac OS/Windows using ubuntu docker container) (multiple definition of 'no symbol')

我正在嘗試編譯我在 MacOS 中的 docker 容器中編寫的 c++ 程序,但我一直得到不一致的編譯器行為。 我的程序按預期使用 docker 容器(具有完全相同的設置)在 Windows 中編譯和運行,但是每當我嘗試在 Mac 中的 docker 容器中編譯時,它都會給我這個錯誤。 有時程序會編譯並運行,但有時它會編譯但不會運行,而是給我一個分段錯誤。 大多數情況下,編譯失敗,並附上一條消息。 我嘗試創建新的 docker 鏡像,但似乎沒有用。 任何幫助將不勝感激。

編輯:刪除圖像並格式化為代碼。 對於我嘗試在此環境中編譯的所有 C++ 程序,都會顯示編譯器錯誤。

Edit2:包括 docker 文件設置。

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文件設置如下:

#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"

我和你有同樣的問題。

Docker 2.4.0.0 似乎默認使用 gRPC-FUSE 進行文件共享。 不知何故,這弄亂了我的構建系統(cmake / make)。

我剛剛切換回 osxfs,轉到 Preferences > General 並禁用 gRPC-FUSE。

這似乎(至少現在)已經為我解決了這個問題。 如果它在您的情況下也有相同的效果,您可以嘗試並發布更新嗎?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM