LINK : fatal error LNK1104: cannot open file 'python37_d.lib' - python

I was trying to integrate Python interpreter in C++ application in Visual Studio 2013, despite of adding INCLUDES and ENV VARIABLES such as LIB & LIBPATH, compilation is throwing an Error as
LINK : fatal error LNK1104: cannot open file 'python37_d.lib'.
I tried all possible google suggestions, but still I am not able get rid of this Error. Any help on this would be highly appreciated.

This library is intended for debugging, and you simply don't have it if the Python was installed with default options. To obtain it, you are to (re)install Python with "Download debug binaries" option enabled in the installer. Then the python37_d.lib will be located in %PythonPath%\Libs together with python3_d.lib.

Following up the Suthiro's answer, you can also explicitly specify Debug or Release configurations for multi-configuration generators (Ninja Multi-Config, Visual Studio) by running
# Configure the build
cmake -S . -B build
# Actually build the binaries
cmake --build build --config Release
in your source directory.
For single configuration generators and more details see this answer https://stackoverflow.com/a/64719718/15452880.

Related

Unable to find package 'pythonx86' via nuget

I downloaded the CPython source code from the CPython GitHub repo and ran .\PCBuild\build.bat -p x64 -c Debug in the command line of VScode. Inside .\cpython\PCBuild\ it consists build.bat. As I wanted to make a compiled CPython binary, executing build.bat will create .\PCBuild\amd64\python_d.exe.When that .bat file gets executed it says,
Installing Python via nuget...
Feeds used:
Installing package 'pythonx86' to 'D:\CHETAN\cpython\externals'
and print the error message as :
Unable to find package 'pythonx86'
Can anyone have a fix for this. Any help will be appreciated.
Try to build the source code with the latest Visual Studio.
Visual Studio 2022 Community can work well:
The external folder only contains following packages:
You can also use dumpbin to check python_d.exe dependents.

LINK : fatal error LNK1104: cannot open file 'python38.lib' with CMake finding library

I'm trying to link a python library to a CMake target and build a module from it (using Boost.Python3). CMake correctly finds Boost.Python3 and Python3, but when linking, I get the error LINK : fatal error LNK1104: cannot open file 'python38.lib'
I have added the correct python38.lib to my PATH (and LIBPATH), and CMake correctly finds the library:
message(STATUS "Python3_LIBRARIES = ${Python3_LIBRARIES}")
results in
-- Python3_LIBRARIES = optimized;C:/Program Files/Python38/libs/python38.lib;debug;C:/Program Files/Python38/libs/python38_d.lib
and I link all the libraries:
target_link_libraries(trgt PRIVATE
${Boost_LIBRARIES}
${Python3_LIBRARIES}
Python3::Python # tried with and without this line
trgtCore)
I'm compiling with $ cmake .. "-GVisual Studio 16 2019" -A x64 which matches my x64 installation of Python 3.8.
I had this same problem when installing opencv version 4 from github, I solved it by copying the .lib file into the visual studio project.
Hope it helps,
Amar.
The same problem occurs for me only when building Debug configuration. Release cfg is been built without this problem.
Debug cfg was been built normally until I installed debug symbols package. Maybe the problem somewhere in there.
Based on this discussion https://github.com/microsoft/vcpkg/issues/10649

install METIS library for python3 on windows7

I want to install METIS for python3.6 on windows7.I did the following steps:
1-Download the source (tar.gz or zip file) from
https://pypi.python.org/pypi/networkx-metis/
2-Unpack and change directory to the source directory (it should have the
setup.py on top level).
3-Run
python setup.py build
to build
in this step, I encountered the following error:
error: Microsoft Visual C++ 14.0 is required.
i installed "Visual Studio Tools 2017", Then I run the code again. I encountered the following error:
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio
14.0\\VC\\BIN\\cl.exe' failed with exit status 2
I would be very grateful if you answer my questions.
Although what I used was Windows 10, perhaps the same steps as I laid out here may work for you.
First, you should get the python metis wrapper using pip: pip install metis.
Second, you must install conda-metis, which you can find here. Note, it does not require you to install Anaconda to work.
Place the files in conda-metis-master in some file path.
The installation requires some fixes. Make sure you have a recent version of Visual Studios (I used 2017). For me, VS had a problem running the instructions in BUILD-WINDOWS.txt, which landed me on this thread:
Why does MSBuild look in C:\ for Microsoft.Cpp.Default.props instead of c:\Program Files (x86)\MSBuild? ( error MSB4019)
Specifically, the answer For Visual Studio 2017 and 2019 on Windows 10 was what I went with. It could potentially be different for you since you are on Windows 7.
For the python metis package, we need to generate a metis.dll, not a metis.lib file, so we must also look closer at the CMakeLists.txt (see the Linux version of this discussion here). We add on line 19: set(METIS_LIBRARY_TYPE SHARED).
You should follow the BUILD-WINDOWS.txt instructions, but run .\vsgen -G "Visual Studio 15 2017 Win64" inside your conda-metis file path in command prompt with full permissions instead of using Visual Studio 10.
Before moving on to using the files that were generated by the above command in path_to_your_metis_dir\build\windows\, we need another fix. Following what was said in:
rint() issue after creating VS Project using CMake
we have to edit the file path_to_your_metis_dir\GKlib\gk_arch.h by removing the line: #define rint(x) ((idx_t)((x)+0.5)). (Or the fix listed on this github exchange.)
Then go to path_to_your_metis_dir\build\windows\.
Open METIS.sln in Visual Studios, go to the top to Build and from the scroll-down go to Build Solution. Afterwards, the .dll file will be in path_to_your_metis_dir\build\windows\libmetis\Release\.
Last, we run in command prompt:
set METIS_DLL=path_to_your_metis_dir\build\windows\libmetis\Release\metis.dll
After this, python metis no longer failed when I would import it into my code with the step from metis import *.

How to install METIS package in python on windows?

I am currently running a source code in python which uses METIS. I wanted to run it using Jetbrains PyCharm, conda interpreter and these are installed on windows 10. Although I have installed METIS using conda, I could not enable shared libraries and I faced this error:
ModuleNotFoundError: No module named 'metis'
When I tried to run it without conda I faced the following error although I have added the metis.dll location to the environment variables.
RuntimeError: Could not load METIS dll
Could anyone please help me about it?
This question is old, but I ran into the same problem and after going down the rabbit's hole for.. too long... I have an answer that worked for me.
First, you should get the python metis wrapper using pip: pip install metis.
Second, You must install conda-metis, which you can find here. Although pip calls the metis python wrapper metis, it just the metis wrapper and does not have metis itself.
Place the files in conda-metis-master in some file path.
The installation requires some fixes. Make sure you have a recent version of Visual Studios (I used 2017). For me, VS had a problem running the instructions in BUILD-WINDOWS.txt, which landed me on this thread:
Why does MSBuild look in C:\ for Microsoft.Cpp.Default.props instead of c:\Program Files (x86)\MSBuild? ( error MSB4019)
Specifically, the answer For Visual Studio 2017 and 2019 on Windows 10 was what I went with. Run:
set VCTargetPaths=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets
in command prompt with full permissions to set the environment variable.
Also go to Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ in regedit and change in 4.0 the variable MSBuildOverrideTasksPath and in ToolsVersion\4.0\ the variable MSBuildToolPath to C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin.
For the python metis, we need a .dll, not .lib[1], so we must also look closer at the CMakeLists.txt (see the Linux version of this discussion here). We add on line 19: set(METIS_LIBRARY_TYPE SHARED).
You should follow the BUILD-WINDOWS.txt instructions, but run .\vsgen -G "Visual Studio 15 2017 Win64" inside your conda-metis file path in command prompt with full permissions instead of using Visual Studio 10.
Wait! We need another fix before following the instructions further on using VS to build the the library. Following what was said in:
rint() issue after creating VS Project using CMake
we have to edit the file path_to_your_metis_dir\GKlib\gk_arch.h by removing the line: #define rint(x) ((idx_t)((x)+0.5)). (Or the fix listed on this github exchange.)
Then go to path_to_your_metis_dir\build\windows\.
Open METIS.sln in Visual Studios, go to the top to Build and from the scroll-down go to Build Solution. Afterwards, the .dll file will be in path_to_your_metis_dir\build\windows\libmetis\Release\.
Last, we run in command prompt:
set METIS_DLL=path_to_your_metis_dir\build\windows\libmetis\Release\metis.dll
After this, python metis no longer failed on the step from metis import * for me.
[1] If we could use .lib, then conda install -c conda-forge metis would work to get this file, but setting METIS_DLL to the .lib file leads to a windows error.
After getting the error described by #XiaojianChen , this is how I solved it (VS Studio 2022). Continuing after the above fixes, to generate a .dll file after opening up the VS solution file, go to the Solution Explorer, right click on the metis project file -> properties.
In General Properties, change the configuration type to Dynamic Library (.dll)
Screenshot of General Properties window
Under Advanced Properties, change the Target File Extension from .lib to .dll
Screenshot of Advanced Properties window
Since we only need the metis.dll file, right click the metis project file in the Solution Explorer and click build. The .dll can be found in ..\build\windows\libmetis\Release.

Python: Warning and after Error using SCons

I am trying to install the openWSN platform on my MAC OS X, to be able to run tests in a simulated (or real) sensors network. For that, is necessary the Python development headers and libraries. In fact, I think the headers are already installed, as I have already downloaded XCode, Command Line Tools, Homebrew, and I already downloaded the Python.
I am using SCons to construct the software application.
The big problem is that when I type this command on the terminal:
$ scons board=python toolchain=gcc oos_openwsn
The processing seems to be going well, when I receive the following warning and error:
File "/Users/stage/Desktop/openwsn/openwsn-fw/SConscript", line 578, in sconscript_scanner
scons: done reading SConscript files.
scons: Building targets ...
Linking (shared) firmware/openos/projects/common/oos_openwsn.so
**ld: warning: directory not found for option '-L/Library/Frameworks/Python.framework/Versions/2.7/libs'**
ld: unknown option: -Bsymbolic-functions
clang: error: linker command failed with exit code 1 (use -v to see invocation)
scons: *** [firmware/openos/projects/common/oos_openwsn.so] Error 1
scons: building terminated because of errors.
The problem to me seems to be in the libs folder, as if the scons could not find this folder, and cannot proceed.
I checked the SCons files for the project https://github.com/openwsn-berkeley/openwsn-fw that you seem to be using. I don't see any hints that the compilation and installation of sources is supported for MacOS. Are you sure that the project supports your OS? If you are, you should consider asking the project's maintainers for help, e.g. via ML or IRC.
The main error in your output above is the "ld: unknown option: -Bsymbolic-functions". Since you specified "toolchain=gcc" in your call, this is what the build expects...but you don't seem to have a proper gcc installed. The clang compiler that is found instead doesn't know the provided command-line option, and stops with an error.

Categories