How to link libraries to OpenCL.lib when pip installing a python package, using developer command prompt? - linker

I am on a Dell Inspiron laptop with an AMD graphics card and am aiming to install a python package named pyviennacl:
https://github.com/viennacl/pyviennacl-dev
I am using Developer Command Prompt for VS 2019.
When I run:
pip install pyviennacl
The following error message is returned:
LINK : fatal error LNK1181: cannot open input file 'OpenCL.lib'
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.20.27508\bin\HostX86\x86\link.exe' failed with exit status 1181
Now, I really have no idea how to proceed. I can see what the error is but cannot find any help.
I've tried to install various Intel/AMD OpenCL packages to remedy this issue, however, to be completely honest, I do not know what I'm doing.

did you had a look to this post ?
Also, I resolved the same issue by defining the LIB environment variable to the directory containing the "OpenCL.lib" file (by default at C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\lib\x64 for NVIDIA graphic card. It can be different for AMD or Intel GPU).
In summary, PATH is where your binary will look for .dll files at runtime. To tell link.exe where to look for your .lib libraries you need to configure the LIB environment variable instead. (source here)

Related

compile putty 0.78 for windows

in the new version of putty there is no Makefile.vc or project file for visual studio. How can I compile putty under visual studio 2019? can someone help me?
link to zipped source
I tried to open the windows folder in visual studio with the following error:
Severity Code Description Project File Line Suppression State
Error CMake Error at C:\Usersuser\Downloads\Compressed\putty-src\windows\CMakeLists.txt:3 (add_sources_from_current_dir):
Unknown CMake command "add_sources_from_current_dir". C:\Users\user\Downloads\Compressed\putty-src\windows\CMakeLists.txt 3
You don't need to open Visual Studio or any IDE to compile the executables.
Download cmake and make sure Visual C compiler is installed.
Unzip the .zip file, open a command prompt where the readme and CMakeLists.txt reside
Then, as the readme states:
run these commands in the source directory:
cmake .
cmake --build .
In the Debug directory, you'll find a lot of .exe files.
Then, to install in the simplest way on Linux or Mac:
cmake --build . --target install
I didn't need that part. I suppose that it copies the executables & other files somewhere in the path.
Problem with creating a distro using Microsoft compiler is that the executables then require a lot of Microsoft runtime DLLs. For instance if you deploy the executables on other machines it may not work.
An alternative is to use gcc and make to build the executables.
First:
install a recent gcc for windows
install make
Installing a recent MinGW distribution should do it. Personally I used another gcc distribution so I had to grab make too.
Now, I followed Setting default compiler in CMake, the key part being to enable mingw makefiles: -G "MinGW Makefiles", else cmake ignores your compiler requirements and keeps on using Microsoft compiler.
cmake -DCMAKE_MAKE_PROGRAM=/path/to/make/make.exe -DCMAKE_C_COMPILER=/path/to/gcc/gcc.exe -G "MinGW Makefiles" .
Note that specifying full paths require that / are used. Backslashes conflict with escaping in cmake/make files.
Then
cmake --build .

VS2017 Nuget pthread LNK1120 unresolved

I heard that Nuget builds project easier without any configuration.
So, I am trying to add pthreads in my project from Nuget
(Actually I am using windows 10 x64 Visual studio 2017, C language, and my friends use linux OS)
I just search pthreads in Nuget package, click "install" button
But, my project compiles well but fatal error LNK1120 called.
Is there any more configuration after install pthreads from nuget?
The reason why I ask this simple question in stackoverflow is that, there is no more steps in Microsoft official guides.
Is there any more configuration after install pthreads from nuget?
Using Nuget format to install pthread into C++ projects is quite simple and will not manually configure include Directories and additional Dependencies address any more.
But pthread nuget package in VS has a drawback that it does not fully inherit pthread class library. It lost a file called pthreadvc2.lib. You can try my following suggestions to configure it without any settings in project properties.
Solution
1) download pthread-w32-2-9-1-release.zip from this link.
2) unpack this file and then copy pthreadVC2.lib from the file(pthreads-w32-2-9-1-release\Pre-built.2\lib\x86 or x64) into
C:\Program Files (x86)\Microsoft Visual Studio\2017\xxxxx\VC\Tools\MSVC\xxxx.xx.xxxx\lib\x86 or x64.
Note that you should copy the related lib into the related folder, x86 pthreadVC2.lib into x86 folder, x64 pthreadVC2.lib into x64 folder.
3) then add this into your cpp file:
#pragma comment(lib,"pthreadVC2.lib")
Then it will work as expected without any errors.

Cannot install vtune amplifier command-line interface

I try to install vtune command line interface on a target machine following the instrument https://software.intel.com/en-us/vtune-amplifier-install-guide-windows-installing-command-line-collectors. But get the error popup like the screenshot below. Any idea of it?
Met the same error for installing CLI for VTune Amplifier 2019 Update 4.
After some digging with unpacking msi package and dependency walker discovered that msi custom action dll imports functions from amplxe_sampling_utils_3.9.dll. Also this file relies on MS Visual C++ 2013 runtime.
For me it helped taking this dll from the VTune full installation (by default it is located at
C:\Program Files (x86)\IntelSWTools\VTune Amplifier 2019\bin32\amplxe_sampling_utils_3.9.dll
and placing it somewhere under system %PATH% for the installation purposes. I have not found better place than C:\Windows\System32 on a 32-bit target.
After the successful installation this dll can be removed from System32 as it it also installed with command line interface into target directory.

I cannot find python35_d.lib

I have downloaded the 3.5 version of python on my windows 7 home premium computer with version 6.1 software. I wish to use a C main program with python library extensions. I have aded the path to the include folder and the library folder to the dev studio c-compiler. I am testing with the supplied test program that prints out the time but I get a compile error. While it can find Python.h, it can't find python35_d.lib. I can't either. Is it missing from the download or is this another name for a one of the libraries in the download? Thanks
Maybe a little too late, but I found a work around for the missing 'python3x_d.lib' : When installing the python with pythoninstaller.exe, choose the advanced setup options in the first command window of the installation wizard, there choose the option "download debug binaries", then the file python3x_d.lib is automatically installed.
I faced this error when trying to build opencv with python bindings

Windows: How to build X264.lib instead of .dll

I downloaded the X264 source and installed mingw.
Step 1:
Executed this in the MINGW bash:
./configure --disable-cli --enable-shared --enable-win32thread -
-extra-ldflags=-Wl,--output-def=libx264.def
and then 'make'
Step 2:
Renamed the libx264-142.dll to libx264.dll and Opened up VS2012 Command Prompt and executed this:
LIB /DEF:libx264.def
which gave me libx264.lib and object libx264.exp
Step 3:
Included the lib file in a VS2012 project which uses the X264 API.
Problem:
When I start the project I get the following error message:
"The program can't start because libx264.dll is missing from your computer"
Question:
Why is it looking for the dll when I'm linking the static library in?
How do I resolve this? I would like to build a static X264 library which I can link in with my project.
EDIT:
I just had to put the dll in the same directory as the project executable.
However - My question still stands: How do I build a static x264 library? So I don't need the dll?
After the latest update of x264 you can build static library usable by MSVS project. For such library compilation you will need:
MSYS and MSVS 2013 Update 2 (express version [for Windows Desktop] would also work if you install Update 2)
run "VS2013 x86 Native Tools Command Prompt" or "VS2013 x64 Native Tools Command Prompt" depending what version (32 or 64-bit) you want to build
change dir to x264 path and run MSYS shell (sh)
from shell run "CC=cl ./configure --disable-cli --enable-static" for x264 configuring
run "make" which should build libx264.lib usable from MSVS
P.S. MSVS builds would be a little bit slower than one build by MinGW
Matthew Oliver has a GIT repository of a patched x264 source tree (https://github.com/ShiftMediaProject/x264) that compiles natively in VS2013 update 2 and later. It requires installing a YASM version for VS.
It worked pretty much straight out of the box for me, though I did have to change the VSYASM parameter "-f Win32" to "-f win32" for a 32bit build
Take a look here: http://siliconandlithium.blogspot.no/2014/03/building-x264-on-windows-with-visual.html
Static lib is not possible in windows as per my knowledge.

Resources