Cannot build because of lstdc++ (no PETSc)

Bug #1147010 reported by Timothée Lecomte
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
libadjoint
New
Undecided
Unassigned

Bug Description

Hi,

Following previous reports, I am now trying to build libadjoint without its PETSc-related features, to workaround the fact that my PETSc built does not have C support. I realize that the cleaner way would be to build PETSc with C support, but I have already had so much of a hard time building it that I am afraid to start again, even changing the smallest option.

So now I am trying to build libadjoint (r418) with:

PETSC_ARCH="" PETSC_DIR="" SLEPC_ARCH="" SLEPC_DIR="" make install

(Note that PETSC_ARCH="" PETSC_DIR="" is not enough since SLEPC headers include PETSc ones)

Unfortunately, I am still getting an error (and a bunch of warnings), all related to the use of -lstdc++. Below is the full output. Thank you in advance for your help to fix my issues !

  CC src/adj_adjointer_routines.c
mpicc -g -O0 -fPIC -Iinclude/ -Wall -Wextra -Wunused-parameter -Wunsafe-loop-optimizations -Wpointer-arith -Wstrict-prototypes -ggdb3 -fstack-protector-all -lstdc++ -c -o obj/adj_adjointer_routines.o src/adj_adjointer_routines.c
i686-apple-darwin10-gcc-4.2.1: -lstdc++: linker input file unused because linking not done
  CC src/adj_adjointer_visualisation.c
mpicc -g -O0 -fPIC -Iinclude/ -Wall -Wextra -Wunused-parameter -Wunsafe-loop-optimizations -Wpointer-arith -Wstrict-prototypes -ggdb3 -fstack-protector-all -lstdc++ -c -o obj/adj_adjointer_visualisation.o src/adj_adjointer_visualisation.c
i686-apple-darwin10-gcc-4.2.1: -lstdc++: linker input file unused because linking not done
  CC src/adj_core.c
mpicc -g -O0 -fPIC -Iinclude/ -Wall -Wextra -Wunused-parameter -Wunsafe-loop-optimizations -Wpointer-arith -Wstrict-prototypes -ggdb3 -fstack-protector-all -lstdc++ -c -o obj/adj_core.o src/adj_core.c
i686-apple-darwin10-gcc-4.2.1: -lstdc++: linker input file unused because linking not done
  CC src/adj_data_structures.c
mpicc -g -O0 -fPIC -Iinclude/ -Wall -Wextra -Wunused-parameter -Wunsafe-loop-optimizations -Wpointer-arith -Wstrict-prototypes -ggdb3 -fstack-protector-all -lstdc++ -c -o obj/adj_data_structures.o src/adj_data_structures.c
i686-apple-darwin10-gcc-4.2.1: -lstdc++: linker input file unused because linking not done
  CC src/adj_debug.c
mpicc -g -O0 -fPIC -Iinclude/ -Wall -Wextra -Wunused-parameter -Wunsafe-loop-optimizations -Wpointer-arith -Wstrict-prototypes -ggdb3 -fstack-protector-all -lstdc++ -c -o obj/adj_debug.o src/adj_debug.c
i686-apple-darwin10-gcc-4.2.1: -lstdc++: linker input file unused because linking not done
  CC src/adj_dictionary.c
mpicc -g -O0 -fPIC -Iinclude/ -Wall -Wextra -Wunused-parameter -Wunsafe-loop-optimizations -Wpointer-arith -Wstrict-prototypes -ggdb3 -fstack-protector-all -lstdc++ -c -o obj/adj_dictionary.o src/adj_dictionary.c
i686-apple-darwin10-gcc-4.2.1: -lstdc++: linker input file unused because linking not done
  CC src/adj_error_handling.c
mpicc -g -O0 -fPIC -Iinclude/ -Wall -Wextra -Wunused-parameter -Wunsafe-loop-optimizations -Wpointer-arith -Wstrict-prototypes -ggdb3 -fstack-protector-all -lstdc++ -c -o obj/adj_error_handling.o src/adj_error_handling.c
i686-apple-darwin10-gcc-4.2.1: -lstdc++: linker input file unused because linking not done
  CC src/adj_evaluation.c
mpicc -g -O0 -fPIC -Iinclude/ -Wall -Wextra -Wunused-parameter -Wunsafe-loop-optimizations -Wpointer-arith -Wstrict-prototypes -ggdb3 -fstack-protector-all -lstdc++ -c -o obj/adj_evaluation.o src/adj_evaluation.c
i686-apple-darwin10-gcc-4.2.1: -lstdc++: linker input file unused because linking not done
  CC src/adj_petsc_data_structures.c
mpicc -g -O0 -fPIC -Iinclude/ -Wall -Wextra -Wunused-parameter -Wunsafe-loop-optimizations -Wpointer-arith -Wstrict-prototypes -ggdb3 -fstack-protector-all -lstdc++ -c -o obj/adj_petsc_data_structures.o src/adj_petsc_data_structures.c
i686-apple-darwin10-gcc-4.2.1: -lstdc++: linker input file unused because linking not done
  CC src/adj_predictability.c
mpicc -g -O0 -fPIC -Iinclude/ -Wall -Wextra -Wunused-parameter -Wunsafe-loop-optimizations -Wpointer-arith -Wstrict-prototypes -ggdb3 -fstack-protector-all -lstdc++ -c -o obj/adj_predictability.o src/adj_predictability.c
i686-apple-darwin10-gcc-4.2.1: -lstdc++: linker input file unused because linking not done
  CC src/adj_simplification.c
mpicc -g -O0 -fPIC -Iinclude/ -Wall -Wextra -Wunused-parameter -Wunsafe-loop-optimizations -Wpointer-arith -Wstrict-prototypes -ggdb3 -fstack-protector-all -lstdc++ -c -o obj/adj_simplification.o src/adj_simplification.c
i686-apple-darwin10-gcc-4.2.1: -lstdc++: linker input file unused because linking not done
  CC src/adj_test_tools.c
mpicc -g -O0 -fPIC -Iinclude/ -Wall -Wextra -Wunused-parameter -Wunsafe-loop-optimizations -Wpointer-arith -Wstrict-prototypes -ggdb3 -fstack-protector-all -lstdc++ -c -o obj/adj_test_tools.o src/adj_test_tools.c
i686-apple-darwin10-gcc-4.2.1: -lstdc++: linker input file unused because linking not done
  CC src/adj_variable_lookup.c
mpicc -g -O0 -fPIC -Iinclude/ -Wall -Wextra -Wunused-parameter -Wunsafe-loop-optimizations -Wpointer-arith -Wstrict-prototypes -ggdb3 -fstack-protector-all -lstdc++ -c -o obj/adj_variable_lookup.o src/adj_variable_lookup.c
i686-apple-darwin10-gcc-4.2.1: -lstdc++: linker input file unused because linking not done
  CC src/html_encode.c
mpicc -g -O0 -fPIC -Iinclude/ -Wall -Wextra -Wunused-parameter -Wunsafe-loop-optimizations -Wpointer-arith -Wstrict-prototypes -ggdb3 -fstack-protector-all -lstdc++ -c -o obj/html_encode.o src/html_encode.c
i686-apple-darwin10-gcc-4.2.1: -lstdc++: linker input file unused because linking not done
  SED include/libadjoint/adj_constants_f.h
  SED include/libadjoint/adj_error_handling_f.h
  FC src/adj_fortran.F90
  C++ src/revolve.cpp
  C++ src/revolve_c.cpp
  AR lib/libadjoint.a
  LD lib/libadjoint.dylib
ld: library not found for -lstdc++
collect2: error: ld returned 1 exit status
make: *** [lib/libadjoint.dylib] Error 1

Revision history for this message
Timothée Lecomte (timothee-lecomte-5) wrote :

And for reference:

minerve:dorsal tlecomte$ mpicc --version
i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
minerve:dorsal tlecomte$ uname -a
Darwin #### 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64

Revision history for this message
Patrick Farrell (pefarrell) wrote :

I don't blame you for not wanting to recompile PETSc! However, I *think* the only thing you have to do is to add

--with-c-support

to your configure line.

Anyway, on to your bug. Could you please paste the output of:

find /usr -name 'libstdc++*'

?

On my machine it gives:
/usr/lib/libstdc++.6.0.9.dylib
/usr/lib/libstdc++.6.dylib
/usr/lib/libstdc++.dylib

which is why -lstdc++ works for me (it automatically looks in /usr/lib).

Thanks!

Patrick

Revision history for this message
Timothée Lecomte (timothee-lecomte-5) wrote :

Thanks for looking into it ! Here is what I have on mine:

minerve:dorsal tlecomte$ find /usr -name 'libstdc++*'
/usr/lib/gcc/i686-apple-darwin10/4.0.1/libstdc++.dylib
/usr/lib/gcc/i686-apple-darwin10/4.2.1/libstdc++.dylib
/usr/lib/gcc/powerpc-apple-darwin10/4.0.1/libstdc++.dylib
/usr/lib/gcc/powerpc-apple-darwin10/4.2.1/libstdc++.dylib
/usr/lib/libstdc++-static.a
/usr/lib/libstdc++.6.0.9.dylib
/usr/lib/libstdc++.6.dylib
/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin10/4.2.1/libstdc++.dylib
/usr/llvm-gcc-4.2/lib/gcc/powerpc-apple-darwin10/4.2.1/libstdc++.dylib

So I have no /usr/lib/libstdc++.dylib

May I ask why you need the C++ standard library to build a C project ?

Revision history for this message
Timothée Lecomte (timothee-lecomte-5) wrote :

Hi Patrick,

For reference for future readers of this page, here is the solution that appeared on bug #1135519:

Thanks again for your help and your explanation. I am sorry that the compiler situation is so messy on OS X...

It looks like my stdc++ problem comes from the fact that I have gfortran is used for the linking, and I have gfortran 4.7.2 installed (from Homebrew):
minerve:dorsal tlecomte$ gfortran --version
GNU Fortran (GCC) 4.7.2

'gfortran -lstdc++' complains while 'gcc -lstdc++' and 'g++ -lstdc++' do not,

Well, as you suggested, I changed '-lstdc++' to '-lstdc++.6' in line 176 of the Makefile, and got rid of that error. Finally, I had to install greadlink (through Homebrew coreutils) to get the python bindings properly built, and now I have a fully working libadjoint where all tests pass ! Thanks !!

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.