[CMake] Cannot find the libstdc++ library on MinGW/MSYS when C++ is not enabled

Alan W. Irwin irwin at beluga.phys.uvic.ca
Mon Feb 3 01:36:37 EST 2014


I have had years of CMake experience on Linux, but my corresponding
CMake experience on MinGW/MSYS/Wine (1.6.1) is not as extensive.
Anyhow, I cannot figure out for the MinGW/MSYS case how to get
find_library to find the stdc++ library _without_ using system
locations that are defined when C++ is enabled.

Here is the simple test code I have been trying for the case when C++
is enabled:

project(test CXX)

message(STATUS "CMake version = ${CMAKE_VERSION}")
message(STATUS "CMAKE_SYSTEM = ${CMAKE_SYSTEM}")
message(STATUS "CMAKE_GENERATOR = ${CMAKE_GENERATOR}")
message(STATUS "CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}")
message(STATUS "CMAKE_LIBRARY_PATH environment variable =
$ENV{CMAKE_LIBRARY_PATH}")

cmake_minimum_required(VERSION 2.8.12.1 FATAL_ERROR)

find_library(libstdcxx_full_path stdc++)
message(STATUS "libstdcxx_full_path = ${libstdcxx_full_path}")

bash.exe-3.1$ env CMAKE_LIBRARY_PATH= cmake -G"MSYS Makefiles" ..
-- The CXX compiler identification is GNU 4.7.2
-- Check for working CXX compiler: z:/home/wine/newstart/MinGW-4.7.2/bin/g++.exe
-- Check for working CXX compiler: z:/home/wine/newstart/MinGW-4.7.2/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- CMake version = 2.8.12.1
-- CMAKE_SYSTEM = Windows-5.1
-- CMAKE_GENERATOR = MSYS Makefiles
-- CMAKE_INSTALL_PREFIX = C:/Program Files/test
-- CMAKE_LIBRARY_PATH environment variable =
-- libstdcxx_full_path = z:/home/wine/newstart/MinGW-4.7.2/lib/gcc/mingw32/4.7.2/libstdc++.dll.a
-- Configuring done
-- Generating done
-- Build files have been written to: Z:/home/wine/newstart/build_script/build_dir-1.6.1/test_build_dir/test_build_dir

So in this case the library is found, but if I change the above "C++" to NONE so that C++ is
not enabled, and if I specify the exact directory where to look via
the CMAKE_LIBRARY_PATH environment variable, the find_library command
fails to find anything (for the usual initially empty build tree):

bash.exe-3.1$ env CMAKE_LIBRARY_PATH=z:/home/wine/newstart/MinGW-4.7.2/lib/gcc/mingw32/4.7.2 cmake -G"MSYS Makefiles" ..
-- CMake version = 2.8.12.1
-- CMAKE_SYSTEM = Windows-5.1
-- CMAKE_GENERATOR = MSYS Makefiles
-- CMAKE_INSTALL_PREFIX = C:/Program Files/test
-- CMAKE_LIBRARY_PATH environment variable = z:/home/wine/newstart/MinGW-4.7.2/lib/gcc/mingw32/4.7.2
-- libstdcxx_full_path = libstdcxx_full_path-NOTFOUND
-- Configuring done
-- Generating done
-- Build files have been written to: Z:/home/wine/newstart/build_script/build_dir-1.6.1/test_build_dir/test_build_dir

I don't understand this result at all since with CMAKE_LIBRARY_PATH
defined to the exact PATH where libstdc++.dll.a exists, I would think
find_library would give identical results to the case when C++ is
enabled (where presumably CMake is using a system location to find
libstdc++.dll.a).  I have also tried the case of an empty CMAKE_LIBRARY_PATH
where I specified PATHS directly (both in z:/... form and /z/...
form) in the find_library command, but I always got the NOTFOUND result.

I don't have such trouble finding other libraries on this MinGW/MSYS
platform (e.g., the python library) using either the
CMAKE_LIBRARY_PATH approach or using an explicit PATHS setting in the
find_library command so I don't understand what is so special about
finding libstdc++.dll.a for this platform

Anyone have a clue about what is going on?

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list