简体   繁体   中英

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

I am trying to compile a c++ program I wrote within a docker container in MacOS, but I keep getting inconsistent compiler behavior. My program compiles and runs in Windows with the docker container(with exact same settings) expectedly, but whenever I try to compile in the docker container within Mac it gives me this error. Sometimes the program will compile and run, but other times it will compile but it will not run and instead give me a segmentation fault. Most often, it will fail to compile with a message attached below. I have tried creating new docker image, but it did not seem to work. Any help would be greatly appreciated.

Edit: removed the image and formatted as a code. The compiler error shows for all C++ program that I try to compile in this environment.

Edit2: included the docker file settings.

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 file settings are as follows:

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

I was having the same problem as you.

It seems that Docker 2.4.0.0 uses gRPC-FUSE for file sharing by default. Somehow this was messing up with my build system (cmake / make).

I just switched back to osxfs, by going to Preferences > General and disable gRPC-FUSE.

This seems (at least for now) to have solved the problem for me. Could you give a try and post an update if it also have the same effect in your case?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM