Can't compile from command line in OSX

140 views
Skip to first unread message

Marcus P S

unread,
Jan 23, 2009, 3:41:56 PM1/23/09
to Google C++ Testing Framework
Hello all,

I am interested in using GTest for running some unit tests for a
library of optimized linear algebra functions we use in the lab I
work. We all use OSX, so I am trying to build GTest from the command
line, and I am running into some problems. In particular, after
running autoreconf and configure, and I try to "make", compilation
ends with the error

$ make
<bunch of stuff ...>
ranlib lib/.libs/libgtest_main.a
creating lib/libgtest_main.la
/opt/local/bin/gsed: can't read Test/gtest-1.2.1/lib/libgtest.la: No
such file or directory
libtool: link: `Test/gtest-1.2.1/lib/libgtest.la' is not a valid
libtool archive
make: *** [lib/libgtest_main.la] Error 1

I downloaded gtest-1.2.1.tar.bz2 from Google code, and I ran these
commands in the untar'ed directory.

I am assuming I should be able to run all this stuff from the
command line instead of learning how to use XCode and taking that
route. Are there any known problems with doing that in OSX? Does
anyone know of a work around?

For those interested in the details, here is the unabridged version
of the commands I run and the outputs:

$ autoreconf -fvi
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force
/opt/local/share/aclocal/smpeg.m4:13: warning: underquoted definition
of AM_PATH_SMPEG
/opt/local/share/aclocal/smpeg.m4:13: run info '(automake)Extending
aclocal'
/opt/local/share/aclocal/smpeg.m4:13: or see
http://sources.redhat.com/automake/automake.html#Extending-aclocal
autoreconf: configure.ac: tracing
autoreconf: running: glibtoolize --copy --force
Putting files in AC_CONFIG_AUX_DIR, `build-aux'.
/opt/local/share/aclocal/smpeg.m4:13: warning: underquoted definition
of AM_PATH_SMPEG
/opt/local/share/aclocal/smpeg.m4:13: run info '(automake)Extending
aclocal'
/opt/local/share/aclocal/smpeg.m4:13: or see
http://sources.redhat.com/automake/automake.html#Extending-aclocal
autoreconf: running: /opt/local/bin/autoconf --force
autoreconf: running: /opt/local/bin/autoheader --force
autoreconf: running: automake --add-missing --copy --force-missing
autoreconf: Leaving directory `.'
$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
/bin/sh: /Users/msilva/Documents/Projects/Software/Google: No such
file or directory
configure: WARNING: `missing' script is too old or missing
checking for a thread-safe mkdir -p... build-aux/install-sh -c -d
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... gcc3
checking build system type... i386-apple-darwin9.6.0
checking host system type... i386-apple-darwin9.6.0
checking for a sed that does not truncate output... /opt/local/bin/
gsed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ld used by gcc... /usr/libexec/gcc/i686-apple-
darwin9/4.0.1/ld
checking if the linker (/usr/libexec/gcc/i686-apple-darwin9/4.0.1/ld)
is GNU ld... no
checking for /usr/libexec/gcc/i686-apple-darwin9/4.0.1/ld option to
reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -p
checking whether ln -s works... yes
checking how to recognize dependent libraries... pass_all
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking how to run the C++ preprocessor... g++ -E
checking for g77... no
checking for xlf... no
checking for f77... no
checking for frt... no
checking for pgf77... no
checking for cf77... no
checking for fort77... no
checking for fl32... no
checking for af77... no
checking for xlf90... no
checking for f90... no
checking for pgf90... no
checking for pghpf... no
checking for epcf90... no
checking for gfortran... no
checking for g95... g95
checking whether we are using the GNU Fortran 77 compiler... yes
checking whether g95 accepts -g... yes
checking the maximum length of command line arguments... 196608
checking command to parse /usr/bin/nm -p output from gcc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking for dsymutil... dsymutil
checking for nmedit... nmedit
checking for -single_module linker flag... yes
checking for -exported_symbols_list linker flag... yes
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fno-common
checking if gcc PIC flag -fno-common works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking whether the gcc linker (/usr/libexec/gcc/i686-apple-
darwin9/4.0.1/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin9.6.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
configure: creating libtool
appending configuration tag "CXX" to libtool
checking for ld used by g++... /usr/libexec/gcc/i686-apple-
darwin9/4.0.1/ld
checking if the linker (/usr/libexec/gcc/i686-apple-darwin9/4.0.1/ld)
is GNU ld... no
checking whether the g++ linker (/usr/libexec/gcc/i686-apple-
darwin9/4.0.1/ld) supports shared libraries... yes
checking for g++ option to produce PIC... -fno-common
checking if g++ PIC flag -fno-common works... yes
checking if g++ static flag -static works... no
checking if g++ supports -c -o file.o... yes
checking whether the g++ linker (/usr/libexec/gcc/i686-apple-
darwin9/4.0.1/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin9.6.0 dyld
(cached) (cached) checking how to hardcode library paths into
programs... immediate
appending configuration tag "F77" to libtool
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for g95 option to produce PIC... -fno-common
checking if g95 PIC flag -fno-common works... yes
checking if g95 static flag -static works... no
checking if g95 supports -c -o file.o... yes
checking whether the g95 linker (/usr/libexec/gcc/i686-apple-
darwin9/4.0.1/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin9.6.0 dyld
(cached) (cached) checking how to hardcode library paths into
programs... immediate
checking for python... /opt/local/bin/python
configure: creating ./config.status
config.status: creating Makefile
config.status: creating scripts/gtest-config
config.status: creating build-aux/config.h
config.status: executing depfiles commands
$ make
depbase=`echo src/gtest.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\
/bin/sh ./libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -
I./build-aux -I. -I./include -g -O2 -MT src/gtest.lo -MD -MP -MF
$depbase.Tpo -c -o src/gtest.lo src/gtest.cc &&\
mv -f $depbase.Tpo $depbase.Plo
mkdir src/.libs
g++ -DHAVE_CONFIG_H -I. -I./build-aux -I. -I./include -g -O2 -MT src/
gtest.lo -MD -MP -MF src/.deps/gtest.Tpo -c src/gtest.cc -fno-common -
DPIC -o src/.libs/gtest.o
g++ -DHAVE_CONFIG_H -I. -I./build-aux -I. -I./include -g -O2 -MT src/
gtest.lo -MD -MP -MF src/.deps/gtest.Tpo -c src/gtest.cc -o src/
gtest.o >/dev/null 2>&1
depbase=`echo src/gtest-death-test.lo | sed 's|[^/]*$|.deps/&|;s|\.lo
$||'`;\
/bin/sh ./libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -
I./build-aux -I. -I./include -g -O2 -MT src/gtest-death-test.lo -MD
-MP -MF $depbase.Tpo -c -o src/gtest-death-test.lo src/gtest-death-
test.cc &&\
mv -f $depbase.Tpo $depbase.Plo
g++ -DHAVE_CONFIG_H -I. -I./build-aux -I. -I./include -g -O2 -MT src/
gtest-death-test.lo -MD -MP -MF src/.deps/gtest-death-test.Tpo -c src/
gtest-death-test.cc -fno-common -DPIC -o src/.libs/gtest-death-test.o
g++ -DHAVE_CONFIG_H -I. -I./build-aux -I. -I./include -g -O2 -MT src/
gtest-death-test.lo -MD -MP -MF src/.deps/gtest-death-test.Tpo -c src/
gtest-death-test.cc -o src/gtest-death-test.o >/dev/null 2>&1
depbase=`echo src/gtest-filepath.lo | sed 's|[^/]*$|.deps/&|;s|\.lo
$||'`;\
/bin/sh ./libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -
I./build-aux -I. -I./include -g -O2 -MT src/gtest-filepath.lo -MD -
MP -MF $depbase.Tpo -c -o src/gtest-filepath.lo src/gtest-filepath.cc
&&\
mv -f $depbase.Tpo $depbase.Plo
g++ -DHAVE_CONFIG_H -I. -I./build-aux -I. -I./include -g -O2 -MT src/
gtest-filepath.lo -MD -MP -MF src/.deps/gtest-filepath.Tpo -c src/
gtest-filepath.cc -fno-common -DPIC -o src/.libs/gtest-filepath.o
g++ -DHAVE_CONFIG_H -I. -I./build-aux -I. -I./include -g -O2 -MT src/
gtest-filepath.lo -MD -MP -MF src/.deps/gtest-filepath.Tpo -c src/
gtest-filepath.cc -o src/gtest-filepath.o >/dev/null 2>&1
depbase=`echo src/gtest-port.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\
/bin/sh ./libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -
I./build-aux -I. -I./include -g -O2 -MT src/gtest-port.lo -MD -MP -
MF $depbase.Tpo -c -o src/gtest-port.lo src/gtest-port.cc &&\
mv -f $depbase.Tpo $depbase.Plo
g++ -DHAVE_CONFIG_H -I. -I./build-aux -I. -I./include -g -O2 -MT src/
gtest-port.lo -MD -MP -MF src/.deps/gtest-port.Tpo -c src/gtest-
port.cc -fno-common -DPIC -o src/.libs/gtest-port.o
g++ -DHAVE_CONFIG_H -I. -I./build-aux -I. -I./include -g -O2 -MT src/
gtest-port.lo -MD -MP -MF src/.deps/gtest-port.Tpo -c src/gtest-
port.cc -o src/gtest-port.o >/dev/null 2>&1
depbase=`echo src/gtest-test-part.lo | sed 's|[^/]*$|.deps/&|;s|\.lo
$||'`;\
/bin/sh ./libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -
I./build-aux -I. -I./include -g -O2 -MT src/gtest-test-part.lo -MD -
MP -MF $depbase.Tpo -c -o src/gtest-test-part.lo src/gtest-test-
part.cc &&\
mv -f $depbase.Tpo $depbase.Plo
g++ -DHAVE_CONFIG_H -I. -I./build-aux -I. -I./include -g -O2 -MT src/
gtest-test-part.lo -MD -MP -MF src/.deps/gtest-test-part.Tpo -c src/
gtest-test-part.cc -fno-common -DPIC -o src/.libs/gtest-test-part.o
g++ -DHAVE_CONFIG_H -I. -I./build-aux -I. -I./include -g -O2 -MT src/
gtest-test-part.lo -MD -MP -MF src/.deps/gtest-test-part.Tpo -c src/
gtest-test-part.cc -o src/gtest-test-part.o >/dev/null 2>&1
depbase=`echo src/gtest-typed-test.lo | sed 's|[^/]*$|.deps/&|;s|\.lo
$||'`;\
/bin/sh ./libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -
I./build-aux -I. -I./include -g -O2 -MT src/gtest-typed-test.lo -MD
-MP -MF $depbase.Tpo -c -o src/gtest-typed-test.lo src/gtest-typed-
test.cc &&\
mv -f $depbase.Tpo $depbase.Plo
g++ -DHAVE_CONFIG_H -I. -I./build-aux -I. -I./include -g -O2 -MT src/
gtest-typed-test.lo -MD -MP -MF src/.deps/gtest-typed-test.Tpo -c src/
gtest-typed-test.cc -fno-common -DPIC -o src/.libs/gtest-typed-test.o
g++ -DHAVE_CONFIG_H -I. -I./build-aux -I. -I./include -g -O2 -MT src/
gtest-typed-test.lo -MD -MP -MF src/.deps/gtest-typed-test.Tpo -c src/
gtest-typed-test.cc -o src/gtest-typed-test.o >/dev/null 2>&1
/bin/sh ./libtool --tag=CXX --mode=link g++ -g -O2 -o lib/
libgtest.la -rpath /usr/local/lib src/gtest.lo src/gtest-death-test.lo
src/gtest-filepath.lo src/gtest-port.lo src/gtest-test-part.lo src/
gtest-typed-test.lo
mkdir lib/.libs
g++ -dynamiclib ${wl}-undefined ${wl}dynamic_lookup -o lib/.libs/
libgtest.0.0.0.dylib src/.libs/gtest.o src/.libs/gtest-death-test.o
src/.libs/gtest-filepath.o src/.libs/gtest-port.o src/.libs/gtest-test-
part.o src/.libs/gtest-typed-test.o -install_name /usr/local/lib/
libgtest.0.dylib -compatibility_version 1 -current_version 1.0 -Wl,-
single_module
dsymutil lib/.libs/libgtest.0.0.0.dylib || :
(cd lib/.libs && rm -f libgtest.0.dylib && ln -s libgtest.0.0.0.dylib
libgtest.0.dylib)
(cd lib/.libs && rm -f libgtest.dylib && ln -s libgtest.0.0.0.dylib
libgtest.dylib)
ar cru lib/.libs/libgtest.a src/gtest.o src/gtest-death-test.o src/
gtest-filepath.o src/gtest-port.o src/gtest-test-part.o src/gtest-
typed-test.o
ranlib lib/.libs/libgtest.a
creating lib/libgtest.la
(cd lib/.libs && rm -f libgtest.la && ln -s ../libgtest.la
libgtest.la)
depbase=`echo src/gtest_main.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\
/bin/sh ./libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -
I./build-aux -I. -I./include -g -O2 -MT src/gtest_main.lo -MD -MP -
MF $depbase.Tpo -c -o src/gtest_main.lo src/gtest_main.cc &&\
mv -f $depbase.Tpo $depbase.Plo
g++ -DHAVE_CONFIG_H -I. -I./build-aux -I. -I./include -g -O2 -MT src/
gtest_main.lo -MD -MP -MF src/.deps/gtest_main.Tpo -c src/
gtest_main.cc -fno-common -DPIC -o src/.libs/gtest_main.o
g++ -DHAVE_CONFIG_H -I. -I./build-aux -I. -I./include -g -O2 -MT src/
gtest_main.lo -MD -MP -MF src/.deps/gtest_main.Tpo -c src/
gtest_main.cc -o src/gtest_main.o >/dev/null 2>&1
/bin/sh ./libtool --tag=CXX --mode=link g++ -g -O2 -o lib/
libgtest_main.la -rpath /usr/local/lib src/gtest_main.lo lib/
libgtest.la
g++ -dynamiclib ${wl}-undefined ${wl}dynamic_lookup -o lib/.libs/
libgtest_main.0.0.0.dylib src/.libs/gtest_main.o lib/.libs/
libgtest.dylib -install_name /usr/local/lib/libgtest_main.0.dylib -
compatibility_version 1 -current_version 1.0 -Wl,-single_module
dsymutil lib/.libs/libgtest_main.0.0.0.dylib || :
(cd lib/.libs && rm -f libgtest_main.0.dylib && ln -s libgtest_main.
0.0.0.dylib libgtest_main.0.dylib)
(cd lib/.libs && rm -f libgtest_main.dylib && ln -s libgtest_main.
0.0.0.dylib libgtest_main.dylib)
ar cru lib/.libs/libgtest_main.a src/gtest_main.o
ranlib lib/.libs/libgtest_main.a
creating lib/libgtest_main.la
/opt/local/bin/gsed: can't read Test/gtest-1.2.1/lib/libgtest.la: No
such file or directory
libtool: link: `Test/gtest-1.2.1/lib/libgtest.la' is not a valid
libtool archive
make: *** [lib/libgtest_main.la] Error 1

Josh Kelley

unread,
Jan 23, 2009, 3:50:45 PM1/23/09
to Marcus P S, Google C++ Testing Framework
On Fri, Jan 23, 2009 at 3:41 PM, Marcus P S <marcus.ps@gmail.com> wrote:

 I am interested in using GTest for running some unit tests for a
library of optimized linear algebra functions we use in the lab I
work.  We all use OSX, so I am trying to build GTest from the command
line, and I am running into some problems. In particular, after
running autoreconf and configure, and I try to "make", compilation
ends with the error

 For those interested in the details, here is the unabridged version
of the commands I run and the outputs:

/bin/sh: /Users/msilva/Documents/Projects/Software/Google: No such
file or directory
/opt/local/bin/gsed: can't read Test/gtest-1.2.1/lib/libgtest.la: No
such file or directory
libtool: link: `Test/gtest-1.2.1/lib/libgtest.la' is not a valid
libtool archive
make: *** [lib/libgtest_main.la] Error 1
It looks like you put the source in /Users/msilva/Documents/Projects/Software/Google Test/gtest-1.2.1 and autotools doesn't like the space in the filename.
Josh Kelley 

Marcus P S

unread,
Jan 23, 2009, 3:53:07 PM1/23/09
to Google C++ Testing Framework
Hm. Interesting ... I removed my macports directory from my $PATH, re-
ran everything (autoreconf, configure, make) and everything worked.

Could it be that gtest is incompatible with MacPorts?
> /opt/local/share/aclocal/smpeg.m4:13:   or seehttp://sources.redhat.com/automake/automake.html#Extending-aclocal
> autoreconf: configure.ac: tracing
> autoreconf: running: glibtoolize --copy --force
> Putting files in AC_CONFIG_AUX_DIR, `build-aux'.
> /opt/local/share/aclocal/smpeg.m4:13: warning: underquoted definition
> of AM_PATH_SMPEG
> /opt/local/share/aclocal/smpeg.m4:13:   run info '(automake)Extending
> aclocal'
> /opt/local/share/aclocal/smpeg.m4:13:   or seehttp://sources.redhat.com/automake/automake.html#Extending-aclocal

Marcus P S

unread,
Jan 23, 2009, 3:57:51 PM1/23/09
to Google C++ Testing Framework
Good call. I renamed the directory and ran it with MacPorts in the
path, and that works too.

I suppose Apple's autotools does not mind spaces in the path, but
MacPorts' version is not so clever.

Thanks for the help!

Marcus

On Jan 23, 3:50 pm, Josh Kelley <josh...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages