How to compile code with visual studio using makefile - c++

I have just downloaded a open source project which is said to be compiled using visual studio c++. It contains 3 makeFiles (makeFile, makeFile(1) and makeFile(2) )
I always open programs in VS using the .sln files and now I dont know what to do with this makeFile.
can anyone instruct me how to deal with it please.
regards

You may try NMake. See NMake Reference and Stackoverflow post.
NMake is included with Visual Studio. You may try with NMake shipped with the edition of Visual Studio you may want to use.

If you are only familiar with Visual Studio projects and solutions, dealing with makefiles can be a challenge. The following link will give you a good introduction to makefiles from a Visual studio perspective.
An introduction to Makefiles for Visual Studio developers
Translating Linux makefiles to Visual Studio solution will be a manual effort.
NMake looks promising. However, the following link takes a simple Makefile and explains some fundamental issues that one may encounter.
Makefiles in Windows

VS2017 and cross-platform dev with make linux binaries
If you're working on windows 10, you can make make work and compile linux binaries:
have lxss installed, and gdb server, ssh server installed:
sudo apt update &&
sudo apt install -y build-essential gdbserver openssh-server
make sure you can connect through ssh to your local machine:
sudo vi /etc/ssh/sshd_config &&
sudo service ssh start
make sure you have linux development with c++ packages installed (VS2017 install)
make sure you configured your connexion to lsxx through ssh in VS/tools/options/connection manager ("connection" in search).
make sure to have a linux project (new project/other languages/vc++/crossplatform/linux)
yet, add you make commands in project/properties.

I've just run into the same problem and for me the solution:
open "VS2012 Native Command Prompt" the name varies over different versions of MSVS. then simply type 'nmake makefile.vc'. nmake is the command, makefile.vc is your own makefile in your local folder. and it is done (if no further errors occur)

Related

Visual Studio 2022 intellisense cannot find Openssl (ARM64 - Makefile project - SSH - Ubuntu)

(Only to be clear, this question is regarding Intellisense only)
Here is my developing scenario:
Visual Studio 2022 (Enterprise edition, 64 bits)
C++ project (Run by SSH to a Raspberry Pi 4 - ARM64 using Ubuntu 20.04 server)
Project is a Makefile project (not CMake).
The code compiles and runs in the Raspberry Pi (via SSH), but the problem is with Visual Studio Intellisense that cannot find the OpenSSL files.
I ran the tutorial here (https://kontext.tech/article/594/microsoft-vcpkg-c-library-manager) and installed vcpkg
vcpkg install openssl:arm64-windows
and ran the instruction to integrate to Visual Studio
vcpkg integrate install
and everything seems to be installed correctly,
PS C:\vcpkg> .\vcpkg.exe integrate install
Applied user-wide integration for this vcpkg root.
CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake"All MSBuild C++ projects can now #include any installed libraries. Linking will be handled automatically. Installing new libraries will make them instantly available.
but as this is a Makefile project (and not CMake), it still seems to have the problem with Intellisense.
Could you please help me to determine how to make Visual Studio to finally find the OpenSSL files?
Thank you.
I made progress in solving the problem in an unexpected way. As the project built successfully in the remote machine, I ignored the Intellisense problems for a while. But one day I connected to another machine and there were no problems! Intellisense found all the files.
The machine with problems had Ubuntu 20.04 and the other one Raspbian OS. The difference was that I installed OpenSSL using apt in Ubuntu,
sudo apt -y install libssl-dev
but I compiled the OpenSSL source code in the Raspbian OS. (https://www.linuxtuto.net/blog/how-to-install-OpenSSL-3-on-Ubuntu-20-04) and (https://nextgentips.com/2022/03/23/how-to-install-openssl-3-on-ubuntu-20-04/)
So I knew the problem was due to the headers.
I compiled OpenSSL from source in Ubuntu, and it didn't work. But I had a third machine with Ubuntu 22.04 and did the same, and it worked. So I knew the exact problem: Visual Studio didn't bring the headers after an initial SSH connection was made.
Solution:
[IMPORTANT] Download OpenSSL source code using the tutorials I linked above, and compile it in your Linux machine (mine was an upgrade from 1.1.1f to 3.0.5).
Go to C:\Users[Your user]\AppData\Local\Microsoft\Linux
Depending on your Visual Studio version (mine is 2022), you will have a folder structure. Search around and you will find an XML file with your connection information (in my case, it was in User Data\3.0\store.xml)
Open the XML. You will have a list of all the SSH connections that version of Visual Studio has made to remote machines.
Check in the HeaderCache\1.0 folder. You will find folders with random numbers, and they match the connections from the XML. Identify the problematic connection.
Inside Visual Studio, delete that SSH connection. (It should also disappear from the XML, but it DOES NOT automatically delete the folder, so this is why the problem happened in the first place).
Delete the associated folder inside the HeaderCache\1.0 you found in step 4.
Recreate the SSH connection inside Visual Studio. It should appear in the XML and a new folder must be created inside HeaderCache\1.0.
Check inside the new folder. Go to the subfolder usr\include. There should be an OpenSSL folder.
Change the configuration of your solution in Visual Studio to use the new SSH connection.
Problem solved!
Edit: Sometimes you must delete your Visual Studio Configuration (inside the Configuration manager). After you delete the problematic configuration, in some cases Visual Studio still shows it inside the project properties. If that is your case, you must:
Open the Package Manager Console (Tools -> Nuget Package Manager -> Package Manager Console)
Run the command:
Get-Project -All | Foreach { $_.ConfigurationMAnager.DeleteConfigurationRow("Name of your configuration with quotes") }
And that's it!

error: command 'C:\\ Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.14.26428\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2

Hi so I was trying to pip install python-ldap using my git bash but at first it told me that i don't have cl.exe so i downloaded the visual studio C++ pack now it's showing this error
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.14.26428\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
I never coded with C++ so I'm not sure what the error is. I downloaded the CLI tools for C++ too and I don't think it's because the cl.exe isn't in the path since it found it. Any insights ??
Install Visual C++ 2015 Build Tools from https://go.microsoft.com/fwlink/?LinkId=691126 with default selection.
I know this question was asked years ago, but for future users, I thought of providing an answer for this question. Today I've faced the same problem with the "Microsoft visual studio 2019 build tool."
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30037\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
I have come across this issue while trying to install the dependency through anaconda3 cmd in windows OS.
pip install sparse_dot_topn
I have tried different methods suggest in different portals and couldn't resolve this for hours. At the same time, I've ended up installing unnecessary components of the visual studio build tool as well. Finally, I found the problem is associated with the setup tool library, and the problem can be solved through force upgrade to the setup tool package
python -m pip install -U pip setuptools
There doesn't seem to be a valid solution for this error but one workaround is to install the windows binary package from https://www.lfd.uci.edu/~gohlke/pythonlibs/#python-ldap
In my case, I had to copy or link (using link shell extension) the x64 version of "C Connector" to the x86 folder.
If you can't find the x64 C connector...
Download mysql-installer-web-community-8.0.12.0.msi from their website:
https://dev.mysql.com/downloads/installer/
Run the Installer, and click the Add button on the right, then locate the Connector C 6.1 x64
The C++ Connector has C compatible header files, but hard-linking to it does not work, as explained here: https://dev.mysql.com/downloads/connector/c/
You cannot install the x86 version alongside the x64 version. The installer does not permit this.
Otherwise, Hard-Link the x64 version
Install link shell extension.
Navigate to "C:\Program Files\MySQL\" then right click on "MySQL Connector C 6.1" and click Pick Link Source
Navigate to "C:\Program Files (x86)\MySQL\" and Drop Link As... > Junction
A Junction is a duplicate reference in the file system to a folder. Creating a second junction reclassifies the original folder a junction as well, but they are both authentic references to the same folder, and so, unlike symbolic links, they will work with scripts, because they are real, and are implemented on the file system level.
Then, if the connector you have installed is a different version number and you want to try to force it to work with a non-compatible script, rename it to match the folder mentioned in the error message. For example...
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.15.26726
\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,3,13,'final',0) -D__version__=1.3.13 "-I C:\Program Files (x86)\MySQL\MySQL Connector C 6.1 \include" "-Ic:\program files\python37\include" "-Ic:\program files\python37\include" "-IC:\Program Files (x86)\Microsoft Visu...
Crappy pip code failing to pass variables from the system environment :(
I had a similar issue.
I had installed a 32-bit python interpreter from https://www.python.org/downloads/windows/ mistakenly in my 64-bit windows machine.
Then I downloaded the correct 64-bit interpreter setup and installed it. Then I pointed the Pycharm interpreter path to it.
Then my issue was solved. I hope this will help you...
When I was perusing the internet to find the solution I ran into an adjacent problem:
Python was not found, which I solved by (assuming your python works and is added to PATH) going to Settings > Manage App Execution Aliases and turning off "python". They try installing your package again
Install the C++ build tools from here: https://my.visualstudio.com/Downloads
Search for 'build tools' and download the latest VS build tools installer. Install the C++ build tools (currently it's called "Desktop Development with C++") with the defaults.
What worked for me in the same situation: Except installing VS Build Tools, install whole Visual Studio. Python libs often require C/C++ compiler
I had the same error; although when installing lux-api
What worked for me was downgrading the default python version 3.10 -> 3.9
(ref)
p.s. the error that I had was the following
error: command ...\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX86\\x64\\cl.exe failed with exit code 2
----------------------------------------
ERROR: Failed building wheel for pandas
Failed to build pandas
ERROR: Could not build wheels for pandas, which is required to install pyproject.toml-based projects
I had the similar issue. I was trying to build pandas from source. I figured out that my build tools were not compatible with the source. I had MSVC v142 installed. So I installed the below components and this worked for me:
Windows 10 SDK (10.0.17763.0)
MSVC v141 - VS 2017 C++x64/x86 build tools
These tools can also be installed from cmd, just install visual studio 2019 build tools exe and then run this command in cmd as admin:
vs_buildtools.exe --quiet --wait --norestart --nocache ^
--installPath C:\BuildTools ^
--add "Microsoft.VisualStudio.Workload.VCTools;includeRecommended" ^
--add Microsoft.VisualStudio.Component.VC.v141 ^
--add Microsoft.VisualStudio.Component.VC.v141.x86.x64 ^
--add Microsoft.VisualStudio.Component.Windows10SDK.17763
I also had to install additional tools to make it work correctly:
C++/CLI Support for v141 build tools (14.16)
Once the tools were installed correctly then I had to initialize x64 environment with new installed build tools:
"C:\BuildTools\VC\Auxiliary\Build\vcvars64.bat" -vcvars_ver=14.16 10.0.17763.0
After that I restarted my computer and build pandas again and it was build successfully.

Visual studio build c++ project with Makefile using mingw

I have a project written in C/C++ (libbpg-0.9.7 downloaded from bellard.org). I want to build this library.
I created a Visual Studio project Visual C++ -> Makefile project (never done before). So there was many options and I don't know what to do. I read the README
from libbpg :
Only cross-compilation from Linux is supported.
The following packages need to be installed: mingw64-gcc mingw64-libpng mingw64-libjpeg-turbo mingw64-SDL mingw64-SDL_image yasm
I installed mingw64-gcc by following this tutorial but I did not find how to install other packages (for included libraries).
But normally with that, I should be able to compile. I defined the build command line to mingw32-make but there are errors and I do not know if they are due to packets or something else.
So my question is : How to install packages and how to be sure that I use mingw64-gcc for compilation ?

How to cmake, make and compile C++14 on Windows

I'm trying to compile, on Windows 10, a C++ project that is using C++14 features such as std::make_unique<> and things like that.
I'd like to be able to compile easily in command line, using CMake and make and then be able to run my program from any command line or just by clicking it's executable.
Compiling using Cygwin, even if it's indeed working (I used this tutorial), is not an option since the resulting executable won't be usable outside of the Cygwin environment due to missing DLLs.
I've read about MinGW-w64, but it seems like the latest available version for Windows corresponds to GCC 4.8.3.
Same goes for the MinGW installer mingw-get-setup.exe available here, wich only allows me to install the 4.8.1-4 version.
So I'd like to have a procedure on how to compile a C++14 project using CMake, and that will allow me to launch the executable in the default Windows environment.
Thanks.
Update : Chris Drew commented that I could use the latest Visual Studio version to build my project using the Visual C++ compiler instead of GCC. I detailed the workflow in my answer, but I'm still looking for a "GNU-style" way to compile it.
"GNU-style" : Use the link provided in Tive's comment to install a working GCC 5.1 environment and use the normal cmake . -G"Unix Makefiles" && make commands.
See this answer for more details on both solutions.
Using Visual Studio compiler
Following Chris Drew comment, here's what I did in order to compile using CMake to generate a Visual Studio 2015 solution and compile this solution in command line.
Note that this is not using the GNU toolchain as we won't be using gcc / make but the Visual C++ Compiler.
Creating and moving to a build subdirectory (it's recommended since it will generate a lot of files, instead of just a standard Makefile) :
mkdir build && cd build
Generating the Visual Studio 2015 solution :
cmake . -G"Visual Studio 14 2015"
This will generate several project files including YourProjectName.sln that we will use to build the project using the following command :
msbuild YourProjectName.sln
Note that msbuild was not in my PATH, so I had to provide the complete path to the executable wich was, in my case, C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe.
Using an updated MinGW installer
Tive provided a link to a bundled installer that will automatically install GCC 5.1 on your system, this way you can use the normal GNU toolchain by generating an Unix Makefile, and using the make command.
Note that you will need to edit your PATH manually as the installer is not doing it for you.

Build Qt 5.2.1 with Visual Studio 2010 for Win 7 64Bit

I'd like to build Qt 5.2.1 for Visual Studio on my Windows 7 64Bit machine. I know, there are various similar questions, but none which I have found really give me the feeling that I definately know how to proceed.
First, I tried to follow the instructions in How to build Qt for Visual Studio 2010, but I noticed that things for Qt 5 have changed a bit. E.g., there is no Qt/bin directory that you could add to the path variable, since now there are many different bin directories.
I then found http://qt-project.org/doc/qt-5/windows-building.html but here I am not sure if they use Visual Studio 10 and I do not understand the instructions to get the environment variables right.
This link http://qt-project.org/wiki/Building-Qt-5-from-Git is also interesting, as it gives various hints, but it uses git and I would like to build from the opensource zip file.
So, what are the steps I need to take precisely? I will write my version here, and you can extend/correct it.
Install Perl and Python and add them to system path
Download http://download.qt-project.org/official_releases/qt/5.2/5.2.1/single/qt-everywhere-opensource-src-5.2.1.zip
Unzip the file from 1. to C:\Qt5.2.1
Install the standalone Windows SDK (http://msdn.microsoft.com/en-US/windows/apps/br229516)
Set up the Qt Environment variables. How?!! Please clarify Step 3 of http://qt-project.org/doc/qt-5/windows-building.html
Open the Visual Studio Command Prompt 2010. Run there
configure -MP -opensource -confirm-license -debug-and-release -no-webkit
Type "nmake" in the Visual Studio Command Prompt 2010.
http://qt-project.org/doc/qt-5/windows-building.html mentions "If an installation prefix was given, type jom install, nmake install or mingw32-make install" - what is an installation prefix??
Then, I believe Qt should be installed in C:\Qt5.2.1; How can I check if the installation was successfull? Is it possible, to have Qt in my list of installed applications using this approach?
I'd be happy if you could correct/comment my approach, since some steps are not entirely clear to me and I have mixed different tutorials.
Thanks!