I'm trying to install Git on a CentOS-7 server that I don't have root access to. I managed to get the source code for git, and did the following:
[som#jsClone git-1.8.3-rc1]make configure
<output omitted>
[som#jsClone git-1.8.3-rc1]./configure --prefix=$HOME/.local
<output omitted>
[som#jsClone git-1.8.3-rc1]$ make install
CC credential-store.o
In file included from credential-store.c:1:0:
cache.h:19:18: fatal error: zlib.h: No such file or directory
#include <zlib.h>
^
compilation terminated.
make: *** [credential-store.o] Error 1
[som#jsClone git-1.8.3-rc1]$
So, to solve the error, I downloaded the source code for zlib, and extracted it to a folder $HOME/make_source/zlib. So currently it has the structure:
[som#jsClone ~]$ ls make_source/ -l
total 4820
drwxrwxr-x. 21 som som 12288 Jun 22 02:44 git-1.8.3-rc1
-rwxr-xr-x. 1 root root 4440451 Jun 22 02:13 git-1.8.3-rc1.tar.gz
lrwxrwxrwx. 1 som som 16 Jun 22 02:19 Shared -> /mnt/hgfs/Shared
drwxr-xr-x. 14 som som 4096 Jun 22 02:26 zlib-1.2.11
-rwxrwxr-x. 1 som som 467960 Jun 22 02:19 zlib-1.2.11.tar.xz
I installed zlib successfully with:
[som#jsClone zlib-1.2.11]make configure
<output omitted>
[som#jsClone zlib-1.2.11]$ ./configure --prefix=$HOME/.local
Checking for gcc...
Checking for shared library support...
Building shared library libz.so.1.2.11 with gcc.
Checking for size_t... Yes.
Checking for off64_t... Yes.
Checking for fseeko... Yes.
Checking for strerror... Yes.
Checking for unistd.h... Yes.
Checking for stdarg.h... Yes.
Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf().
Checking for vsnprintf() in stdio.h... Yes.
Checking for return value of vsnprintf()... Yes.
Checking for attribute(visibility) support... Yes.
[som#jsClone zlib-1.2.11]$ make install
gcc -O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -c -o adler32.o adler32.c
gcc -O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -c -o crc32.o crc32.c
gcc -O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -c -o deflate.o deflate.c
gcc -O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -c -o infback.o infback.c
gcc -O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -c -o inffast.o inffast.c
gcc -O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -c -o inflate.o inflate.c
gcc -O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -c -o inftrees.o inftrees.c
gcc -O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -c -o trees.o trees.c
gcc -O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -c -o zutil.o zutil.c
gcc -O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -c -o compress.o compress.c
gcc -O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -c -o uncompr.o uncompr.c
gcc -O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -c -o gzclose.o gzclose.c
gcc -O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -c -o gzlib.o gzlib.c
gcc -O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -c -o gzread.o gzread.c
gcc -O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -c -o gzwrite.o gzwrite.c
ar rc libz.a adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/adler32.o adler32.c
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/crc32.o crc32.c
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/deflate.o deflate.c
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/infback.o infback.c
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/inffast.o inffast.c
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/inflate.o inflate.c
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/inftrees.o inftrees.c
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/trees.o trees.c
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/zutil.o zutil.c
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/compress.o compress.c
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/uncompr.o uncompr.c
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/gzclose.o gzclose.c
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/gzlib.o gzlib.c
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/gzread.o gzread.c
gcc -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -DPIC -c -o objs/gzwrite.o gzwrite.c
gcc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map -O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -o libz.so.1.2.11 adler32.lo crc32.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo zutil.lo compress.lo uncompr.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo -lc
rm -f libz.so libz.so.1
ln -s libz.so.1.2.11 libz.so
ln -s libz.so.1.2.11 libz.so.1
rm -f /home/som/.local/lib/libz.a
cp libz.a /home/som/.local/lib
chmod 644 /home/som/.local/lib/libz.a
cp libz.so.1.2.11 /home/som/.local/lib
chmod 755 /home/som/.local/lib/libz.so.1.2.11
rm -f /home/som/.local/share/man/man3/zlib.3
cp zlib.3 /home/som/.local/share/man/man3
chmod 644 /home/som/.local/share/man/man3/zlib.3
rm -f /home/som/.local/lib/pkgconfig/zlib.pc
cp zlib.pc /home/som/.local/lib/pkgconfig
chmod 644 /home/som/.local/lib/pkgconfig/zlib.pc
rm -f /home/som/.local/include/zlib.h /home/som/.local/include/zconf.h
cp zlib.h zconf.h /home/som/.local/include
chmod 644 /home/som/.local/include/zlib.h /home/som/.local/include/zconf.h
[som#jsClone zlib-1.2.11]$
The $HOME/.local has the structure:
[som#jsClone ~]$ tree $HOME/.local
/home/som/.local
├── bin
├── include
│ ├── zconf.h
│ └── zlib.h
├── lib
│ ├── libz.a
│ ├── libz.so -> libz.so.1.2.11
│ ├── libz.so.1 -> libz.so.1.2.11
│ ├── libz.so.1.2.11
│ └── pkgconfig
│ └── zlib.pc
└── share
└── man
└── man3
└── zlib.3
7 directories, 8 files
So now that zlib is installed, I tried to build git again, specifying the location of the zlib.h file, but it doesn't work.
[som#jsClone git-1.8.3-rc1]$ make
CC credential-store.o
In file included from credential-store.c:1:0:
cache.h:19:18: fatal error: zlib.h: No such file or directory
#include <zlib.h>
^
compilation terminated.
make: *** [credential-store.o] Error 1
How can I fix this?
Related
We've decided to switch to using Node.js, and I'm trying to build out the GridDB Node.js client, but I'm getting a make error. I followed closely with the blog and the GitHub instructions. How can I fix this?
Here's the error code:
$ make
g++ -fPIC -std=c++0x -g -O2 -c -o src/TimeSeriesProperties.o -Iinclude -Isrc src/TimeSeriesProperties.cpp
g++ -fPIC -std=c++0x -g -O2 -c -o src/ContainerInfo.o -Iinclude -Isrc src/ContainerInfo.cpp
g++ -fPIC -std=c++0x -g -O2 -c -o src/AggregationResult.o -Iinclude -Isrc src/AggregationResult.cpp
g++ -fPIC -std=c++0x -g -O2 -c -o src/Container.o -Iinclude -Isrc src/Container.cpp
g++ -fPIC -std=c++0x -g -O2 -c -o src/Store.o -Iinclude -Isrc src/Store.cpp
g++ -fPIC -std=c++0x -g -O2 -c -o src/StoreFactory.o -Iinclude -Isrc src/StoreFactory.cpp
g++ -fPIC -std=c++0x -g -O2 -c -o src/PartitionController.o -Iinclude -Isrc src/PartitionController.cpp
g++ -fPIC -std=c++0x -g -O2 -c -o src/Query.o -Iinclude -Isrc src/Query.cpp
g++ -fPIC -std=c++0x -g -O2 -c -o src/QueryAnalysisEntry.o -Iinclude -Isrc src/QueryAnalysisEntry.cpp
g++ -fPIC -std=c++0x -g -O2 -c -o src/RowKeyPredicate.o -Iinclude -Isrc src/RowKeyPredicate.cpp
g++ -fPIC -std=c++0x -g -O2 -c -o src/RowSet.o -Iinclude -Isrc src/RowSet.cpp
swig -DSWIGWORDSIZE64 -Ilibs/js/v8 -outdir . -o src/griddb_js.cxx -c++ -javascript -node src/griddb.i
g++ -fPIC -std=c++0x -g -O2 -Iinclude -Isrc -I/usr/include/node -DNODE_GYP_MODULE_NAME=griddb -DV8_DEPRECATION_WARNINGS=1 -DBUILDING_NODE_EXTENSION -c -o src/griddb_js.o src/griddb_js.cxx
src/griddb_js.cxx:171:18: fatal error: node.h: No such file or directory
#include <node.h>
^
compilation terminated.
make: *** [src/griddb_js.o] Error 1
src/griddb_js.cxx:171:18: fatal error: node.h: No such file or directory
#include <node.h>
The compiler can't find the "node.h" header file in any of the include paths ("/usr/include/node").
You need to install a "nodejs-devel" package that includes this header then re-run make.
I came across a very strange issue of makefile, here it is:
System: Linux CentOS 6
In the beginning, the name of makefile is “makefile”, its sample contents:
OPTFLAGS = -Wall -g -O
CXX = g++
INC = -I/usr/local/include -I/usr/include
LIBS = -L/usr/local/lib -L/usr/lib64
CXXFLAGS = $(OPTFLAGS) $(INC)
SOURCES = file1.cpp file2.cpp file3.cpp
OBJECTS = $(SOURCES:.cpp=.o)
EXECUTABLE = mybin
$(EXECUTABLE): $(OBJECTS)
$(CXX) $(CXXFLAGS) $(INC) $(LIBS) $(OBJECTS) -o $#
file1.o : file1.cpp
file2.o : file2.cpp
file3.o : file3.cpp
.PHONY: clean
clean:
rm -f $(EXECUTABLE) *.o core*
I got following err after I ran “make”:
g++: file3.o: No such file or directory
I have a workaround to add a dummy file after file3:
dummy.o : dummy.cpp
This way I could build successfully.
And I know that I can delete all these lines:
file1.o : file1.cpp
file2.o : file2.cpp
file3.o : file3.cpp
let make to build using default settings, I could build successfully this way.
I also tried to just rename “makefile” to “Makefile”, and with following lines without dummy line:
file1.o : file1.cpp
file2.o : file2.cpp
file3.o : file3.cpp
To my surprise, I could build successfully this way.
Could anyone explain why I got error of “No such file or directory” for the last file3 in the beginning?
Following is the error output:
g++ -g -Wall -O -I/usr/local/include -I/usr/include -c -o file1.o file1.cpp
g++ -g -Wall -O -I/usr/local/include -I/usr/include -c -o file2.o file2.cpp
g++ -g -Wall -O -I/usr/local/include -I/usr/include -I/usr/local/include -I/usr/include -L/usr/local/lib -L/usr/lib64 -lsybdb file1.o file2.o file3.o -o mybin
g++: file3.o: No such file or directory
make: *** [mybin] Error 1
Following is the output after I added dummy line:
g++ -Wall -g -O -I/usr/local/include -I/usr/include -c -o file1.o file1.cpp
g++ -Wall -g -O -I/usr/local/include -I/usr/include -c -o file2.o file2.cpp
g++ -Wall -g -O -I/usr/local/include -I/usr/include -c -o file3.o file3.cpp
g++ -Wall -g -O -I/usr/local/include -I/usr/include -I/usr/local/include -I/usr/include -L/usr/local/lib -L/usr/lib64 -lsybdb file1.o file2.o file3.o -o mybin
I tried to rename "makefile" to "Makefile" again, and it doesn't work this time.
Ufffff!! Found your problem.
When you wrote
file1.o : file1.cpp
file2.o : file2.cpp
file3.o : file3.cpp
in your makefile a deamon came and introduced a TAB after the line file3.o : file3.cpp so make instead of taking implicit rule thought you are specifying explicit rule. For file1.o and file2.o it used implicit rule but for file3.o it assumed your are specifying explicit rule because of that TAB, but you had given it a blank TAB so file3.o was never built.
Now when you added dummy.o:dummy.cpp the TAB moved below that line so file3.o was compiled. When you were experimenting around you deleted that TAB that's why renaming makefile to Makefile seemed to work.
Just FYI: there is no difference between Makefile or makefile both are treated equally by make, except when both Makefile and makefile files are there in same folder and you give make then makefile is executed instead of Makefile
My application can be compiled & linked successfully via GCC/G++ 4.4.7, which is shipped with CentOS 6.5.
I wanna static link libstdc++.a via -static-libstdc++ , but it is not supported by 4.4.7.
Hence I installed redhat-devtools-1.1 via the following command, upgraded GCC/G++ to 4.7.2
cd /etc/yum.repos.d
wget http://people.centos.org/tru/devtools-1.1/devtools-1.1.repo
yum --enablerepo=testing-1.1-devtools-6 install devtoolset-1.1-gcc devtoolset-1.1-gcc-c++
Then compile my application with the new toolset, it fails
/opt/centos/devtoolset-1.1/root/usr/bin/c++ -m64 -c -O2 -Iinc -fPIC -MMD -MP -MF "AutoInit.o.d" -o AutoInit.o AutoInit.cpp
/opt/centos/devtoolset-1.1/root/usr/bin/gcc -m64 -c -O2 -D_LARGEFILE64_SOURCE=1 -Iinc -std=c99 -fPIC -MMD -MP -MF "common.o.d" -o common.o common.c
/opt/centos/devtoolset-1.1/root/usr/bin/gcc -m64 -c -O2 -D_LARGEFILE64_SOURCE=1 -Iinc -std=c99 -fPIC -MMD -MP -MF "rpc.o.d" -o rpc.o rpc.c
/opt/centos/devtoolset-1.1/root/usr/bin/gcc -m64 -c -O2 -D_LARGEFILE64_SOURCE=1 -Iinc -std=c99 -fPIC -MMD -MP -MF "transport_service.o.d" -o transport_service.o transport_service.c
/opt/centos/devtoolset-1.1/root/usr/bin/gcc -m64 -c -O2 -D_LARGEFILE64_SOURCE=1 -Iinc -std=c99 -fPIC -MMD -MP -MF "interop.o.d" -o interop.o interop.c
/opt/centos/devtoolset-1.1/root/usr/bin/gcc -m64 -c -O2 -D_LARGEFILE64_SOURCE=1 -Iinc -std=c99 -fPIC -MMD -MP -MF "utility.o.d" -o utility.o utility.c
/opt/centos/devtoolset-1.1/root/usr/bin/g++ -o libmq.so AutoInit.o common.o rpc.o transport_service.o interop.o utility.o -L./lib -l:libapr-1.a -l:libcurl.a -l:libjansson.a -static-libgcc -static-libstdc++ -Wl,--start-group -l:libzmq.a -l:libczmq.a -Wl,--end-group -shared -fPIC
/usr/bin/ld: /opt/centos/devtoolset-1.1/root/usr/lib/gcc/x86_64-redhat-linux/4.7.2/libstdc++.a(compatibility.o): relocation R_X86_64_32 against `_ZTIN10__cxxabiv115__forced_unwindE' can not be used when making a shared object; recompile with -fPIC
/opt/centos/devtoolset-1.1/root/usr/lib/gcc/x86_64-redhat-linux/4.7.2/libstdc++.a: could not read symbols: Bad value
collect2: error: ld returned 1 exit status
Please do you know how to resolve this problem?
Likely libstdc++.a is compiled without -fPIC so ld prohibites building a shared object with it. http://eli.thegreenplace.net/2011/11/03/position-independent-code-pic-in-shared-libraries/ . Probably you need to recompile libstdc++.a yourself.
Even though I have linked -lrt in my Makefile, as you can see below, I am still getting undefined reference to 'mq_open'. Please help!
all:get1 iserv1
get: get1.c
gcc -Wall -o get1 get1.c -lrt
iserv: iserv1.c
gcc -Wall -o iserv1 iserv1.c -lrt
clean:
rm -fr *~ get1 iserv1
Note -lrt should be at end not inbetween.
Your makefile is wrong
all:get1 iserv1
get: get1.c
gcc -Wall -o get1 get1.c -lrt
all has a prerequisite of get1 and iserv1. But you created a get target and an iserv target. So e.g. get1 will be compiled with the default make rules, which does not include -lrt (this should show if you look at the gcc commands that actually are executed.)
Your makefile should like like this:
all:get1 iserv1
get1: get1.c
gcc -Wall -o get1 get1.c -lrt
iserv1: iserv1.c
gcc -Wall -o iserv1 iserv1.c -lrt
clean:
rm -fr *~ get1 iserv1
I have used this command.
libtool --mode=compile gcc -g -o -c foo.c
Actual output should be like this after the command:
$libtool --mode=compile gcc -g -O -c foo.c
mkdir .libs
gcc -g -O -c foo.c -fPIC -DPIC -o .libs/foo.o
gcc -g -O -c foo.c -o foo.o >/dev/null 2>&1
but observed output is
$libtool --mode=compile gcc -g -O -c foo.c
gcc -g -O -c foo.c -fPIC -DPIC -o .libs/foo.o
gcc -g -O -c foo.c -o foo.o >/dev/null 2>&1.
.libs directory is not creating. It there any changes i have to make
http://www.gnu.org/software/libtool/manual/html_node/Creating-object-files.html
On shared library systems, libtool automatically generates an additional PIC object by inserting the appropriate PIC generation flags into the compilation command:
burger$ libtool --mode=compile gcc -g -O -c foo.c
mkdir .libs
gcc -g -O -c foo.c -fPIC -DPIC -o .libs/foo.o
gcc -g -O -c foo.c -o foo.o >/dev/null 2>&1
burger$
Note that Libtool automatically created .libs directory upon its first execution, where PIC library object files will be stored.
Since ‘burger’ supports shared libraries, and requires PIC objects to build them, Libtool has compiled a PIC object this time, and made a note of it in the libtool object:
# foo.lo - a libtool object file
# Generated by ltmain.sh (GNU libtool) 2.4.2
#
# Please DO NOT delete this file!
# It is necessary for linking the library.
# Name of the PIC object.
pic_object='.libs/foo.o'
# Name of the non-PIC object.
non_pic_object='foo.o'
Notice that the second run of GCC has its output discarded. This is done so that compiler warnings aren't annoyingly duplicated. If you need to see both sets of warnings (you might have conditional code inside ‘#ifdef PIC’ for example), you can turn off suppression with the -no-suppress option to libtool's compile mode:
burger$ libtool --mode=compile gcc -no-suppress -g -O -c hello.c
gcc -g -O -c hello.c -fPIC -DPIC -o .libs/hello.o
gcc -g -O -c hello.c -o hello.o
burger$
I hope this would be helpful.
Thanks & Regards,
Alok