s5z / zsim

A fast and scalable x86-64 multicore simulator
GNU General Public License v2.0
337 stars 186 forks source link

undefined symbol: gzwrite #174

Open iotlpf opened 7 years ago

iotlpf commented 7 years ago

I compiled zsim using gcc 4.6.4 on Ubuntu 14.04 with Linux 3.13.0-24-generic. I am using pin-2.14-71313-gcc.4.4.7-linux.

When running the simple test, I get the following error: iotlpf@lpf:~/zsim$ ./build/opt/zsim tests/simple.cfg [H] Starting zsim, built 2017年 10月 30日 星期一 12:48:07 CST (rev master:89:fb4d6e0:clean) [H] Creating global segment, 1024 MBs [H] Global segment shmid = 622597 [H] Deadlock detection ON E: E: Unable to load /home/iotlpf/zsim/build/opt/libzsim.so: /home/iotlpf/zsim/build/opt/libzsim.so: undefined symbol: gzwrite Unable to load /home/iotlpf/zsim/build/opt/libzsim.so: /home/iotlpf/zsim/build/opt/libzsim.so: undefined symbol: gzwrite [H] Child 4133 done [H] Child 4134 done [H] All children done, exiting

when I do 'ldd libzsim.so': iotlpf@lpf:~/zsim$ ldd build/opt/libzsim.so linux-vdso.so.1 => (0x00007fff93bfe000) libconfig++.so.11 => /usr/local/lib/libconfig++.so.11 (0x00007fe031acc000) libelf.so.1 => /usr/lib/x86_64-linux-gnu/libelf.so.1 (0x00007fe0318a2000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fe03169d000) librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fe031495000) libhdf5.so.101 => /usr/local/lib/libhdf5.so.101 (0x00007fe030f02000) libhdf5_hl.so.100 => /usr/local/lib/libhdf5_hl.so.100 (0x00007fe030cde000) libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fe0309da000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fe0306d4000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fe0304bd000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe0300f8000) /lib64/ld-linux-x86-64.so.2 (0x00007fe0328e9000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fe02feda000)

Now, I don't know what should i do to fix this problem。Could someone help me?

gaomy3832 commented 7 years ago

It seems gzwrite is part of zlib. Do you have it installed in your system?

iotlpf commented 7 years ago

Thank you for your reply, when I enter: sudo apt-get install zlib it says con't find the package, and I finally installed zlib1g-dev: sudo apt-get install zlib1g-dev here is the location of zlib: iotlpf@lpf:~/install/debian$ locate zlib /lib/modules/3.13.0-24-generic/kernel/crypto/zlib.ko /usr/bin/zlib-flate /usr/include/zlib.h /usr/lib/python2.7/encodings/zlib_codec.py /usr/lib/python3.4/encodings/zlib_codec.py /usr/lib/rsyslog/lmzlibw.so /usr/lib/ruby/1.9.1/x86_64-linux/zlib.so /usr/lib/syslinux/com32/include/zlib.h /usr/lib/x86_64-linux-gnu/pkgconfig/zlib.pc /usr/share/doc/zlib1g /usr/share/doc/zlib1g-dev /usr/share/doc/zlib1g/changelog.Debian.gz /usr/share/doc/zlib1g/copyright /usr/share/doc/zlib1g-dev/FAQ.gz /usr/share/doc/zlib1g-dev/README.gz /usr/share/doc/zlib1g-dev/algorithm.txt.gz /usr/share/doc/zlib1g-dev/changelog.Debian.gz /usr/share/doc/zlib1g-dev/copyright /usr/share/doc/zlib1g-dev/examples /usr/share/doc/zlib1g-dev/txtvsbin.txt.gz /usr/share/doc/zlib1g-dev/examples/README.examples /usr/share/doc/zlib1g-dev/examples/enough.c.gz /usr/share/doc/zlib1g-dev/examples/example.c.gz /usr/share/doc/zlib1g-dev/examples/fitblk.c.gz /usr/share/doc/zlib1g-dev/examples/gun.c.gz /usr/share/doc/zlib1g-dev/examples/gzappend.c.gz /usr/share/doc/zlib1g-dev/examples/gzjoin.c.gz /usr/share/doc/zlib1g-dev/examples/gzlog.c.gz /usr/share/doc/zlib1g-dev/examples/gzlog.h.gz /usr/share/doc/zlib1g-dev/examples/infcover.c.gz /usr/share/doc/zlib1g-dev/examples/minigzip.c.gz /usr/share/doc/zlib1g-dev/examples/zlib_how.html /usr/share/doc/zlib1g-dev/examples/zpipe.c.gz /usr/share/doc/zlib1g-dev/examples/zran.c.gz /usr/share/man/man1/zlib-flate.1.gz /usr/share/man/man3/zlib.3.gz /usr/src/linux-headers-4.4.0-31/include/linux/zlib.h /usr/src/linux-headers-4.4.0-31/lib/zlib_deflate /usr/src/linux-headers-4.4.0-31/lib/zlib_inflate /usr/src/linux-headers-4.4.0-31/lib/zlib_deflate/Makefile /usr/src/linux-headers-4.4.0-31/lib/zlib_inflate/Makefile /usr/src/linux-headers-4.4.0-31-generic/include/config/zlib /usr/src/linux-headers-4.4.0-31-generic/include/config/crypto/zlib.h /usr/src/linux-headers-4.4.0-31-generic/include/config/jffs2/zlib.h /usr/src/linux-headers-4.4.0-31-generic/include/config/squashfs/zlib.h /usr/src/linux-headers-4.4.0-31-generic/include/config/ubifs/fs/zlib.h /usr/src/linux-headers-4.4.0-31-generic/include/config/zlib/deflate.h /usr/src/linux-headers-4.4.0-31-generic/include/config/zlib/inflate.h /usr/src/linux-headers-4.4.0-97/include/linux/zlib.h /usr/src/linux-headers-4.4.0-97/lib/zlib_deflate /usr/src/linux-headers-4.4.0-97/lib/zlib_inflate /usr/src/linux-headers-4.4.0-97/lib/zlib_deflate/Makefile /usr/src/linux-headers-4.4.0-97/lib/zlib_inflate/Makefile /usr/src/linux-headers-4.4.0-97-generic/include/config/zlib /usr/src/linux-headers-4.4.0-97-generic/include/config/crypto/zlib.h /usr/src/linux-headers-4.4.0-97-generic/include/config/jffs2/zlib.h /usr/src/linux-headers-4.4.0-97-generic/include/config/squashfs/zlib.h /usr/src/linux-headers-4.4.0-97-generic/include/config/ubifs/fs/zlib.h /usr/src/linux-headers-4.4.0-97-generic/include/config/zlib/deflate.h /usr/src/linux-headers-4.4.0-97-generic/include/config/zlib/inflate.h /var/cache/apt/archives/zlib1g-dev_1%3a1.2.8.dfsg-1ubuntu1_amd64.deb /var/lib/dpkg/info/zlib1g-dev:amd64.list /var/lib/dpkg/info/zlib1g-dev:amd64.md5sums /var/lib/dpkg/info/zlib1g:amd64.list /var/lib/dpkg/info/zlib1g:amd64.md5sums /var/lib/dpkg/info/zlib1g:amd64.postinst /var/lib/dpkg/info/zlib1g:amd64.postrm /var/lib/dpkg/info/zlib1g:amd64.shlibs /var/lib/dpkg/info/zlib1g:amd64.symbols

iotlpf@lpf:~/zsim$ whereis zlib zlib: /usr/include/zlib.h /usr/share/man/man3/zlib.3.gz

But it didn't work either, I have no idea what should I do next.

shahrooz1997 commented 7 years ago

Do you have libelfg0 installed in your system? I encountered that error one month ago and I think I installed libelfg0 library and after that the error disappeared.

shahrooz1997 commented 6 years ago

I encountered this error again, I changed my gcc to gcc-4.7 and compile everything again. Then the zsim worked. To do this, Enter These commands: sudo apt-get install gcc-4.7 g++-4.7 gcc-4.7-multilib cd /usr/bin sudo mv gcc gcc.backup sudo mv g++ g++.backup sudo ln -s ./gcc-4.7 ./gcc sudo ln -s ./g++-4.7 ./g++

Then compile and install everything again. Hope this help

bakhshalipour commented 4 years ago

Add -fabi-version=2 -D_GLIBCXX_USE_CXX11_ABI=0 to CPPFLAGS. For example, change the following line in the SConstruct:

env["CPPFLAGS"] += " -MMD -DBIGARRAY_MULTIPLIER=1 -DUSING_XED -DTARGET_IA32E -DHOST_IA32E -fPIC -DTARGET_LINUX" to env["CPPFLAGS"] += " -MMD -DBIGARRAY_MULTIPLIER=1 -DUSING_XED -DTARGET_IA32E -DHOST_IA32E -fPIC -DTARGET_LINUX -fabi-version=2 -D_GLIBCXX_USE_CXX11_ABI=0"

YalandHong commented 3 years ago

Thank you for your reply, when I enter: sudo apt-get install zlib it says con't find the package, and I finally installed zlib1g-dev: sudo apt-get install zlib1g-dev here is the location of zlib: iotlpf@lpf:\~/install/debian$ locate zlib /lib/modules/3.13.0-24-generic/kernel/crypto/zlib.ko /usr/bin/zlib-flate /usr/include/zlib.h ... iotlpf@lpf:\~/zsim$ whereis zlib zlib: /usr/include/zlib.h /usr/share/man/man3/zlib.3.gz

But it didn't work either, I have no idea what should I do next.

@iotlpf zlib1g-dev is the correct package. But the file of the dynamic library of zlib is called libz.so, not zlib.so. However, zlib is a dependency of libhdf5. It seems that you have libhdf5 installed in your system without installing zlib, which is pretty strange.

Since you are using Ubuntu 14.04, you can install libhdf5 by simply running apt-get install libhdf5-serial-dev.

Once I encountered this problem, too. Now I replace all the libraries with the packages from the official APT repository instead of compling them on my own.

Besides, use ldd -r libzsim.so. The -r option reports all the missing objects.

ambulGruidae commented 10 months ago

I added -lz at the end of the command to generate libzsim.so, like this g++ -o build/opt/libzsim.so balabala.. -lz, and the error disappeared. Hope this is useful.

ambulGruidae commented 10 months ago

I added -lz at the end of the command to generate libzsim.so, like this g++ -o build/opt/libzsim.so balabala.. -lz, and the error disappeared. Hope this is useful.

You also can change the line in SConstruct: env["PINLIBS"] += ["hdf5", "hdf5_hl"] to env["PINLIBS"] += ["hdf5", "hdf5_hl", "z"]

yangcug commented 1 month ago

I added -lz at the end of the command to generate libzsim.so, like this g++ -o build/opt/libzsim.so balabala.. -lz, and the error disappeared. Hope this is useful.

You also can change the line in SConstruct: env["PINLIBS"] += ["hdf5", "hdf5_hl"] to env["PINLIBS"] += ["hdf5", "hdf5_hl", "z"]

I have the same issue. THIS ANSWER HELPS ME OUT.