Use vcpkg on WSL 1 with Visual Studio - visual-studio

I'm adventuring myself into compiling a CMake project using Visual Studio, targeting WSL 1.
Following Microsoft's tutorial to setup a CMake project in Visual Studio and debugging on WSL works fine. Things break when I try to install and use packages using Microsoft's vcpkg package manager after installing vcpkg into a separate Windows directory and integrating it into Visual Studio.
A simple example that fails:
# CMakeLists.txt
cmake_minimum_required(VERSION 3.0)
project(test)
find_package(protobuf CONFIG REQUIRED)
with the following error message:
CMake Error at C:\test\CMakeLists.txt:5 (find_package):
Could not find a package configuration file provided by
"protobuf" with any of the following names
protobufConfig.cmake
protobuf-config.cmake
Add the installation prefix of "unofficial-sqlite3" to CMAKE_PREFIX_PATH or
set "protobuf_DIR" to a directory containing one of the above
files. If "protobuf" provides a separate development package or
SDK, be sure it has been installed.
I'm getting Intellisense to recognize find_package and suggesting to install the package or copying the vcpkg command to clipboard.
The CMake toolchain file is pointing to the "C:/vcpkg/scripts/buildsystems/vcpkg.cmake" file in the WSL-GCC-Debug configuration settings. Installing vcpkg on the Linux system and setting the CMake toolchain file to the corresponding path creates the exact same error output.
Running the "vcpkg install protobuf:x64-linux" command in the terminal creates the following output:
Computing installation plan...
The following packages will be built and installed:
protobuf[core]:x64-linux -> 3.14.0#1
Detecting compiler hash for triplet x64-linux...
Error: while detecting compiler information:
The log content at C:\vcpkg\buildtrees\detect_compiler\stdout-x64-linux.log is:
-- Configuring x64-linux
CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:108 (message):
Command failed: ninja -v
Working Directory: C:/vcpkg/buildtrees/detect_compiler/x64-linux-rel/vcpkg-parallel-configure
Error code: 1
See logs for more information:
C:\vcpkg\buildtrees\detect_compiler\config-x64-linux-out.log
Call Stack (most recent call first):
scripts/cmake/vcpkg_configure_cmake.cmake:319 (vcpkg_execute_required_process)
scripts/detect_compiler/portfile.cmake:18 (vcpkg_configure_cmake)
scripts/ports.cmake:128 (include)
Error: vcpkg was unable to detect the active compiler's information. See above for the CMake failure output.
This is not a surprise as I don't expect it to be able to build packages targeting Linux on my Windows machine.
I'm new to cross-platform development and I find documentation on vcpkg + WSL rather sparse. Am I right in assuming that the packages should be installed by vcpkg running on the Linux system? Or do I need to have CMake setup on Windows to make vcpkg work on the Windows side?
Setup:
Windows 10 Build 19041
Visual Studio 2019 (16.8.5) with Visual C++ for Linux Development
Ubuntu 20.04 LTS as WSL
vcpkg commit f226416d2

It seems that I was a bit off track.
vcpkg installed on the Windows machine is accessible on the Linux system the same way as the actual CMake project is accessible. Setting the "CMAKE_TOOLCHAIN_FILE" variable to the absolute "C:/vcpkg/scripts/buildsystems/vcpkg.cmake" path gets translated into "/mnt/c/vcpkg/scripts/buildsystems/vcpkg.cmake".
The missing step was to run the ./bootstrap-vcpkg.sh script on the Linux system to make sure packages can be installed by vcpkg on the Linux system.
I also learned that packages have to be installed manually by running the vcpkg install command since there is no "build in" way to do this via CMake.

Related

How to install ZeroMQ on Windows 10?

I need to install ZeroMQ (libzmq) on windows 10 which is running on a VirtualBox. On their official website there are zip files for Visual Studio but on their github they mentioned that Windows10 is not supported.
I downloaded the zip file of "Visual Studio 15 2017 x64" and also installed cygwin and cmake but when I try to install it via cmake I get: The source directory does not appear to contain CMakeList.txt. This is true but there is a zmq.h inside that directory which I thought I should install via cmake. I also tried make exactly how I do it in linux with C files but that one also didn't work.
I have to mention that I don't want to use the ZMQ in Visual Studio. I need to connect a python program running in the host linux to Metatrader via ZMQ and the method that I am following (https://github.com/darwinex/DarwinexLabs/tree/master/tools/dwx_zeromq_connector/v2.0.1#installation) needs libzmq to be installed.
Can someone please help me with installing ZMQ on Windows10 either via cmake or Visual Studio?

Installing and using IPopt with Cygwin - or even better alternative?

I am new to the optimization field. Did some projects with fmincon though, and am now looking for an alternative usable in OpenSource, preferrably somehow usable in Python. Therefore I found IPopt. Any other suggestions which are equally good as fmincon?
I tried to install IPopt by compiling it. And I must say, it seems like a mess. I tried all version and ended up with the most promising one "Installation with Cygwin using the MSVC++ compiler " from the Manual. Therefore I have to install CYGwin and change the make.exe. Done.
Add the cl.exe from Visual Studio (Visual Studio 1 in my case) to the Apth environment. Done.
add "call "call "C:\Program Files (x86)\Microsoft Visual Studio 14\VC\vcvarsall.bat" " to the cygwin.bat. Done.
Now two things. When I do "./configure" with the downloaded IPopt sources I get: "configure: error: /bin/sh './configure' failed for Ipopt"
Also like suggested in the manual calling "./configure -enable-doscompile=msvc" to tell cygwin to use the windows compiler gives me "configure: error: --enable-doscompile=mscv not supported anymore."
So. Basically I am not able to install Ipopt. Using it seem like impossible, as all other methods to build it also failed on my Win10 64bit. It seems that the manual is outdated or I am not finding the corect way to do it, hope some of u guys probably can help. Compiling is something rather new and I am happy to learn.
Tahnks in advance.
Ensure that you have the following packages installed in Cygwin.
Devel: gcc
Devel: gfortran
Devel: pkg-config
Devel: subversion
Archive: unzip
Utils: patch
Web: wget
Utils: dos2unix
Assuming you are building for 64-bit, add path to cl.exe in Cygwin.bat (located in root directory of location where Cygwin was installed) so that msvc can be used from Cygwin –
call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64\vcvars64.bat" (vcvarsall needs you to specify architecture version)
You will need the Intel Fortran Compiler. It comes along with Parallel Studio. Free for students, faculty, open source contributors.
In .bash_profile (located in pathto/cygwin64/home/username/) add this line so that ifort recognizes msvc linker (path given above should be to link.exe of msvc) –
alias ifort='ifort -Qlocation,link,"C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin/amd64"'
Intel Fortran gets integrated to a visual studio shell. Run this shell. Execute cygwin.bat from this shell. Check the version of link (link --version). If it is not the microsoft linker, you may have to remove the Cygwin link.exe file from Cygwin folder.
Note that any other bash terminals (e.g. Git Bash) might interfere. You will come to know only while running the configure script. It tries to access packages from those bash terminals. You may have to place them elsewhere temporarily, so cygwin does not find them.
I understand you have read the manual, so you must have downloaded the required third-party tools for Ipopt (asl, lapck, blas and one linear solver) .
You can now run (in Ipopt root folder):
mkdir build
cd build
../configure --enable-msvc=MD
make
make install

CMake does not find Windows SDK 8.1

I am trying to download a C program called fluidsynth (https://sourceforge.net/p/fluidsynth) so that I can later install python bindings and use it in some code.
I installed CMake and Visual Studio. From the VS command line (as an administrator) I gave the command cmake c:\path\to\fluidsynth. I got a few errors:
In the command line, I got No CMAKE_C_COMPILER could be found.
In the CMake error log it says Build FAILED Then:
error MSB8036: The Windows SDK version 8.1 was not found.
Install the required version of Windows SDK or change the
SDK version in the project property pages or by right-clicking
the solution and selecting "Retarget solution".
[C:\Users\user\Desktop\fluidsynth-1.1.6\CMakeFiles\3.4.3\CompilerIdC\CompilerIdC.vcxproj]
This error persists even after upgrading my Windows SDK.
1.- Visual Basic?? CMake doesn't have native support for VB.
2.- If you are going to use CMake, you must be ensure that Win SDK is propertly registered its paths.
3.- Once is done, you only need to run, from the directory you extracted the files, the following command: cmake . if you still get errors, then something is not correctly registered nor installed. That wouldn't be cmake fault.

LNK1104: cannot open file 'boost_thread-vc100-mt-gd-1_55.lib'

I'm facing difficulty to build qpid cpp solution on windows xp
I have installed Boost 1.55.0, Python 2.7, Ruby 2.0.0 and CMake 2.8
Then I have added Environment variable paths for Python, Ruby and CMake, and then Boost variables are
set as followed
BOOST_ROOT C:\Boost
BOOST_LIBRARYDIR C:\Boost\lib
BOOST_INCLUDEDIR C:\Boost\include
I build Boost with following commands from command prompt
bootstrap
.\b2
I have downloaded qpid-cpp-0.26, Then I build qpid with following command from command prompt
cmake -i -G "Visual Studio 10"
Executing the above command have generated solution file for qpid
Then I opened qpid from solution file to build in Visual Studio 2010, when I tried to build the solution it
gave me following error in qpidCommon
cannot open file 'boost_thread-vc100-mt-gd-1_55.lib'
After bit of searching, I came up with solutions like
Adding “BOOST_ALL_DYN_LINK” in Preprocessor definations
Adding Library path in Linker – General - Additional Library Directories
but above solutions didn't work for me
Any Ideas?
I got a workaround, from command prompt run following command
bjam --build-type=complete
Add lib path in Project Properties - Configuration Properties - VC++ Directories
- Library Directories - here add library path(one which is in stage - lib)
This worked for me.

Linking errors with boost, VS2010, and CMake

I have searched high and low for this answer. I have tried suggestions to similar problems posted on Stack and other sites. My toolchain consists of an x64 machine with windows 7, visual studio 2010, opencv 2.4, qt 4.8, and boost. I configure all of my projects using CMake, which finds all of these libraries and includes and creates my visual studio project. I have compiled two versions of boost, a 32-bit version build in the command line and placed in \boost\boost_1_47_0\lib\win32, and a 64-bit compiled in the Windows SDK v7.1 64-bit compiler and stored in \boost\boost_1_47_0\lib\x64. Everything in the project compiles fine with the exception of boost. I get a compiler error:
fatal error LNK1104: cannot open file 'libboost_filesystem-vc100-mt-1_47.lib'
As a reminder, CMake is handling all of my linking and it properly locates this lib and adds it to the visual studio project. I can verify this by looking at Properties->Linker->Command Line. Here, in addition to files representing other libraries, it has listed:
"C:\Tools\boost\boost_1_47_0\lib\x64\boost_filesystem-vc100-mt-1_47.lib"
"C:\Tools\boost\boost_1_47_0\lib\x64\boost_program_options-vc100-mt-1_47.lib"
"C:\Tools\boost\boost_1_47_0\lib\x64\boost_date_time-vc100-mt-1_47.lib"
"C:\Tools\boost\boost_1_47_0\lib\x64\boost_thread-vc100-mt-1_47.lib"
I can suppress this error by manually adding my boost\boost_1_47_0\lib\x64 directory to Properties->Linker->General->Additional Library Dependencies. This compiles without error. However, when I go to run the application, I am met with a system error that tells me:
The program can't start because boost_filesystem-vc100-mt-1_47.dll is missing from your computer. Try reinstalling the program to fix this problem.
In this /x64 directory I have:
boost_filesystem-vc100-mt-1_47.dll
boost_filesystem-vc100-mt-1_47.lib
libboost_filesystem-vc-100-mt-1_47.dll
Any insight would be incredibly appreciated. Thanks!
To solve the runtime error:
Add the location of the dll(s) to the PATH environment variable.
For example on my machine:
set PATH=%PATH%;c:\users\chris\boost_regex-vc140.1.63.0.0\lib\native\address-model-32\lib
or copy the dll(s) to a directory already in the PATH
See here: https://msdn.microsoft.com/en-us/library/7d83bc18.aspx?f=255&MSPPError=-2147217396

Resources