Discussion:
[CMake] cmake 3.12 - python libs / 32 / 64 bits
Stéphane Ancelot
2018-11-14 13:06:32 UTC
Permalink
Hi,

My system is 64 bits but I can cross compile python c modules for 32 bits .

Unfortunately I don't manage to retrieve python 32 libs , always the 64
bits version is found.


here is what I tried :

cmake_minimum_required(VERSION 3.10)
project(py_autom)


set(CMAKE_SYSTEM_PROCESSOR "i686")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" CACHE STRING "c++ flags")
set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -m32" CACHE STRING "c flags")

set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS TRUE)
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE)

include_directories(python2.6)
find_package(Python2 COMPONENTS Development)



message(STATUS "python ${PYTHON_INCLUDE_DIRS} ${Python2_LIBRARIES_DIR}
${Python2_FOUND}")

Regards

Steph
--
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
Marc CHEVRIER
2018-11-14 16:53:18 UTC
Permalink
The way you proceed is wrong.
The system configuration is determined during the 'project' function call.
Setting information after this call is useless. So, in your example, on a
64bit system, the compilation configuration will be 64bit (variable
CMAKE_SIZEOF_VOID_P has value 8).
This explain why 'FIND_LIBRARY_USE_LIB32_PATHS' has no effect. This
property is taken in consideration only on 32bit systems.

Moreover, I am not sure that modifying variable 'CMAKE_SYSTEM_PROCESSOR' is
a valid action.

To configure a 32bit compilation environment, two possibilities:
* using environment variables: env CFLAGS=-m32 CXXFLAGS=-m32 cmake ...
* using a toolchain file: see
https://cmake.org/cmake/help/v3.13/manual/cmake-toolchains.7.html
Post by Stéphane Ancelot
Hi,
My system is 64 bits but I can cross compile python c modules for 32 bits .
Unfortunately I don't manage to retrieve python 32 libs , always the 64
bits version is found.
cmake_minimum_required(VERSION 3.10)
project(py_autom)
set(CMAKE_SYSTEM_PROCESSOR "i686")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" CACHE STRING "c++ flags")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32" CACHE STRING "c flags")
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS TRUE)
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE)
include_directories(python2.6)
find_package(Python2 COMPONENTS Development)
message(STATUS "python ${PYTHON_INCLUDE_DIRS} ${Python2_LIBRARIES_DIR}
${Python2_FOUND}")
Regards
Steph
--
Powered by www.kitware.com
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
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
https://cmake.org/mailman/listinfo/cmake
Stéphane Ancelot
2018-11-15 08:47:11 UTC
Permalink
I agree. That was a debug snippet...but is wrong ... I setted up again
the toolchain, but does not help.

 So, I know where are include_dirs and libs  for 32 bits cross
compiling, I have to hardcode it like this ?

 add_library(python SHARED IMPORTED)
 set_target_properties( python PROPERTIES IMPORTED_LOCATION
/usr/lib32/libpython2.6.so )
 target_include_directories(python SYSTEM ...
Post by Marc CHEVRIER
The way you proceed is wrong.
The system configuration is determined during the 'project' function
call. Setting information after this call is useless. So, in your
example, on a 64bit system, the compilation configuration will be
64bit (variable CMAKE_SIZEOF_VOID_P has value 8).
This explain why 'FIND_LIBRARY_USE_LIB32_PATHS' has no effect. This
property is taken in consideration only on 32bit systems.
Moreover, I am not sure that modifying variable
'CMAKE_SYSTEM_PROCESSOR' is a valid action.
* using environment variables: env CFLAGS=-m32 CXXFLAGS=-m32 cmake ...
* using a toolchain file: see
https://cmake.org/cmake/help/v3.13/manual/cmake-toolchains.7.html
Le mer. 14 nov. 2018 à 14:06, Stéphane Ancelot
Hi,
My system is 64 bits but I can cross compile python c modules for 32 bits .
Unfortunately I don't manage to retrieve python 32 libs , always the 64
bits version is found.
cmake_minimum_required(VERSION 3.10)
project(py_autom)
set(CMAKE_SYSTEM_PROCESSOR "i686")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" CACHE STRING "c++ flags")
set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -m32" CACHE STRING "c flags")
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS TRUE)
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE)
include_directories(python2.6)
find_package(Python2 COMPONENTS Development)
message(STATUS "python ${PYTHON_INCLUDE_DIRS}
${Python2_LIBRARIES_DIR}
${Python2_FOUND}")
Regards
Steph
--
Powered by www.kitware.com <http://www.kitware.com>
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community.
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
https://cmake.org/mailman/listinfo/cmake
Eric Noulard
2018-11-15 09:00:19 UTC
Permalink
I agree. That was a debug snippet...but is wrong ... I setted up again the
toolchain, but does not help.
If you are using a proper toolchain for 32bit compilation.
It looks like a bug in the find_package for Python in the cross-compiling
case.
Do you have a stripped down example which exhibit the issue?
Which version of CMake are you using?
So, I know where are include_dirs and libs for 32 bits cross compiling,
I have to hardcode it like this ?
add_library(python SHARED IMPORTED)
set_target_properties( python PROPERTIES IMPORTED_LOCATION /usr/lib32/
libpython2.6.so )
target_include_directories(python SYSTEM ...
I think you can do that but it replaces the use of find_package(Python2
COMPONENTS Development)
may be fixing this would be a better long-term solution ?
The way you proceed is wrong.
The system configuration is determined during the 'project' function call.
Setting information after this call is useless. So, in your example, on a
64bit system, the compilation configuration will be 64bit (variable
CMAKE_SIZEOF_VOID_P has value 8).
This explain why 'FIND_LIBRARY_USE_LIB32_PATHS' has no effect. This
property is taken in consideration only on 32bit systems.
Moreover, I am not sure that modifying variable 'CMAKE_SYSTEM_PROCESSOR'
is a valid action.
* using environment variables: env CFLAGS=-m32 CXXFLAGS=-m32 cmake ...
* using a toolchain file: see
https://cmake.org/cmake/help/v3.13/manual/cmake-toolchains.7.html
Post by Stéphane Ancelot
Hi,
My system is 64 bits but I can cross compile python c modules for 32 bits .
Unfortunately I don't manage to retrieve python 32 libs , always the 64
bits version is found.
cmake_minimum_required(VERSION 3.10)
project(py_autom)
set(CMAKE_SYSTEM_PROCESSOR "i686")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" CACHE STRING "c++ flags")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32" CACHE STRING "c flags")
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS TRUE)
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE)
include_directories(python2.6)
find_package(Python2 COMPONENTS Development)
message(STATUS "python ${PYTHON_INCLUDE_DIRS} ${Python2_LIBRARIES_DIR}
${Python2_FOUND}")
Regards
Steph
--
Powered by www.kitware.com
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
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
https://cmake.org/mailman/listinfo/cmake
--
Powered by www.kitware.com
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
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
https://cmake.org/mailman/listinfo/cmake
--
Eric
Marc CHEVRIER
2018-11-16 17:09:01 UTC
Permalink
FYI, I just deliver a MR (
https://gitlab.kitware.com/cmake/cmake/merge_requests/2624) which fix the
problem of the selection of the library with the wrong architecture.
Post by Eric Noulard
Post by Stéphane Ancelot
I agree. That was a debug snippet...but is wrong ... I setted up again
the toolchain, but does not help.
If you are using a proper toolchain for 32bit compilation.
It looks like a bug in the find_package for Python in the cross-compiling
case.
Do you have a stripped down example which exhibit the issue?
Which version of CMake are you using?
Post by Stéphane Ancelot
So, I know where are include_dirs and libs for 32 bits cross compiling,
I have to hardcode it like this ?
add_library(python SHARED IMPORTED)
set_target_properties( python PROPERTIES IMPORTED_LOCATION /usr/lib32/
libpython2.6.so )
target_include_directories(python SYSTEM ...
I think you can do that but it replaces the use of find_package(Python2
COMPONENTS Development)
may be fixing this would be a better long-term solution ?
Post by Stéphane Ancelot
The way you proceed is wrong.
The system configuration is determined during the 'project' function
call. Setting information after this call is useless. So, in your example,
on a 64bit system, the compilation configuration will be 64bit (variable
CMAKE_SIZEOF_VOID_P has value 8).
This explain why 'FIND_LIBRARY_USE_LIB32_PATHS' has no effect. This
property is taken in consideration only on 32bit systems.
Moreover, I am not sure that modifying variable 'CMAKE_SYSTEM_PROCESSOR'
is a valid action.
* using environment variables: env CFLAGS=-m32 CXXFLAGS=-m32 cmake ...
* using a toolchain file: see
https://cmake.org/cmake/help/v3.13/manual/cmake-toolchains.7.html
Post by Stéphane Ancelot
Hi,
My system is 64 bits but I can cross compile python c modules for 32 bits .
Unfortunately I don't manage to retrieve python 32 libs , always the 64
bits version is found.
cmake_minimum_required(VERSION 3.10)
project(py_autom)
set(CMAKE_SYSTEM_PROCESSOR "i686")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" CACHE STRING "c++ flags")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32" CACHE STRING "c flags")
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS TRUE)
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE)
include_directories(python2.6)
find_package(Python2 COMPONENTS Development)
message(STATUS "python ${PYTHON_INCLUDE_DIRS} ${Python2_LIBRARIES_DIR}
${Python2_FOUND}")
Regards
Steph
--
Powered by www.kitware.com
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
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
https://cmake.org/mailman/listinfo/cmake
--
Powered by www.kitware.com
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
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
https://cmake.org/mailman/listinfo/cmake
--
Eric
Loading...