[CMake] cmake can't find some crtbegin.so, libgcc, libgcc_s under certain conditions

Michael Hertling mhertling at online.de
Tue Jan 31 20:22:17 EST 2012


On 01/31/2012 09:14 PM, Jim Galarowicz wrote:
> 
> Hi all,
> 
> I'm running into issues with cmake or likely our set-up/usage of cmake, when trying to build the component based tool framework (CBTF) with cmake.
> The issue I'm seeing only occurs on machines where binutils-devel is not installed and I build my own version of binutils.
> It seems that something gets out of sync with ld and gcc.  I'm on laboratory machines where I don't control the software that is installed, so that
> is why I'm building my own version of binutils.
> 
> Has anyone seen something like this (output listed below) or has any suggestions on where to look and/or what to look for to solve this?
> 
> *********************************************************************************
> CMAKE OUTPUT:
> *********************************************************************************
> -- The C compiler identification is GNU
> -- The CXX compiler identification is GNU
> -- Check for working C compiler: /usr/bin/gcc
> -- Check for working C compiler: /usr/bin/gcc -- broken
> CMake Error at /global/common/hopper2/usg/cmake/2.8.2/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:52
> (MESSAGE):
>    The C compiler "/usr/bin/gcc" is not able to compile a simple test program.
>    It fails with the following output:
>     Change Dir: /global/homes/j/jgalaro/hopper/cbtf/framework/build/CMakeFiles/CMakeTmp
> 
>    Run Build Command:/usr/bin/gmake "cmTryCompileExec/fast"
> 
>    /usr/bin/gmake -f CMakeFiles/cmTryCompileExec.dir/build.make
>    CMakeFiles/cmTryCompileExec.dir/build
> 
>    gmake[1]: Entering directory
>    `/global/u2/j/jgalaro/hopper/cbtf/framework/build/CMakeFiles/CMakeTmp'
> 
>    /global/common/hopper2/usg/cmake/2.8.2/bin/cmake -E  cmake_progress_report
> 
> /global/homes/j/jgalaro/hopper/cbtf/framework/build/CMakeFiles/CMakeTmp/CMakeFiles
>    1
>    Building C object CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.o
>    /usr/bin/gcc -o CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.o -c /global/homes/j/jgalaro/hopper/cbtf/framework/build/CMakeFiles/CMakeTmp/testCCompiler.c
> 
>    Linking C executable cmTryCompileExec
> 
>    /global/common/hopper2/usg/cmake/2.8.2/bin/cmake -E cmake_link_script CMakeFiles/cmTryCompileExec.dir/link.txt --verbose=1
> 
>    /usr/bin/gcc CMakeFiles/cmTryCompileExec.dir/testCCompiler.c.o -o cmTryCompileExec -rdynamic
> 
>    /global/u2/j/jgalaro/hopper/cbtf_install/bin/ld: cannot find crtbegin.o: No such file or directory
> 
>    /global/u2/j/jgalaro/hopper/cbtf_install/bin/ld: cannot find -lgcc
> 
>    /global/u2/j/jgalaro/hopper/cbtf_install/bin/ld: cannot find -lgcc_s
> 
>    collect2: ld returned 1 exit status
> 
>    gmake[1]: *** [cmTryCompileExec] Error 1
> 
>    gmake[1]: Leaving directory
>    `/global/u2/j/jgalaro/hopper/cbtf/framework/build/CMakeFiles/CMakeTmp'
> 
>    gmake: *** [cmTryCompileExec/fast] Error 2
> 
> 
> In experimenting to get some clues about what is causing the cmake failures, I tried not setting PATH and LD_LIBRARY_PATH to point to my version of binutils.
> That didn't make a difference.  I don't think the fact that binutils-devel is not installed is what tweaking the cmake build,
> it seems more like the alternative bintuils install that does it.
> 
> I've tried setting LD_LIBRARY_PATH to point to the library location of crtbegin.so, libgcc, and libgcc_s that the cmake build complains that it can not find.
> But, this doesn't work either.   I then added a line to the CMakeLists.txt file we have for building CBTF, but that also did not make a difference.
> When I play with this on my laptop, I can reproduce what I see on the laboratory machines.
> 
> I've listed the build file (CMakeLists.txt) below.
> 
> This is the line that I added to see if I could help cmake file the crtbegin.so, libgcc and libgcc_s:
> 
> list( APPEND libSearchDirs /usr/lib64/gcc/x86_64-suse-linux/4.3)
> 
> 
> Any tips/help will be greatly appreciated.
> 
> Thanks,
> Jim G
> 
> 
> *********************************************************************************
> Shows where crtbegin.so, etc. are located.
> *********************************************************************************
> hopper08-796>lsr /usr/lib64/gcc/x86_64-suse-linux/4.3
> total 35824
>      4 drwxr-xr-x 3 root root     4096 2010-05-05 05:44 ../
>    756 -rw-r--r-- 1 root root   766626 2010-05-05 05:46 libsupc++.a
> 12148 -rw-r--r-- 1 root root 12420868 2010-05-05 05:46 libstdc++.a
>    252 -rw-r--r-- 1 root root   253440 2010-05-05 05:46 libgcc_eh.a
>   5824 -rw-r--r-- 1 root root  5951124 2010-05-05 05:46 libgcc.a
>    176 -rw-r--r-- 1 root root   174428 2010-05-05 05:46 libgcov.a
>      4 -rw-r--r-- 1 root root      170 2010-05-05 05:46 libgomp.spec
>    300 -rw-r--r-- 1 root root   299624 2010-05-05 05:46 libgomp.a
>      4 -rw-r--r-- 1 root root     3288 2010-05-05 05:46 crtprec80.o
>      4 -rw-r--r-- 1 root root     3480 2010-05-05 05:46 crtprec64.o
>      4 -rw-r--r-- 1 root root     3288 2010-05-05 05:46 crtprec32.o
>      4 -rw-r--r-- 1 root root     3320 2010-05-05 05:46 crtfastmath.o
>      4 -rw-r--r-- 1 root root     1928 2010-05-05 05:46 crtendS.o
>      4 -rw-r--r-- 1 root root     1928 2010-05-05 05:46 crtend.o
>      4 -rw-r--r-- 1 root root     3024 2010-05-05 05:46 crtbeginT.o
>      4 -rw-r--r-- 1 root root     2872 2010-05-05 05:46 crtbeginS.o
>      4 -rw-r--r-- 1 root root     2528 2010-05-05 05:46 crtbegin.o
>   7780 -rwxr-xr-x 1 root root  7951440 2010-05-05 05:46 cc1*
>    116 -rwxr-xr-x 1 root root   113656 2010-05-05 05:46 collect2*
>   8412 -rwxr-xr-x 1 root root  8594552 2010-05-05 05:47 cc1plus*
>      0 lrwxrwxrwx 1 root root       23 2012-01-12 22:05 libstdc++.so ->
> ../../../libstdc++.so.6*
>      0 lrwxrwxrwx 1 root root       21 2012-01-12 22:05 libgomp.so ->
> ../../../libgomp.so.1*
>      0 lrwxrwxrwx 1 root root       20 2012-01-12 22:05 libgcc_s.so ->
> /lib64/libgcc_s.so.1*
>      4 drwxr-xr-x 2 root root     4096 2012-01-12 22:05 include-fixed/
>      4 drwxr-xr-x 2 root root     4096 2012-01-12 22:05 include/
>      4 drwxr-xr-x 5 root root     4096 2012-01-12 22:06 ./
>      4 drwxr-xr-x 2 root root     4096 2012-01-12 22:06 32/
> hopper08-797>
> 
> 
> 
> 
> *********************************************************************************
> CMakeLists.txt SOURCE:
> *********************************************************************************
> cat -n CMakeLists.txt
> 
>     18
>      19    cmake_minimum_required(VERSION 2.8.0)
>      20
>      21    project(CBTF)
>      22
>      23
>      24    if(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc*")
>      25        set(CMAKE_LIBRARY_PATH ${CMAKE_INSTALL_PREFIX}/lib)
>      26    elseif(EXISTS /usr/lib64)
>      27        set(LIB_SUFFIX 64)
>      28        set(CMAKE_LIBRARY_PATH ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
>      29    endif()
>      30
>      31    list( APPEND libSearchDirs /usr/lib64/gcc/x86_64-suse-linux/4.3)
>      32
>      33    set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR})
>      34
>      35    find_package(Boost 1.35.0 REQUIRED
>      36        COMPONENTS date_time filesystem system thread unit_test_framework
>      37        )
>      38    find_package(MRNet 3.1)
>      39    find_package(Threads)
>      40    find_package(XercesC 3.0)
>      41
>      42    add_subdirectory(libcbtf)
>      43
>      44    if(XERCESC_FOUND)
>      45        add_subdirectory(libcbtf-xml)
>      46    endif()
>      47
>      48    if(XERCESC_FOUND AND MRNET_FOUND)
>      49        add_subdirectory(libcbtf-mrnet)
>      50        add_subdirectory(libcbtf-mrnet-backend)
>      51        add_subdirectory(libcbtf-mrnet-filter)
>      52        add_subdirectory(BasicMRNetLaunchers)
>      53    endif()
>      54
>      55    add_subdirectory(examples)
>      56    add_subdirectory(test)

The binutils and gcc are very closely related, so using the system's/
distribution's compilers in /usr along with your own installation of
binutils in /global/u2/j/jgalaro/hopper/cbtf_install is a recipe for
desaster. If you must use your own customized binutils, you should
definitely build your own customized gcc, too; you might even do
this in one go. Refer to [1] for more information.

Regards,

Michael

[1] http://gcc.gnu.org/install


More information about the CMake mailing list