second-state / WasmEdge-go

The GO language SDK and API for WasmEdge
https://www.secondstate.io/articles/extend-golang-app-with-webassembly-rust/
Apache License 2.0
107 stars 16 forks source link

Compile issue on Ubuntu 18.04 #13

Closed chenyukang closed 3 years ago

chenyukang commented 3 years ago

[](On Ubuntu 18.04

Try to compile some examples on machine:

Linux wasmedge 5.4.0-1055-azure #57~18.04.1-Ubuntu SMP Fri Jul 16 19:40:19 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Commands:

git clone https://github.com/second-state/WasmEdge-go-examples.git
cd go_ParseImage
go mod vendor
go build

I got many errors and I solved some but still the Glibc version is too low. Do I miss something?

Undefined reference to LLVM 12

We need to install LLVM12 for compilation.

Fix it:

wget https://apt.llvm.org/llvm.sh -O /tmp/llvm.sh
sudo bash /tmp/llvm.sh 12

Undefined reference to GLIBCXX_3.4.26

/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libwasmedge_c.so: undefined reference to `std::filesystem::__cxx11::path::_List::_List(std::filesystem::__cxx11::path::_List const&)@GLIBCXX_3.4.26'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libwasmedge_c.so: undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()@GLIBCXX_3.4.26'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libwasmedge_c.so: undefined reference to `std::filesystem::__cxx11::path::lexically_normal() const@GLIBCXX_3.4.26'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libwasmedge_c.so: undefined reference to `std::filesystem::absolute(std::filesystem::__cxx11::path const&)@GLIBCXX_3.4.26'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libwasmedge_c.so: undefined reference to `std::filesystem::__cxx11::path::_List::_List()@GLIBCXX_3.4.26'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libwasmedge_c.so: undefined reference to `std::filesystem::__cxx11::path::replace_extension(std::filesystem::__cxx11::path const&)@GLIBCXX_3.4.26'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libwasmedge_c.so: undefined reference to `std::filesystem::__cxx11::path::operator/=(std::filesystem::__cxx11::path const&)@GLIBCXX_3.4.26'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libwasmedge_c.so: undefined reference to `pthread_sigmask@GLIBC_2.32'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libwasmedge_c.so: undefined reference to `std::filesystem::file_size(std::filesystem::__cxx11::path const&, std::error_code&)@GLIBCXX_3.4.26'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libwasmedge_c.so: undefined reference to `std::filesystem::__cxx11::path::_List::_Impl_deleter::operator()(std::filesystem::__cxx11::path::_List::_Impl*) const@GLIBCXX_3.4.26'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libwasmedge_c.so: undefined reference to `std::filesystem::__cxx11::path::_M_find_extension() const@GLIBCXX_3.4.26'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libwasmedge_c.so: undefined reference to `std::filesystem::__cxx11::path::compare(std::filesystem::__cxx11::path const&) const@GLIBCXX_3.4.26'

Fix it:

Need to upgrade libstdc++6 to latest version like this

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.9
sudo apt-get upgrade libstdc++6

After that you can check if you get GLIBCXX desired version like this:

strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX

Link error can not find GLIbC_2.33

/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libwasmedge_c.so: undefined reference to `fstatat@GLIBC_2.33'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libwasmedge_c.so: undefined reference to `pthread_sigmask@GLIBC_2.32'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libwasmedge_c.so: undefined reference to `fstat@GLIBC_2.33'

Glibc version is too low, double check it:

strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBC_

I compiled and install GLIBC2.33 and then install it on /usr/local, the final error is:

# github.com/second-state/WasmEdge-go/wasmedge
/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libwasmedge_c.so: undefined reference to `fstatat@GLIBC_2.33'
//usr/local/lib/librt.so.1: undefined reference to `__futex_abstimed_wait_cancelable64@GLIBC_PRIVATE'
//usr/local/lib/librt.so.1: undefined reference to `__pthread_attr_setsigmask_internal@GLIBC_PRIVATE'
//usr/local/lib/librt.so.1: undefined reference to `__futex_abstimed_wait64@GLIBC_PRIVATE'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libwasmedge_c.so: undefined reference to `pthread_sigmask@GLIBC_2.32'
/usr/lib/gcc/x86_64-linux-gnu/7/../../../../lib/libwasmedge_c.so: undefined reference to `fstat@GLIBC_2.33'
//usr/lib/x86_64-linux-gnu/libLLVM-12.so.1: undefined reference to `clock_gettime@GLIBC_2.2.5'
collect2: error: ld returned 1 exit status

with GLIBC:

image

chenyukang commented 3 years ago

I can compile it on Ubuntu 20.04, even without install LLVM12. This is my GLIBC info: image

hydai commented 3 years ago

Sorry about the inconvenience, our wasmedge deb release is based on Ubuntu 20.04 with LLVM 12. If you want to use an old version of Ubuntu, please use the installation script. It will download the manylinux2014 build which is based on CentOS 7 and is compatible with most popular linux distributions

$ wget https://github.com/second-state/WasmEdge-go/releases/download/v0.8.1/install_wasmedge.sh
$ sudo ./install_wasmedge.sh /usr/local

Ref: https://github.com/second-state/WasmEdge-go#wasmedge-shared-library-installation

chenyukang commented 3 years ago

Yes, I tried to use this script, but does not work. Maybe something is broken. anyway my old ubuntu VM is not in the right state. I will use a new empty VM to confirm it.