Autodesk / Autodesk/maya-usd

Python related link error with --build-debug on Windows.

Open
#2,619 2 comments 0 reactions 0 assignees View on GitHub
help wanted
Dominant language
Wolfram Language
Stars
905
Forks
223
Avg merge
2d 9h
Merged PRs (30d)
17

Description

**Describe the issue**
There is a link error when specifying the "--build-debug" commandline option to the build.py script when building on Windows (not tested on other platforms):

```
python.exe build.py --generator="Visual Studio 16 2019" --install-location %INSTALL_LOCATION% --maya-location "%MAYA_BASE_LOCATION%\Maya" --pxrusd-location "..\..\USD\Debug" --devkit-location "%MAYA_BASE_LOCATION%\Maya" --qt-location c:\usr\bin\qt\5.15.2\v141 --build-debug --build-args="-DUSD_LIB_PREFIX=pxrdbg_,-DBUILD_WITH_PYTHON_3=ON" ..\
```

`LINK : fatal error LNK1104: cannot open file 'python39_d.lib'`

The issue is that when _DEBUG is defined, pyconfig.h will inject the pythonXX_d.lib, for example:

```
#if defined(_DEBUG)
# pragma comment(lib,"python39_d.lib")
#elif defined(Py_LIMITED_API)
# pragma comment(lib,"python3.lib")
#else
# pragma comment(lib,"python39.lib")
#endif /* _DEBUG */
```

It appears that the MAYAUSD_DEFINE_BOOST_DEBUG_PYTHON_FLAG is supposed to control whether to enable BOOST_DEBUG_PYTHON or not. When BOOST_DEBUG_PYTHON is not defined, _DEBUG is undefined in "wrap_python.hpp", so the non-debug version of the python library is injected. The "CMakeLists.txt" files only check for the build configuration (CMAKE_BUILD_TYPE) when determining if BOOST_DEBUG_PYTHON is defined and does not check MAYAUSD_DEFINE_BOOST_DEBUG_PYTHON_FLAG:

`$<$:BOOST_DEBUG_PYTHON>`

I don't know if this is a proper fix, but this is what I changed it to in all the CMakeLists.txt files, and it fixes the link error when MAYAUSD_DEFINE_BOOST_DEBUG_PYTHON_FLAG is off:

`$<$,$>:BOOST_DEBUG_PYTHON>`

The link error still happens if you also specify "--debug-python" to the build.py script, which turns on MAYAUSD_DEFINE_BOOST_DEBUG_PYTHON_FLAG.

**Build log**
[build_log.txt](https://github.com/Autodesk/maya-usd/files/9629297/build_log.txt) is attached

**Specs:**
Windows 10 Enterprise, version 21H1
Visual Studio 2019
Maya 2023
Maya USD commit SHA: 0.19.0, master at a2fdf40
Pixar USD commit SHA: 22.08, release at 3abc464

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with build.py's --build-debug and --debug-python handling, then inspect the CMakeLists.txt files that define BOOST_DEBUG_PYTHON. Reproduce the Windows command from the issue and review build_log.txt, checking both flag combinations. Done means the debug build no longer requests the missing python39_d.lib when --debug-python is not enabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, python
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.