Can't find VisualStudio linker LINK.EXE - visual-studio

I'm following the openCl documentation provided by Altera to setup an FPGA board and run an example on it. So far I have installed the SDK and followed the instructions but when I get to the step where I have to compile the kernel, I get the following error:
Error: aoc: Can't find VisualStudio linker LINK.EXE.
Either use Visual Studio x64 Command Prompt or run %ALTERAOCLSDKROOT%\init_opencl.bat to setup your environment.
So I tried running the init_opencl.bat script but I get the following message:
AOCL_BOARD_PACKAGE_ROOT path is not set in environment
Setting to default s5_ref board.
If you want to target another board, do
set AOCL_BOARD_PACKAGE_ROOT=board_pkg_dir and re-run this script
VisualStudio's link.exe is not on the path. Guessing its location.
Cannot find VisualStudio installation by looking at the environment.
If VisualStudio is installed, use VisualStudio Command Prompt to set all
required environment variables.
Here is a link to the documentation I am trying to follow:
https://documentation.altera.com/#/00016207-AA$NT00067143
I also tried adding link.exe to the environment variables path but that had no luck. (C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\link.exe).

Related

Can't set up the environment for CUDA compilation

I'm trying to build a project which requires CUDA computing, but I keep encountering an error every time I reach CUDA compilation stage.
The error goes as follows:
nvcc fatal : Could not set up the environment for Microsoft Visual Studio using 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.20.27508/bin/Hostx64/x64/../../../../../../../VC/Auxiliary/Build/vcvars64.bat'
It might be caused by the fact that the environment has already been set up before the nvcc build started since I'm using Visual Studio x64 Native Tools command prompt. When I launch vcvars64.bat from Visual Studio command prompt it throws an error:
%PATH%";C:\Program Files\CMake\bin;C:\Program Files\Git\cmd;C:\opencv\x64\vc15\bin;;C:\Users\grayf\AppData\Local\Microsoft\WindowsApps;C:\Users\grayf\AppData\Local\Programs\Microsoft VS Code\bin;"=="" was unexpected at this time.
When vcvars64.bat is launched from Windows command prompt the error goes away. Seems like nvcc launches vcvars64.bat the second time, but it encounters the error, so it's unable to continue the compliation.
But I can't find a workaround because without setting up the environment by launching vcvars64.bat I'm unable to compile anything at all including a simple test C program and it doesn't even reach the nvcc compilation stage. Anyone had the same issue? I'll be glad to see your answers.
The issue was with my PATH variable in system variables. it contained unnecessary "\" symbols at the end of some paths and an entry that looked like "C:\torch\bin;%PATH%" when it should have been just "C:\torch\bin".
The problem is gone now, nvcc sets up the environment successfuly and vcvars64.bat doesn't throw any errors even when launched from VS Command Prompt.

CMake and Visual Studio with not default installation folder

I am trying to build something using CMake and VS 2012. The problem is I have my VS installation on D:\Pliki programów (x86)\Microsoft Visual Studio 11.0. I have no free space on my C drive.
CMake have problem with finding my VS. I tried to specify VS compiler cl.exe but it was asking for dll in the same folder anyway. I also tried to use specified toolchaing with vcvarsall.bat. But I am not sure if I am doing those things right.
I guess that I need to add VS location to CMake, but how? I tried setting PATH but it did not work.
And searching about that problem is difficult, all search engines think that I want to change installation path for my program that I want to build.
UPDATE
I've added variable_watch(CMAKE_MAKE_PROGRAM).
CMake Debug Log at CMakeLists.txt:3 (project):
Variable "CMAKE_MAKE_PROGRAM" was accessed using UNKNOWN_READ_ACCESS with
value .
CMake Debug Log at CMakeLists.txt:3 (project):
Variable "CMAKE_MAKE_PROGRAM" was accessed using MODIFIED_ACCESS with value
C:/Windows/Microsoft.NET/Framework/v4.0.30319/MSBuild.exe.
The C compiler identification is unknown
The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:3 (project):
No CMAKE_C_COMPILER could be found.
In output file:
LINK : fatal error LNK1104: cannot open file 'MSVCRTD.lib'
Is CMake looking for libs in VS 11 installation folder? The thing is that VS installer put libs in C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib\amd64.
For cases like this (and similar), I keep a VCEnvCmd.bat in my source trees:
call "%VS110COMNTOOLS%\..\..\VC\vcvarsall.bat" amd64 & %*
Executing that .bat without parameters will find and run vcvarsall.bat, setting up the environment for the amd64 target in the current shell (which you could change or parameterize according to your needs, like the version number embedded in that environment variable).
The nice trick is, for those Nightly / Continuous builds, you can use the .bat as a "prefix" for setting up the environment, e.g. in the task manager:
VCEnvCmd.bat ctest -S CTestScript.cmake,Nightly
The advantage is that you use what MSVC already gives you (the VS...COMNTOOLS variable), without having to clutter your environment further with persistent changes to PATH etc.

Setting Up .NET Build Environment with setenv - Two Warnings - Could not find vsvars32.bat Visual C++ Does not appear to be installed

I'm trying to compile some netmf firmware using MSBUILD with Yagarto. I'm doing it on a machine with VS2012 and all the right pre-requisites installed. From a command prompt as administrator, I go to the NetMF Porting Kit folder, where all the source code lives, I call setenv_gcc.cmd 4.6.0 c:\yagarto46
Doing so yields two warnings:
WARNING: Count not find vsvars32.bat
WARNING: VISUAL C++ DOES NOT APPEAR TO BE
INSTALLED ON THIS MACHINE.
When I try the above command from VS2012 Developer Command Prompt as Administrator I get the following ERROR
ERROR: Cannot determine the location of the VS Common Tools folder.
I've done the path modifications in Environment System Variables with no luck.
Thanks!
VS2010 command prompt gives error : Cannot determine the location of the VS Common Tools folder
I modified the vsvars32.bat file in the vs11 and vs10 folders accordingly and the error went away... Now onto eliminating my build errors....

Running vcvars32.bat before compiling in Code::Blocks?

I've installed Visual Studio C++ Express 2012 and want to use it's compiler with Code::Blocks. Starting cl.exe does not work (missing mspdb100.dll) until I run vcvars32.bat, but that does only hold on for the current session in the Command-line. The same applies to compiling with Code::Blocks.
How can I make it run the vcvars32.bat before compiling?
Workaround
That workaround is actually not what I was looking for, but it works, and that is important. Instead of letting Code::Blocks running cl.exe directly, I've set-up a simple batch-script that runs vcvars32.bat before running the actual compiler.
REM File: cl.bat
call vcvars32.bat
call cl.exe %1 %*
In the project properties, you have a section Build events. You can add vcvars32.bat to the pre-build event.
To run the .bat before compiling in Code Blocks(16.01), go to the project build options and its under the "pre/post build steps" tab. This tab only appears in the project settings, not the compiler settings.
However, adding "vcvars32.bat" (or "vcvars64.bat") to the pre build steps didn't fix the error for me.
I found the directory where the library is and added it to the linker search directories. This gave errors about further missing libraries. I added the following paths to my linker settings. These will almost certainly be different for you. I'm installed MSVS 2017 community edition. For some reason known only to Microsoft, the necessary libraries are installed on two different drives.
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\lib
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\lib\x64
D:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\um\x64
D:\Program Files (x86)\Windows Kits\10\Lib\10.0.16299.0\ucrt\x64
Note that the .bat script is no longer necessary if you add these paths by hand.

Using boost 1_47 with Visual C++ Express 2010

I have installed and built (successfully as far as I can tell), boost 1_47_0. I am now trying to get the sample program (the regex one) with their install guide to run and it is giving me the following link error:
LNK2019: unresolved external symbol "private: class boost::basic_regex ....
I suspect that the problem is that the libraries were built as vc100 using b2 and the Platform Toolset is Windows7.1SDK. I cannot change the Platform Toolset to v100 or it generates a kernel32.lib missing error. And I cannot seem to figure out how to build boost so that it is sdk7. I am using Visual C++ Express 2010 and have also tried building from the Windows7.1SDK command line prompt.
Any ideas?
I meet the same issue when I install boost with installer from "BoostPro Computing". And I solve it by compiling boost lib from source code.
Here is the steps:
enter Visual Studio 2010 Express Command Prompt
cd to the unzipped boost dir
bootstrap.bat
.\b2
Done.
Here is my environment:
Win7 64bit
Visual Studio 2010 Express
boost 1_52_0
I build boost using a batch file that calls bjam, and I have not had any problems using the regex library in my projects. I am using VS2010 Pro. Here are the lines from my batch file, the extra library locations might not be important to you, I'm just putting them here for completeness:
call "C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"
SET ZLIB_SOURCE=%LIBS%\zlib
SET ZLIB_INCLUDE=%LIBS%\zlib
SET BZIP2_SOURCE=%LIBS%\bzip2-1.0.5
SET BZIP2_INCLUDE=%LIBS%\bzip2-1.0.5
SET BZIP2_BINARY=libbz2
SET ZLIB_BINARY=zdll
SET EXPAT_INCLUDE=%LIBS%\Expat\Source\lib
SET EXPAT_LIBPATH=%LIBS%\Expat\Bin
SET EXPAT_BIN=%LIBS%\Expat\Bin
bjam.exe --disable-filesystem2 --build-type=complete --user-config=%UTILS%\user-config.jam
Of course the path to your libraries and your user-config.jam will be different, and the only one line in user-config.jam that is really important is:
using msvc : 10.0 ;
After a successful build you will want to add the path to the stage/lib directory to you additional libraries settings for the project so the linker is satisfied. Also since this is an express build you may have to fiddle with the include path to pick up the platform SDK. I run this batch file from the top level Boost directory.

Resources