Hi,
the appended patch fixes an issue I have with recent cmake (3.2.3) with
cross compiling an mingw32 application. The applications requires bzip2
library which is handled by cmake provided FindBZip2.cmake. The problem
is that BZIP2_NEED_PREFIX is not set where it should be and results
into linker failure not finding bzip2 related symbols.
Some details:
FindBZip2.cmake uses BZ2_bzCompressInit to detect if BZIP2_NEED_PREFIX
should be set.
CHECK_LIBRARY_EXISTS("${BZIP2_LIBRARIES}" BZ2_bzCompressInit ""
BZIP2_NEED_PREFIX)
The check is performed with CheckFunctionExists.c, which converts the
function name into a prototype of the form 'char BZ2_bzCompressInit()',
while in real it is
int BZ2_bzCompressInit ( bz_stream *strm,
int blockSize100k,
int verbosity,
int workFactor );
The compiler converts this function to the symbol '_BZ2_bzCompressInit',
which is not in the related import library.
Taking a look into the related import library shows that there is
objdump -x /usr/i686-w64-mingw32/sys-root/mingw/lib/libbz2.dll.a | grep
CompressInit
[ 6](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000
_BZ2_bzCompressInit@16
[ 7](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000
__imp__BZ2_bzCompressInit@16
The '@16' indicates the size of the parameter list
(https://msdn.microsoft.com/en-us/library/zxk0tw93.aspx) with does match
the used prototype 'char BZ2_bzCompressInit().'
The fix is to use a function which do not have parameters like
BZ2_decompress.
objdump -x /usr/i686-w64-mingw32/sys-root/mingw/lib/libbz2.dll.a | grep
decompress
[ 6](sec 1)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000 _BZ2_decompress
[ 7](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x00000000
__imp__BZ2_decompress
The appended patch fixes this issue.
Regards
Ralf
--- /usr/share/cmake/Modules/FindBZip2.cmake.orig 2015-07-19 20:22:50.312758104 +0200
+++ /usr/share/cmake/Modules/FindBZip2.cmake 2015-07-19 20:23:30.849124798 +0200
@@ -60,7 +60,7 @@
include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake)
cmake_push_check_state()
set(CMAKE_REQUIRED_QUIET ${BZip2_FIND_QUIETLY})
- CHECK_LIBRARY_EXISTS("${BZIP2_LIBRARIES}" BZ2_bzCompressInit "" BZIP2_NEED_PREFIX)
+ CHECK_LIBRARY_EXISTS("${BZIP2_LIBRARIES}" BZ2_decompress "" BZIP2_NEED_PREFIX)
cmake_pop_check_state()
endif ()
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers