Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Window compilation issue. LNK1181 error #685

Open
spyroot opened this issue Feb 12, 2022 · 3 comments
Open

Window compilation issue. LNK1181 error #685

spyroot opened this issue Feb 12, 2022 · 3 comments

Comments

@spyroot
Copy link

spyroot commented Feb 12, 2022

Describe the bug
A clear and concise description of what the bug is.

I think there is some issue when compiling under the window

I'm using the MSVC console.

LINK : warning LNK4044: unrecognized option '/fopenmp'; ignored
LINK : fatal error LNK1181: cannot open input file 'mujoco210.lib'
error: command 'D:\dev\VC\Tools\MSVC\14.29.30133\bin\HostX86\x86\link.exe' failed with exit code 1181

To Reproduce
Steps to reproduce the behavior.

Expected behavior
A clear and concise description of what you expected to happen.

Open VC Console.
conda activate env_name

set MUJOCO_PY_MUJOCO_PATH=C:\Users\X.mujoco\mujoco210
set PATH=C:\Users\X.mujoco\mujoco210;%PATH%

clone repo
python setup.py build

LINK : warning LNK4044: unrecognized option '/fopenmp'; ignored
LINK : fatal error LNK1181: cannot open input file 'mujoco210.lib'
error: command 'D:\dev\VC\Tools\MSVC\14.29.30133\bin\HostX86\x86\link.exe' failed with exit code 1181

Error Messages
Including more/longer error messages gives us more information to work with.

(X) c:\mujoco-py>python setup.py build
running build
Removing old mujoco_py cext c:\mujoco-py\mujoco_py\generated\cymj_2.1.2.14_38_windowsextensionbuilder_38.so
running build_ext
building 'mujoco_py.cymj' extension
cl : Command line warning D9025 : overriding '/W3' with '/w'
cl : Command line warning D9002 : ignoring unknown option '-fopenmp'
dummyshim.c
cl : Command line warning D9025 : overriding '/W3' with '/w'
cl : Command line warning D9002 : ignoring unknown option '-fopenmp'
cymj.c
C:\Users\X\anaconda3\envs\X\lib\site-packages\numpy\core\include\numpy\npy_1_7_deprecated_api.h(14) : Warning Msg: Using deprecated NumPy API, disable it with #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
LINK : warning LNK4044: unrecognized option '/fopenmp'; ignored
LINK : fatal error LNK1181: cannot open input file 'mujoco210.lib'
error: command 'D:\dev\VC\Tools\MSVC\14.29.30133\bin\HostX86\x86\link.exe' failed with exit code 1181

Desktop (please complete the following information):

  • OS: [e.g. Win32]
  • Python Version [e.g. 3.8]
  • Mujoco Version [e.g. 2.1.1]
  • mujoco-py version [e.g. upstream git clone]

Environment

  • output of: echo $LD_LIBRARY_PATH
  • output of: echo $HOME
  • output of: echo $USER

VC related

VCIDEInstallDir=D:\dev\Common7\IDE\VC
VCINSTALLDIR=D:\dev\VC
VCToolsInstallDir=D:\dev\VC\Tools\MSVC\14.29.30133
VCToolsRedistDir=D:\dev\VC\Redist\MSVC\14.29.30133
VCToolsVersion=14.29.30133
VisualStudioVersion=16.0
VS160COMNTOOLS=D:\dev\Common7\Tools
VSCMD_ARG_app_plat=Desktop
VSCMD_ARG_HOST_ARCH=x86
VSCMD_ARG_TGT_ARCH=x86
VSCMD_VER=16.11.10
VSINSTALLDIR=D:\dev\

Path=C:\Users\X.mujoco\mujoco210;
MUJOCO_PY_MUJOCO_PATH=C:\Users\X.mujoco\mujoco210

Conda and the rest

CommandPromptType=Native
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMPUTERNAME=X
ComSpec=C:\WINDOWS\system32\cmd.exe
CONDA_DEFAULT_ENV=X
CONDA_EXE=C:\Users\X\anaconda3\Scripts\conda.exe
CONDA_PREFIX=C:\Users\X\anaconda3\envs\X
CONDA_PROMPT_MODIFIER=(X)
CONDA_PYTHON_EXE=C:\Users\X\anaconda3\python.exe
CONDA_SHLVL=1

Additional context
Add any other context about the problem here.

I think somewhere the path to the lib file doesn't resolve correctly or maybe something different.

LINK : warning LNK4044: unrecognized option '/fopenmp'; ignored
LINK : fatal error LNK1181: cannot open input file 'mujoco210.lib'
error: command 'D:\dev\VC\Tools\MSVC\14.29.30133\bin\HostX86\x86\link.exe' failed with exit code 1181

First I think for VC it must /openmp
https://docs.microsoft.com/en-us/cpp/build/reference/openmp-enable-openmp-2-0-support?view=msvc-170
But it was ignored anyway.

So the root cause
LINK: fatal error LNK1181: cannot open input file 'mujoco210.lib'

@spyroot
Copy link
Author

spyroot commented Feb 12, 2022

Note if I add Lib and indicate direct path (mujoco) like

set LIB=C:\Users\X.mujoco\mujoco210\Lib;%LIB%

I get a million unresolved

LINK : warning LNK4044: unrecognized option '/fopenmp'; ignored
Creating library c:\mujoco-py\mujoco_py\generated_pyxbld_2.1.2.14_38_windowsextensionbuilder\temp.win32-3.8\Release\mujoco-py\mujoco_py/gl\cymj.cp38-win_amd64.lib and object c:\mujoco-py\mujoco_py\generated_pyxbld_2.1.2.14_38_windowsextensionbuilder\temp.win32-3.8\Release\mujoco-py\mujoco_py/gl\cymj.cp38-win_amd64.exp
cymj.obj : error LNK2001: unresolved external symbol __imp__mj_referenceConstraint
cymj.obj : error LNK2001: unresolved external symbol __imp__mj_integratePos
cymj.obj : error LNK2001: unresolved external symbol __imp__mj_deleteVFS
cymj.obj : error LNK2001: unresolved external symbol __imp__mj_jac
cymj.obj : error LNK2001: unresolved external symbol __imp__mj_rnePostConstraint
cymj.obj : error LNK2001: unresolved external symbol __imp__mj_setConst
cymj.obj : error LNK2001: unresolved external symbol __imp__mju_insertionSortInt
cymj.obj : error LNK2001: unresolved external symbol __imp__PyUnicode_AsEncodedString
cymj.obj : error LNK2001: unresolved external symbol __imp__mjv_initPerturb
cymj.obj : error LNK2001: unresolved external symbol __imp__mj_version
cymj.obj : error LNK2001: unresolved external symbol __imp__PyFrozenSet_Type
cymj.obj : error LNK2001: unresolved external symbol __imp__mj_activate

@spyroot
Copy link
Author

spyroot commented Feb 12, 2022

folks I complied by hand by can you tell me how I can overwrite -fopenmp

In Extension Builder

        extra_compile_args=[
            '-fopenmp',  # needed for OpenMP # in case of window /openmp
            '-w',  # suppress numpy compilation warnings / no need that
        ],

class MujocoExtensionBuilder():

CYMJ_DIR_PATH = abspath(dirname(__file__))

def __init__(self, mujoco_path):
    self.mujoco_path = mujoco_path
    python_version = str(sys.version_info.major) + str(sys.version_info.minor)
    self.version = '%s_%s_%s' % (get_version(), python_version, self.build_base())
    self.extension = Extension(
        'mujoco_py.cymj',
        sources=[join(self.CYMJ_DIR_PATH, "cymj.pyx")],
        include_dirs=[
            self.CYMJ_DIR_PATH,
            join(mujoco_path, 'include'),
            np.get_include(),
        ],
        libraries=['mujoco210'],
        library_dirs=[join(mujoco_path, 'bin')],
        extra_compile_args=[
            '-fopenmp',  # needed for OpenMP
            '-w',  # suppress numpy compilation warnings
        ],
        extra_link_args=['-fopenmp'],
        language='c')

@spyroot
Copy link
Author

spyroot commented Feb 12, 2022

I added a pull request it fixes window compilation issues with the visual studio
#686

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant