Compiler errors involving Python

  • 13 Replies
  • 6494 Views
Compiler errors involving Python
« on: April 03, 2023, 11:04:50 PM »
Hi there,

I'm trying to compile from source, and I'm following the build pdf in the develop branch for the software. On Step 1 for Windows, I'm running into a problem involving Python/pybind. I have Python 3.11.2 installed, and my machine is Windows 11. Any assistance is appreciated.

From the MSYS2 MINGW64 terminal:
Code: [Select]
$ mingw32-make package
[  1%] Built target libUsb
[  1%] Built target wxregex
[  3%] Built target wxzlib
[ 15%] Built target base
[ 17%] Built target wxexpat
[ 17%] Built target xml
[ 30%] Built target SDL2-static
[ 35%] Built target wxjpeg
[ 37%] Built target wxpng
[ 72%] Built target core
[ 72%] Built target adv
[ 75%] Built target html
[ 75%] Built target propgrid
[ 77%] Built target richtext
[ 92%] Built target wxscintilla
[ 92%] Built target stc
[ 92%] Building CXX object source/CMakeFiles/ScopeFun.dir/scopefun/app/app.cpp.obj
[ 92%] Building CXX object source/CMakeFiles/ScopeFun.dir/scopefun/gui/osc.cpp.obj
[ 92%] Building CXX object source/CMakeFiles/ScopeFun.dir/scopefun/gui/OsciloskopConnection.cpp.obj
[ 93%] Building CXX object source/CMakeFiles/ScopeFun.dir/scopefun/gui/OsciloskopDebug.cpp.obj
[ 93%] Building CXX object source/CMakeFiles/ScopeFun.dir/scopefun/gui/OsciloskopDisplay.cpp.obj
[ 93%] Building CXX object source/CMakeFiles/ScopeFun.dir/scopefun/gui/OsciloskopHardwareGenerator.cpp.obj
[ 93%] Building CXX object source/CMakeFiles/ScopeFun.dir/scopefun/gui/OsciloskopInfo.cpp.obj
[ 93%] Building CXX object source/CMakeFiles/ScopeFun.dir/scopefun/gui/OsciloskopMeasure.cpp.obj
[ 93%] Building CXX object source/CMakeFiles/ScopeFun.dir/scopefun/gui/OsciloskopOsciloskop.cpp.obj
[ 93%] Building CXX object source/CMakeFiles/ScopeFun.dir/scopefun/gui/OsciloskopSoftwareGenerator.cpp.obj
[ 93%] Building CXX object source/CMakeFiles/ScopeFun.dir/scopefun/gui/OsciloskopStorage.cpp.obj
[ 93%] Building CXX object source/CMakeFiles/ScopeFun.dir/scopefun/gui/OsciloskopThermal.cpp.obj
[ 93%] Building CXX object source/CMakeFiles/ScopeFun.dir/scopefun/gui/OsciloskopTools.cpp.obj
[ 94%] Building C object source/CMakeFiles/ScopeFun.dir/api/scopefunapi.c.obj
C:\msys64\home\Jared\scopefun-software\source\api\scopefunapi.c: In function 'sfApiExit':
C:\msys64\home\Jared\scopefun-software\source\api\scopefunapi.c:338:5: warning: implicit declaration of function 'socketExit' [-Wimplicit-function-declaration]
  338 |     socketExit();
      |     ^~~~~~~~~~
[ 94%] Linking CXX executable sfDebug.exe
[ 98%] Built target ScopeFun
[100%] Building CXX object source/CMakeFiles/pythonApi.dir/api/pythonApi/pythonApi.cpp.obj
In file included from C:/msys64/home/Jared/scopefun-software/lib/pybind11/include/pybind11/cast.h:1
,
                 from C:/msys64/home/Jared/scopefun-software/lib/pybind11/include/pybind11/attr.h:1
,
                 from C:/msys64/home/Jared/scopefun-software/lib/pybind11/include/pybind11/pybind11.h:13,
                 from C:\msys64\home\Jared\scopefun-software\source\api\pythonApi\pythonApi.cpp:22:
C:/msys64/home/Jared/scopefun-software/lib/pybind11/include/pybind11/detail/type_caster_base.h: In function 'std::string pybind11::detail::error_string()':
C:/msys64/home/Jared/scopefun-software/lib/pybind11/include/pybind11/detail/type_caster_base.h:473:36: error: invalid use of incomplete type 'PyFrameObject' {aka 'struct _frame'}
  473 |                 "  " + handle(frame->f_code->co_filename).cast<std::string>() +
      |                                    ^~
In file included from C:/Users/Jared/AppData/Local/Programs/Python/Python311/include/Python.h:42,
                 from C:/msys64/home/Jared/scopefun-software/lib/pybind11/include/pybind11/detail/common.h:186,
                 from C:/msys64/home/Jared/scopefun-software/lib/pybind11/include/pybind11/pytypes.h:12,
                 from C:/msys64/home/Jared/scopefun-software/lib/pybind11/include/pybind11/cast.h:1
:
C:/Users/Jared/AppData/Local/Programs/Python/Python311/include/pytypedefs.h:22:16: note: forward declaration of 'PyFrameObject' {aka 'struct _frame'}
   22 | typedef struct _frame PyFrameObject;
      |                ^~~~~~
C:/msys64/home/Jared/scopefun-software/lib/pybind11/include/pybind11/detail/type_caster_base.h:473:75: error: expected primary-expression before '>' token
  473 |                 "  " + handle(frame->f_code->co_filename).cast<std::string>() +
      |                                                                           ^
C:/msys64/home/Jared/scopefun-software/lib/pybind11/include/pybind11/detail/type_caster_base.h:473:77: error: expected primary-expression before ')' token
  473 |                 "  " + handle(frame->f_code->co_filename).cast<std::string>() +
      |                                                                             ^
C:/msys64/home/Jared/scopefun-software/lib/pybind11/include/pybind11/detail/type_caster_base.h:475:29: error: invalid use of incomplete type 'PyFrameObject' {aka 'struct _frame'}
  475 |                 handle(frame->f_code->co_name).cast<std::string>() + "\n";
      |                             ^~
C:/Users/Jared/AppData/Local/Programs/Python/Python311/include/pytypedefs.h:22:16: note: forward declaration of 'PyFrameObject' {aka 'struct _frame'}
   22 | typedef struct _frame PyFrameObject;
      |                ^~~~~~
C:/msys64/home/Jared/scopefun-software/lib/pybind11/include/pybind11/detail/type_caster_base.h:475:64: error: expected primary-expression before '>' token
  475 |                 handle(frame->f_code->co_name).cast<std::string>() + "\n";
      |                                                                ^
C:/msys64/home/Jared/scopefun-software/lib/pybind11/include/pybind11/detail/type_caster_base.h:475:66: error: expected primary-expression before ')' token
  475 |                 handle(frame->f_code->co_name).cast<std::string>() + "\n";
      |                                                                  ^
C:/msys64/home/Jared/scopefun-software/lib/pybind11/include/pybind11/detail/type_caster_base.h:476:26: error: invalid use of incomplete type 'PyFrameObject' {aka 'struct _frame'}
  476 |             frame = frame->f_back;
      |                          ^~
C:/Users/Jared/AppData/Local/Programs/Python/Python311/include/pytypedefs.h:22:16: note: forward declaration of 'PyFrameObject' {aka 'struct _frame'}
   22 | typedef struct _frame PyFrameObject;
      |                ^~~~~~
C:/msys64/home/Jared/scopefun-software/lib/pybind11/include/pybind11/pybind11.h: In function 'pybind11::function pybind11::detail::get_type_override(const void*, const type_info*, const char*)':
C:/msys64/home/Jared/scopefun-software/lib/pybind11/include/pybind11/pybind11.h:2338:49: error: 'PyThreadState' {aka 'struct _ts'} has no member named 'frame'; did you mean 'cframe'?
 2338 |     PyFrameObject *frame = PyThreadState_Get()->frame;
      |                                                 ^~~~~
      |                                                 cframe
C:/msys64/home/Jared/scopefun-software/lib/pybind11/include/pybind11/pybind11.h:2339:52: error: invalid use of incomplete type 'PyFrameObject' {aka 'struct _frame'}
 2339 |     if (frame != nullptr && (std::string) str(frame->f_code->co_name) == name
      |                                                    ^~
C:/Users/Jared/AppData/Local/Programs/Python/Python311/include/pytypedefs.h:22:16: note: forward declaration of 'PyFrameObject' {aka 'struct _frame'}
   22 | typedef struct _frame PyFrameObject;
      |                ^~~~~~
C:/msys64/home/Jared/scopefun-software/lib/pybind11/include/pybind11/pybind11.h:2340:17: error: invalid use of incomplete type 'PyFrameObject' {aka 'struct _frame'}
 2340 |         && frame->f_code->co_argcount > 0) {
      |                 ^~
C:/Users/Jared/AppData/Local/Programs/Python/Python311/include/pytypedefs.h:22:16: note: forward declaration of 'PyFrameObject' {aka 'struct _frame'}
   22 | typedef struct _frame PyFrameObject;
      |                ^~~~~~
C:/msys64/home/Jared/scopefun-software/lib/pybind11/include/pybind11/pybind11.h:2343:18: error: invalid use of incomplete type 'PyFrameObject' {aka 'struct _frame'}
 2343 |             frame->f_locals, PyTuple_GET_ITEM(frame->f_code->co_varnames, 0));
      |                  ^~
C:/Users/Jared/AppData/Local/Programs/Python/Python311/include/pytypedefs.h:22:16: note: forward declaration of 'PyFrameObject' {aka 'struct _frame'}
   22 | typedef struct _frame PyFrameObject;
      |                ^~~~~~
In file included from C:/Users/Jared/AppData/Local/Programs/Python/Python311/include/Python.h:35:
C:/msys64/home/Jared/scopefun-software/lib/pybind11/include/pybind11/pybind11.h:2343:30: error: invalid use of incomplete type 'PyFrameObject' {aka 'struct _frame'}
 2343 |             frame->f_locals, PyTuple_GET_ITEM(frame->f_code->co_varnames, 0));
      |                              ^~~~~~~~~~~~~~~~
C:/Users/Jared/AppData/Local/Programs/Python/Python311/include/pytypedefs.h:22:16: note: forward declaration of 'PyFrameObject' {aka 'struct _frame'}
   22 | typedef struct _frame PyFrameObject;
      |                ^~~~~~
In file included from C:/Users/Jared/AppData/Local/Programs/Python/Python311/include/Python.h:38:
C:/msys64/home/Jared/scopefun-software/lib/pybind11/include/pybind11/pybind11.h:2343:30: error: invalid use of incomplete type 'PyFrameObject' {aka 'struct _frame'}
 2343 |             frame->f_locals, PyTuple_GET_ITEM(frame->f_code->co_varnames, 0));
      |                              ^~~~~~~~~~~~~~~~
C:/Users/Jared/AppData/Local/Programs/Python/Python311/include/pytypedefs.h:22:16: note: forward declaration of 'PyFrameObject' {aka 'struct _frame'}
   22 | typedef struct _frame PyFrameObject;
      |                ^~~~~~
mingw32-make[2]: *** [source\CMakeFiles\pythonApi.dir\build.make:76: source/CMakeFiles/pythonApi.dir/api/pythonApi/pythonApi.cpp.obj] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:1324: source/CMakeFiles/pythonApi.dir/all] Error 2
mingw32-make: *** [Makefile:155: all] Error 2



*

Dejan

  • *****
  • 150
    • View Profile
Re: Compiler errors involving Python
« Reply #1 on: April 04, 2023, 11:31:35 AM »
Hi episense,

Thanks for reporting the problem.

Python API compilation was tested working with Python version is 3.9.5. I have not tested compilation with later Python versions.

A similar problem with Python 3.11 and pybind11 was reported here: https://github.com/pybind/pybind11/discussions/4333.  According to this report, It looks like some changes were introduced in Python version 3.11 that prevent successful compilation. I will need to update the version of pybind11 included in the ScopeFun source code.

Meanwhile, could you try to use the Python version 3.9.5 for compiling? If you require Python version 3.11.2 for some specific reason, please also let me know.

Re: Compiler errors involving Python
« Reply #2 on: April 05, 2023, 09:50:56 PM »
Thank you - I swapped to Python 3.9.5 and that furthered the compilation past the ScopeFun step, but I seem to have some new errors with missing definitions for the pythonApi step. I did some searching and some users suggest there may be problems with 32-bit vs 64 versions in my installation? I appreciate the help.

Code: [Select]
$ mingw32-make package
[  1%] Built target libUsb
[  2%] Built target wxexpat
[  2%] Built target wxregex
[  4%] Built target wxzlib
[ 17%] Built target base
[ 17%] Built target xml
[ 30%] Built target SDL2-static
[ 35%] Built target wxjpeg
[ 37%] Built target wxpng
[ 72%] Built target core
[ 72%] Built target adv
[ 75%] Built target html
[ 75%] Built target propgrid
[ 89%] Built target wxscintilla
[ 92%] Built target richtext
[ 92%] Built target stc
[ 98%] Built target ScopeFun
[ 98%] Linking CXX shared module scopefun.cp39-win_amd64.pyd
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\pythonApi.dir/objects.a(pythonApi.cpp.obj): in function `_Py_INCREF':
C:/Users/Jared/AppData/Local/Programs/Python/Python39/include/object.h:406: undefined reference to `__imp__Py_RefTotal'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/Jared/AppData/Local/Programs/Python/Python39/include/object.h:406: undefined reference to `__imp__Py_RefTotal'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\pythonApi.dir/objects.a(pythonApi.cpp.obj): in function `_Py_DECREF':
C:/Users/Jared/AppData/Local/Programs/Python/Python39/include/object.h:420: undefined reference to `__imp__Py_RefTotal'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/Jared/AppData/Local/Programs/Python/Python39/include/object.h:420: undefined reference to `__imp__Py_RefTotal'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/Jared/AppData/Local/Programs/Python/Python39/include/object.h:425: undefined reference to `__imp__Py_NegativeRefcount'
collect2.exe: error: ld returned 1 exit status
mingw32-make[2]: *** [source\CMakeFiles\pythonApi.dir\build.make:187: source/scopefun.cp39-win_amd64.pyd] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:1324: source/CMakeFiles/pythonApi.dir/all] Error 2
mingw32-make: *** [Makefile:155: all] Error 2

*

Dejan

  • *****
  • 150
    • View Profile
Re: Compiler errors involving Python
« Reply #3 on: April 07, 2023, 02:13:08 PM »
You should install 64-bit program versions.

I'm not sure why you are getting errors at linking stage. Do you have multiple Python versions installed? If so, remove other versions. Check if Python lib folder is added to the Windows PATH variable and try to build again from a clean build folder.

If you are still getting errors, please provide complete build log.
« Last Edit: April 07, 2023, 02:14:48 PM by Dejan »

Re: Compiler errors involving Python
« Reply #4 on: April 07, 2023, 07:27:42 PM »
I've tried your suggested fixes, and I'm still getting errors.

Here's the log from a fresh build.
pastebin[.]com/raw/iiS3A7C2

Re: Compiler errors involving Python
« Reply #5 on: April 07, 2023, 07:30:21 PM »
(I attached via pastebin since the log exceeded max character limit)

*

Dejan

  • *****
  • 150
    • View Profile
Re: Compiler errors involving Python
« Reply #6 on: April 07, 2023, 08:33:17 PM »
Did you try to re-run the cmake configure step? This is where the include paths are set.

Re: Compiler errors involving Python
« Reply #7 on: April 10, 2023, 04:48:26 PM »
Yes, I reconfigured from cmake in this build.

*

Dejan

  • *****
  • 150
    • View Profile
Re: Compiler errors involving Python
« Reply #8 on: April 12, 2023, 10:36:34 PM »
Double check that you have the following entries in your Windows Path (in this order):
C:\Users\<your_windows_username>\AppData\Local\Programs\Python\Python39\Scripts\
C:\Users\<your_windows_username>\AppData\Local\Programs\Python\Python39\
C:\msys64\mingw64\bin


Double check that you installed all the required programs in "MSYS2 MinGW 64-bit":

pacman -Su
pacman -S mingw-w64-x86_64-gcc
pacman -S git
pacman -S make
pacman -S mingw-w64-x86_64-make
pacman -S msys/automake-wrapper
pacman -S msys/autoconf
pacman -S mingw-w64-x86_64-nsis


When performing the cmake configure step (before generate step), please check if you get the following output (note the Found Python... log entries):

Code: [Select]
...
pybind11 v2.9.0 dev1
Found PythonInterp: C:/Users/Win10/AppData/Local/Programs/Python/Python39/python.exe (found version "3.9.5")
Found PythonLibs: C:/Users/Win10/AppData/Local/Programs/Python/Python39/libs/python39.lib
pybind11::lto disabled (problems with undefined symbols for MinGW for now)
pybind11::thin_lto disabled (problems with undefined symbols for MinGW for now)
Found Python: C:/Users/Win10/AppData/Local/Programs/Python/Python39/python.exe (found suitable version "3.9.5", minimum required is "3.9.5") found components: Interpreter Development Development.Module Development.Embed
Configuring done

Re: Compiler errors involving Python
« Reply #9 on: April 13, 2023, 10:52:26 PM »
I've double checked the paths and the packages to be all set and installed correctly. I can see that Python is being found during the configure step in Cmake. I ran a fresh build once more after this and now I have a different error.

Code: [Select]
[ 92%] Built target adv
[ 92%] Building CXX object source/CMakeFiles/ScopeFun.dir/core/core.cpp.obj
[ 92%] Building CXX object source/CMakeFiles/ScopeFun.dir/core/render/camera/camera.cpp.obj
[ 92%] Building CXX object source/CMakeFiles/ScopeFun.dir/core/render/canvas/canvas2d.cpp.obj
[ 92%] Building CXX object source/CMakeFiles/ScopeFun.dir/core/render/canvas/canvas3d.cpp.obj
[ 93%] Building CXX object source/CMakeFiles/ScopeFun.dir/core/render/render/render.cpp.obj
[ 93%] Building CXX object source/CMakeFiles/ScopeFun.dir/core/render/font/font.cpp.obj
[ 93%] Building CXX object source/CMakeFiles/ScopeFun.dir/core/string/corestring.cpp.obj
[ 93%] Building CXX object source/CMakeFiles/ScopeFun.dir/core/file/file.cpp.obj
[ 93%] Building CXX object source/CMakeFiles/ScopeFun.dir/core/format/format.cpp.obj
C:\msys64\home\Jared\scopefun-software\source\core\format\format.cpp: In member function 'int FormatManager::formatPathWinAppData(char*, int, const char*)':
C:\msys64\home\Jared\scopefun-software\source\core\format\format.cpp:123:18: error: 'SHGetKnownFolderPath' was not declared in this scope; did you mean 'SHGetFolderPath'?
  123 |     HRESULT hr = SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, NULL, &ppszPath);
      |                  ^~~~~~~~~~~~~~~~~~~~
      |                  SHGetFolderPath
mingw32-make[2]: *** [source\CMakeFiles\ScopeFun.dir\build.make:196: source/CMakeFiles/ScopeFun.dir/core/format/format.cpp.obj] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:1298: source/CMakeFiles/ScopeFun.dir/all] Error 2
mingw32-make: *** [Makefile:155: all] Error 2

*

Dejan

  • *****
  • 150
    • View Profile
Re: Compiler errors involving Python
« Reply #10 on: April 21, 2023, 02:07:06 PM »
I have tried to compile in Windows 11, but I was unable to duplicate the problem with SHGetKnownFolderPath declaration.

However, I did encounter another problem initially during the cmake configure step. The problem was related to SDL2 requirement for DirectX SDK. After installing [Windows SDK](https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/) and adding DXSDK_DIR to Windows Environment Variables, the compilation was successful.

I have added additional comment about the DXSDK_DIR variable in the [ScopeFun compilation instructions](https://gitlab.com/scopefun/scopefun-software/-/wikis/Developers-Guide/Building-software-from-source).

If you are still having problems after the Windows SDK installtion, try to delete cmake cache and re-run cmake configure, before compiling. In cmake, go to File -> Delete Cache.

Re: Compiler errors involving Python
« Reply #11 on: April 25, 2023, 06:02:32 PM »
I've installed the Windows SDK and I have no issues with DirectX during configuration, but I'm now getting the same Python errors as before during linking. I've tried deleting the cache and even doing a full fresh build. My path includes both the Python39 folder and Python39\Scripts. I've tried adding the Python39\libs folder as well.

Python also seems to be discovered properly during the configuration step in CMake.

Code: [Select]

$ mingw32-make package
[  1%] Built target libUsb
[  3%] Built target wxzlib
[  3%] Built target wxregex
[ 15%] Built target base
[ 17%] Built target wxexpat
[ 17%] Built target xml
[ 30%] Built target SDL2-static
[ 35%] Built target wxjpeg
[ 37%] Built target wxpng
[ 72%] Built target core
[ 72%] Built target adv
[ 72%] Built target propgrid
[ 75%] Built target html
[ 77%] Built target richtext
[ 92%] Built target wxscintilla
[ 92%] Built target stc
[ 92%] Building CXX object source/CMakeFiles/ScopeFun.dir/scopefun/app/app.cpp.obj
[ 92%] Building CXX object source/CMakeFiles/ScopeFun.dir/scopefun/gui/osc.cpp.obj
[ 92%] Building CXX object source/CMakeFiles/ScopeFun.dir/scopefun/gui/OsciloskopConnection.cpp.obj
[ 93%] Building CXX object source/CMakeFiles/ScopeFun.dir/scopefun/gui/OsciloskopDebug.cpp.obj
[ 93%] Building CXX object source/CMakeFiles/ScopeFun.dir/scopefun/gui/OsciloskopDisplay.cpp.obj
[ 93%] Building CXX object source/CMakeFiles/ScopeFun.dir/scopefun/gui/OsciloskopHardwareGenerator.cpp.obj
[ 93%] Building CXX object source/CMakeFiles/ScopeFun.dir/scopefun/gui/OsciloskopInfo.cpp.obj
[ 93%] Building CXX object source/CMakeFiles/ScopeFun.dir/scopefun/gui/OsciloskopMeasure.cpp.obj
[ 93%] Building CXX object source/CMakeFiles/ScopeFun.dir/scopefun/gui/OsciloskopOsciloskop.cpp.obj
[ 93%] Building CXX object source/CMakeFiles/ScopeFun.dir/scopefun/gui/OsciloskopSoftwareGenerator.cpp.obj
[ 93%] Building CXX object source/CMakeFiles/ScopeFun.dir/scopefun/gui/OsciloskopStorage.cpp.obj
[ 93%] Building CXX object source/CMakeFiles/ScopeFun.dir/scopefun/gui/OsciloskopThermal.cpp.obj
[ 93%] Building CXX object source/CMakeFiles/ScopeFun.dir/scopefun/gui/OsciloskopTools.cpp.obj
[ 94%] Building C object source/CMakeFiles/ScopeFun.dir/api/scopefunapi.c.obj
C:\msys64\home\jared\scopefun-software\source\api\scopefunapi.c: In function 'sfApiExit':
C:\msys64\home\jared\scopefun-software\source\api\scopefunapi.c:338:5: warning: implicit declaration of function 'socketExit' [-Wimplicit-function-declaration]
  338 |     socketExit();
      |     ^~~~~~~~~~
[ 94%] Linking CXX executable sfDebug.exe
[ 98%] Built target ScopeFun
[100%] Building CXX object source/CMakeFiles/pythonApi.dir/api/pythonApi/pythonApi.cpp.obj
[100%] Building C object source/CMakeFiles/pythonApi.dir/api/scopefunapi.c.obj
C:\msys64\home\jared\scopefun-software\source\api\scopefunapi.c: In function 'sfApiExit':
C:\msys64\home\jared\scopefun-software\source\api\scopefunapi.c:338:5: warning: implicit declaration of function 'socketExit' [-Wimplicit-function-declaration]
  338 |     socketExit();
      |     ^~~~~~~~~~
[100%] Linking CXX shared module scopefun.cp39-win_amd64.pyd
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\pythonApi.dir/objects.a(pythonApi.cpp.obj): in function `_Py_INCREF':
C:/Users/jared/AppData/Local/Programs/Python/Python39/include/object.h:406: undefined reference to `__imp__Py_RefTotal'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/jared/AppData/Local/Programs/Python/Python39/include/object.h:406: undefined reference to `__imp__Py_RefTotal'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\pythonApi.dir/objects.a(pythonApi.cpp.obj): in function `_Py_DECREF':
C:/Users/jared/AppData/Local/Programs/Python/Python39/include/object.h:420: undefined reference to `__imp__Py_RefTotal'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/jared/AppData/Local/Programs/Python/Python39/include/object.h:420: undefined reference to `__imp__Py_RefTotal'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/jared/AppData/Local/Programs/Python/Python39/include/object.h:425: undefined reference to `__imp__Py_NegativeRefcount'
collect2.exe: error: ld returned 1 exit status
mingw32-make[2]: *** [source\CMakeFiles\pythonApi.dir\build.make:187: source/scopefun.cp39-win_amd64.pyd] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:1324: source/CMakeFiles/pythonApi.dir/all] Error 2
mingw32-make: *** [Makefile:155: all] Error 2


*

Dejan

  • *****
  • 150
    • View Profile
Re: Compiler errors involving Python
« Reply #12 on: May 03, 2023, 09:10:40 AM »
I'm still not sure why you are  getting these errors... Maybe something is broken with your Python installation and you would need to re-install Python.

Another option you can try is to use Python which is provided with MSYS2. To verify which Python version is provided with MSYS2, enter the following command in the MSYS2 MINGW64 terminal:

Code: [Select]
$ pacman -Sl | grep "python " | grep "installed"
mingw64 mingw-w64-x86_64-python 3.10.11-1 [installed]

Uninstall Python 3.9.5 from Windows completely, leaving only Python which is provided with MSYS2.

For the cmake configure step, instead of using cmake-GUI Windows application, use cmake provided with MSYS2:

cd scopefun-software/
mkdir build && cd build
cmake -G "MinGW Makefiles" -D SCOPEFUN_VERSION_MAJOR="2" -D SCOPEFUN_VERSION_MINOR="2" -D SCOPEFUN_VERSION_MICRO="0" -D SCOPEFUN_BUILD_TYPE="Release" ..


Note: cmake can be installed with pacman -S mingw-w64-x86_64-cmake

In the cmake log output you should see the following:
Code: [Select]
...
-- pybind11 v2.9.0 dev1
-- Found PythonInterp: C:/msys64/mingw64/bin/python3.10.exe (found version "3.10.11")
-- Found PythonLibs: C:/msys64/mingw64/lib/libpython3.10.dll.a
-- pybind11::lto disabled (problems with undefined symbols for MinGW for now)
-- pybind11::thin_lto disabled (problems with undefined symbols for MinGW for now)
-- Found Python: C:/msys64/mingw64/bin/python3.10.exe (found suitable version "3.10.11", minimum required is "3.9") found components: Interpreter Development Development.Module Development.Embed
-- Configuring done (123.6s)
-- Generating done (0.8s)

After that you can build ScopeFun with:
mingw32-make package
« Last Edit: May 03, 2023, 10:09:50 AM by Dejan »

Re: Compiler errors involving Python
« Reply #13 on: May 08, 2023, 07:50:44 PM »
I tried using the Python built-in to MSYS2 and uninstalled Python 3.9.5, and I was able to compile the first step.

I ran everything including CMake through MSYS2 itself and everything compiled successfully. Even the CodeBlocks build was successful. I now have a problem with the full build, but that's a separate issue worthy of a different post. My initial issue with Python was fixed by this suggestion - thank you for the help!