Win7 64位Python3.6安装pyOpt时出现__intrinsic_setjmpex未定义引用错误
__intrinsic_setjmpex Undefined Reference Error When Installing pyOpt on Windows 7 x64 (Python 3.6) Hey there, I’ve run into this exact linker error while setting up pyOpt on older Windows/Python combinations—let’s break down what’s going on and how to fix it:
What’s Causing the Error?
The undefined reference to __intrinsic_setjmpex issue happens because the MinGW-w64 GCC version you’re using (7.3.0) has compatibility conflicts with the MSVCRT runtime that Python 3.6 depends on. That function is a Microsoft-specific intrinsic that MinGW’s linker can’t resolve properly in this version.
Step-by-Step Fixes
Here are two reliable ways to resolve this:
1. Downgrade MinGW-w64 to Version 6.3.0
This is the most straightforward fix, as 6.3.0 has much better compatibility with Python 3.6’s runtime:
- Uninstall your current MinGW-w64 7.3.0 installation.
- Download the x86_64-win32-seh build of MinGW-w64 6.3.0 (match your system architecture).
- Install it to a path without spaces (e.g.,
C:\mingw-w64\6.3.0), then add itsbindirectory to the top of your systemPATHenvironment variable (to ensure it’s picked up before any other compilers). - Re-run your pyOpt installation command.
2. Force Linking to MSVCRT (No Version Downgrade)
If you want to keep your current MinGW version, you can tell the linker to explicitly use the MSVC runtime library:
- When installing via
pip, use this command:pip install pyopt --global-option=build_ext --global-option="-lmsvcrt" - If compiling from source manually, run:
python setup.py build_ext -lmsvcrt install
Verify the Fix
Once installation finishes, open a Python shell and test:
import pyOpt print(pyOpt.__version__)
If this runs without errors, you’re all set!
Your original error log for reference:
compiling C sources C compiler: gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall -Wstrict-prototypes compile options: '-DNPY_MINGW_USE_CUSTOM_MSVCR -D__MSVCRT_VERSION__=0x1900 -Ibuild\src.win-amd64-3.6\build\src.win-amd64-3.6\pyALGENCAN\source\f2py -IC:\Users\gporzio\AppData\Local\Programs\Python\Python36\Lib\site-packages\numpy\core\include -IC:\Users\gporzio\AppData\Local\Programs\Python\Python36\include -IC:\Users\gporzio\AppData\Local\Programs\Python\Python36\include -c' gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall -Wstrict-prototypes -DNPY_MINGW_USE_CUSTOM_MSVCR -D__MSVCRT_VERSION__=0x1900 -Ibuild\src.win-amd64-3.6\build\src.win-amd64-3.6\pyALGENCAN\source\f2py -IC:\Users\gporzio\AppData\Local\Programs\Python\Python36\Lib\site-packages\numpy\core\include -IC:\Users\gporzio\AppData\Local\Programs\Python\Python36\include -IC:\Users\gporzio\AppData\Local\Programs\Python\Python36\include -c build\src.win-amd64-3.6\pyALGENCAN\source\f2py\algencanmodule.c -o build\temp.win-amd64-3.6\Release\build\src.win-amd64-3.6\pyalgencan\source\f2py\algencanmodule.o gcc -g -DDEBUG -DMS_WIN64 -O0 -Wall -Wstrict-prototypes -DNPY_MINGW_USE_CUSTOM_MSVCR -D__MSVCRT_VERSION__=0x1900 -Ibuild\src.win-amd64-3.6\build\src.win-amd64-3.6\pyALGENCAN\source\f2py -IC:\Users\gporzio\AppData\Local\Programs\Python\Python36\Lib\site-packages\numpy\core\include -IC:\Users\gporzio\AppData\Local\Programs\Python\Python36\include -IC:\Users\gporzio\AppData\Local\Programs\Python\Python36\include -c build\src.win-amd64-3.6\build\src.win-amd64-3.6\pyALGENCAN\source\f2py\fortranobject.c -o build\temp.win-amd64-3.6\Release\build\src.win-amd64-3.6\build\src.win-amd64-3.6\pyalgencan\source\f2py\fortranobject.o compiling Fortran sources Fortran f77 compiler: C:\Program Files\mingw-w64\x86_64-7.3.0-win32-seh-rt_v5-rev0\mingw64\bin\gfortran.exe -Wall -g -ffixed-form -fno-second-underscore -O3 -funroll-loops Fortran f90 compiler: C:\Program Files\mingw-w64\x86_64-7.3.0-win32-seh-rt_v5-rev0\mingw64\bin\gfortran.exe -Wall -g -fno-second-underscore -O3 -funroll-loops Fortran fix compiler: C:\Program Files\mingw-w64\x86_64-7.3.0-win32-seh-rt_v5-rev0\mingw64\bin\gfortran.exe -Wall -g -ffixed-form -fno-second-underscore -Wall -g -fno-second-underscore -O3 -funroll-loops compile options: '-Ibuild\src.win-amd64-3.6\build\src.win-amd64-3.6\pyALGENCAN\source\f2py -IC:\Users\gporzio\AppData\Local\Programs\Python\Python36\Lib\site-packages\numpy\core\include -IC:\Users\gporzio\AppData\Local\Programs\Python\Python36\include -IC:\Users\gporzio\AppData\Local\Programs\Python\Python36\include -c' gfortran.exe:f77: build\src.win-amd64-3.6\pyALGENCAN\source\f2py\algencan-f2pywrappers.f C:\Program Files\mingw-w64\x86_64-7.3.0-win32-seh-rt_v5-rev0\mingw64\bin\gfortran.exe -Wall -g -Wall -g -shared build\temp.win-amd64-3.6\Release\build\src.win-amd64-3.6\pyalgencan\source\f2py\algencanmodule.o build\temp.win-amd64-3.6\Release\build\src.win-amd64-3.6\build\src.win-amd64-3.6\pyalgencan\source\f2py\fortranobject.o build\temp.win-amd64-3.6\Release\build\src.win-amd64-3.6\pyALGENCAN\source\f2py\algencan-f2pywrappers.o -L"C:\Program Files\mingw-w64\x86_64-7.3.0-win32-seh-rt_v5-rev0\mingw64\lib\gcc\x86_64-w64-mingw32\7.3.0" -LC:\Users\gporzio\AppData\Local\Programs\Python\Python36\libs -LC:\Users\gporzio\AppData\Local\Programs\Python\Python36\PCbuild\amd64 -Lbuild\temp.win-amd64-3.6 -lalgencan -lpython36 -lgfortran -o build\lib.win-amd64-3.6\pyOpt\pyALGENCAN\algencan.cp36-win_amd64.pyd build\temp.win-amd64-3.6\Release\build\src.win-amd64-3.6\pyalgencan\source\f2py\algencanmodule.o: In function `f2py_rout_algencan_algencan': C:\Users\gporzio\Desktop\pyOpt-1.2.0\pyOpt/build/src.win-amd64-3.6/pyALGENCAN/source/f2py/algencanmodule.c:3397: undefined reference to `__intrinsic_setjmpex' C:\Users\gporzio\Desktop\pyOpt-1.2.0\pyOpt/build/src.win-amd64-3.6/pyALGENCAN/source/f2py/algencanmodule.c:3397: undefined reference to `__intrinsic_setjmpex' C:\Users\gporzio\Desktop\pyOpt-1.2.0\pyOpt/build/src.win-amd64-3.6/pyALGENCAN/source/f2py/algencanmodule.c:3397: undefined reference to `__intrinsic_setjmpex' C:\Users\gporzio\Desktop\pyOpt-1.2.0\pyOpt/build/src.win-amd64-3.6/pyALGENCAN/source/f2py/algencanmodule.c:3397: undefined reference to `__intrinsic_setjmpex' C:\Users\gporzio\Desktop\pyOpt-1.2.0\pyOpt/build/src.win-amd64-3.6/pyALGENCAN/source/f2py/algencanmodule.c:3397: undefined reference to `__intrinsic_setjmpex' build\temp.win-amd64-3.6\Release\build\src.win-amd64-3.6\pyalgencan\source\f2py\algencanmodule.o:C:\Users\gporzio\Desktop\pyOpt-1.2.0\pyOpt/build/src.win-amd64-3.6/pyALGENCAN/source/f2py/algencanmodule.c:3397: more undefined references to `__intrinsic_setjmpex' follow collect2.exe: error: ld returned 1 exit status
内容的提问来源于stack exchange,提问作者GPorz




