Intel® oneAPI DPC++/C++ Compiler
Talk to fellow users of Intel® oneAPI DPC++/C++ Compiler and companion tools like Intel® oneAPI DPC++ Library, Intel® DPC++ Compatibility Tool, and Intel® Distribution for GDB*
768 Discussions

Unable to build C Python 3.12.3 application on Windows with Intel Compiler Classic 2021.7

gsamo
Beginner
600 Views

Attempting to build the following Python 3.12.3 hello world program fails with icl on Windows, but builds as expected with cl:

Source:

#include <Python.h>
#include <stdio.h>

int main() {
Py_Initialize();
if (Py_IsInitialized()) {
printf("Python is initialized!\n");
Py_Finalize();
} else {
printf("Failed to initialize Python.\n");
}
return 0;
}

Build script:

@echo off

REM Set the paths for Intel Compiler and Python (adjust these paths accordingly)
set PYTHON_INCLUDE=C:\.conan\d1de9a\1\bin\include
set PYTHON_LIB=C:\.conan\d1de9a\1\bin\libs
set "ICX_PATH=C:\Program Files (x86)\Intel\oneAPI"

REM Set up the Intel Compiler environment
call "%ICX_PATH%\setvars.bat"

REM Compile the C program with the Intel Compiler
icl /I"%PYTHON_INCLUDE%" hello_python.c /link /LIBPATH:"%PYTHON_LIB%" python3.lib

REM Check if the executable was created successfully
if exist hello_python.exe (
echo Build successful!
) else (
echo Build failed!
)

 This fails with:

Intel(R) C++ Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.7.0 Build 20220726_000000
Copyright (C) 1985-2022 Intel Corporation. All rights reserved.

hello_python.c
C:\.conan\d1de9a\1\bin\include\object.h(239): error: expected a type specifier
static inline Py_ALWAYS_INLINE int _Py_IsImmortal(PyObject *op)
^

C:\.conan\d1de9a\1\bin\include\object.h(239): error #141: unnamed prototyped parameters not allowed when body is present
static inline Py_ALWAYS_INLINE int _Py_IsImmortal(PyObject *op)
^

C:\.conan\d1de9a\1\bin\include\object.h(239): error: expected a "{"
static inline Py_ALWAYS_INLINE int _Py_IsImmortal(PyObject *op)
^

C:\.conan\d1de9a\1\bin\include\object.h(242): error: identifier "op" is undefined
return _Py_CAST(PY_INT32_T, op->ob_refcnt) < 0;
^

C:\.conan\d1de9a\1\bin\include\object.h(624): error: expected a type specifier
static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op)
^

C:\.conan\d1de9a\1\bin\include\object.h(624): error: function "__attribute__" has already been defined
static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op)
^

C:\.conan\d1de9a\1\bin\include\object.h(624): error #141: unnamed prototyped parameters not allowed when body is present
static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op)
^

C:\.conan\d1de9a\1\bin\include\object.h(624): error: expected a "{"
static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op)
^

C:\.conan\d1de9a\1\bin\include\object.h(641): error: identifier "op" is undefined
PY_UINT32_T cur_refcnt = op->ob_refcnt_split[PY_BIG_ENDIAN];
^

C:\.conan\d1de9a\1\bin\include\object.h(696): error: expected a type specifier
static inline Py_ALWAYS_INLINE void Py_DECREF(PyObject *op)
^

C:\.conan\d1de9a\1\bin\include\object.h(696): error: function "__attribute__" has already been defined
static inline Py_ALWAYS_INLINE void Py_DECREF(PyObject *op)
^

C:\.conan\d1de9a\1\bin\include\object.h(696): error #141: unnamed prototyped parameters not allowed when body is present
static inline Py_ALWAYS_INLINE void Py_DECREF(PyObject *op)
^

C:\.conan\d1de9a\1\bin\include\object.h(696): error: expected a "{"
static inline Py_ALWAYS_INLINE void Py_DECREF(PyObject *op)
^

C:\.conan\d1de9a\1\bin\include\object.h(700): error: identifier "op" is undefined
if (_Py_IsImmortal(op)) {
^

compilation aborted for hello_python.c (code 2)
Build failed!

 If "icl" is replaced with "cl" in the build script, compilation works as expected.

This appears to be an issue with more recent versions of Python.  Unfortunately, my organization currently requires the use of Intel Compiler 2021.7 because it appears the be the last version which is compatible with all of EL7, EL8, and Windows.

Any suggested workarounds would be greatly appreciated!

 

0 Kudos
1 Reply
Alex_Y_Intel
Moderator
505 Views

icl has already been deprecated and removed. Please use icx instead. 

0 Kudos
Reply