libbz2.a,libz.so cause tokyocabinet Make failure problem Solving method
A recent whim, decided to install an Ubuntu 9.10 Live CD for programming development. I didn't think Wbui.exe was a convenient thing, if you have unfortunately chosen the Simplified Chinese before installation ~ ~ ~ ~ ~ Oh, sorry, slowly, it will be slow to connect to foreign countries, for your well-intentioned download Chinese dependent package (if your home has already fiber into the house, congratulations, you will not have this trouble). Not one night, absolutely uncertain ~ ~
Suggestions:
1. Installation of English version. Installed the system and then download the Internet, at least you can see the interface, you can do simple operation ~ Heart sureness.
2, painstakingly download a 4.5g DVD version of Ubuntu. Chinese normal is very, but it seems to be installed after the traditional, or to download the Simplified Chinese package (if you do not mind the traditional, that is to solve the problem)
3, if unfortunately fell into the simplified Chinese, do not be afraid, in the process of downloading and installing the package, press CRTL+ALT+F2, transfer to other work interface, commonly used characters program should be very familiar with, and then use PS aux view where is the apt-get process, find the PID, It's OK to kill it off. It will go into the next installation, and soon there will be a system interface. With the program, we all have a feeling, practical, Linux safe to cloth ~ ~ ~ ~
The recent blaze of small Japanese B + database tokyocabinet (hereinafter referred to as TC), the performance is indeed indisputable, but the installation is always problematic, the problem comes from a lot of dependency errors. It's really frustrating to get it done. The main problem is that TC relies on bzip2, as well as the LIBBZ2 Linux General compression tool. It's normal, but the Ubuntu,opensuse routine is not installed. I don't know what the routine is.
Perhaps the conventional is for radhat, I use 5.3 Enterprise version of the Radhat does not appear this kind of trouble.
Because the tool is too conventional, so the General people will not pay attention to the problem, but also read, online think it is tokyocabinet a bug.
Come to the point, talk about specific questions.
Problem:
1, TC make file, when the encounter relies on libbz2.a or libz.a these two libraries, there will be compile errors.
Such as:
Missing Zlib.h This file
//************************************************************************************************************* *****************//
/USR/BIN/LD:/usr/local/lib/libbz2.a (BZLIB.O): Relocation r_x86_64_32s against ' a local symbol ' can ' is ' used when Makin G A Shared object; Recompile with-fpic
/usr/local/lib/libbz2.a:could not read Symbols:bad value
COLLECT2:LD return 1
Make: * * * * [libtokyocabinet.so.8.22.0] Error 1
//************************************************************************************************************* *****************//
/USR/BIN/LD:/usr/local/lib/libz.a (CRC32.O): Relocation r_x86_64_32 against ' a local symbol ' can is used when making a Shared object; Recompile with-fpic
/usr/local/lib/libz.a:could not read Symbols:bad value
Make: * * * * [libtokyocabinet.so.8.22.0] Error 1
//************************************************************************************************************* *****************//
One of the reasons for these two problems is that bZIP's development dependency pack is not installed or not installed.
First to download the two installation packages
1, bzip2-1.0.4.tar.gz
2, zlib-1.2.3.tar.gz
I have found many solutions on the Internet. But the problem still, still compile not past.
Even with the Ubuntu apt-get install Libbz2-dev ...
Online is generally modified bZIP source code package makefile files. Pack a small thing, the knowledge must be rich. )
On-Line solutions:
Add-fpic to gcc compilation parameters (for this parameter, I have an explanation in the comments, suitable for novice C language users to understand)
But the problem is that sometimes it just doesn't work for you.
I have summed up the method:
1, Attention order problem: (These three things inter-related, really trouble)
If libbz2.a:could not read Symbols:bad value is found
You should delete the libbz2.a in the/usr/local/lib.
Go to the uncompressed zlib-1.2.3 directory and clear it with the make clean command.
Similarly,/usr/local/lib/libz.a:could not read symbols
Operation Ibid., delete the libz.a, the bzip2-1.0.4 directory to clean up the compilation of files.
If you cannot find the location of these two files, you can knock on the terminal:
Find-name libbz2.a
....
2. Modify the zlib-1.2.3 makefile file
Add GCC compilation parameters to the-fpic
Original: Cflags=-o3-duse_mmap
Modified to: Cflags=-o3-duse_mmap-fpic
If you still have a hard time, persuade you to CC=GCC directly behind the-fpic let them all independently compile
Repeat: If you have compiled before, be sure to clean it with make, otherwise it is futile.
Finally make install
3. Modify the bzip2-1.0.4 makefile file
Cc=gcc-fpic "= = This is my mad results, all let him-fpic
Ar=ar
Ranlib=ranlib
ldflags=
Bigfiles=-d_file_offset_bits=64
Cflags=-fpic-wall-winline-o2-g $ (bigfiles) "= = Of course here also can add
Similarly, BZIP2 has a makefile-libbz2_so file that will be invoked at compile time, and you can, of course, be compiled individually:
Make-f Makefile-libbz2_so
Make Clean <------------conservative advice, clean it up.
Make
Make install
The specific Bzip2 installation method can refer to:
Http://lamp.linux.gov.cn/Linux/LFS-6.2/chapter06/bzip2.html
Finally reinstall TC
I'm using the latest version: Tokyocabinet-1.4.31.tar.gz
It is estimated that some bugs should be fixed.
Make clean
Make
When output:
#================================================================
# Ready to install.
#================================================================
All right, install it make install
Test the Lower TC
/web/ttserver# tchmgr Create Test.tch
/web/ttserver# ls
Test.tch
/web/ttserver# Tchmgr put Test.tch 1 test1
/web/ttserver# Tchmgr put Test.tch 2 test2
/web/ttserver# Tchmgr Get Test.tch 2
Test2
The test was successful.
(openSUSE users, you cannot install tokyocabinet, or you can modify makefile files by this method)
Note:
Fpic parameter Explanation:
-fpic
Original: Position independant code, needed for shared libraries.
My understanding: The independent compilation code, needs to share the bitter support (rookie level translation)
-fpic
Position independant code, needed for shared libraries.
I am a bit in the dark what exactly the difference between-fpic and-fpic. It seems that-fpic works always while-fpic produces object files.
My understanding: The difference between these two parameters is that the following is always performed, and the lower case only provides a smaller object file compilation.
(Excerpt from: 163 blog, http://liuziheng5726.blog.163.com , my old blog ~)