How to make a c++ project from command prompt? [closed] - c++

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
Note that this is referred to make a project from command prompt, not build or run it, by "make", i mean, creating a .vcxproj file like Visual Studio does.
I am unable to use Visual Studio for now, this is why i'm asking to make a project through cmd, i tried gcc, but it doesn't generate these project stuff.

The vcxproj format provides information the MSBuild tool to control the build process. It's an XML file that is automatically created by Visual Studio, but its possible to make it manually by writing the XML yourself, and then specifying the file when invoking MSBuild from the cmd prompt.
See this walkthrough in the MS docs, and this reference to the vcxproj format if you want it to work when you regain access to VS.
Alternatively, if you're not absolutely required to use Visual Studio and the Visual C++ ecosystem, then it might be worth exploring other build systems as suggested in other answers/comments.

GCC is just a compiler, rather than a full IDE like Visual Studio. It takes source code (and some binary libraries), and then outputs compiled executables or object files.
You can use a build system like CMake or Meson, which can make the building process easier for you and those who clone your code, and can even be integrated into Visual Studio. You can actually use CMake to convert projects into Visual Studio format.

Related

C++ Setup For VS Code [duplicate]

This question already has answers here:
How do I set up Visual Studio Code to compile C++ code?
(14 answers)
Closed 10 months ago.
So my teacher is wants the class to install C++, and I don't know how to do it. Please help me set it up in Visual Studio Code because it's the IDE I'm most familiar with. Please explain it in the simplest way possible.
If you are going to edit and execute on Windows, you have to install either Visual Studio regardless or g++ under MinGW. These instructions are very detailed:
https://code.visualstudio.com/docs/languages/cpp
To configure VSCode with MS compiler:
https://code.visualstudio.com/docs/cpp/config-msvc
To configure VSCode with gcc on Windows:
https://code.visualstudio.com/docs/cpp/config-mingw
Another alternative that I recommend is to use Windows WSL which is like a Linux inside Windows.
https://code.visualstudio.com/docs/cpp/config-wsl
Then install the C++ extensions for VSCode.
Then I recommend you install cmake for Windows. Although the tutorials will teach you how to build a single file, you will need more for large projects.
https://cmake.org/install/
Create a CMakeLists.txt and then use the cmake-gui to create the Visual Studio project files. All this is outside Visual Studio Code.
To build from inside VSCode I found it particularly cumbersome. I'd rather Alt-Tab and build the project manually by either calling 'make' or building inside Visual Studio. But it's your preference.
But if you are editing on Windows and running on Windows, I'd strongly suggest to run inside Visual Studio itself. Not only you will have way more support for your questions but also the Visual Studio debugger is arguably the best in the market.

How do I build a program after cloning a repository from github? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I want to take this program: https://github.com/baskiton/Img2STL, open it in visual studio and make an executable. I realize I could get it straight from the release, but I want to learn how to edit it and build myself. When I clone it into visual studio, the folders all have blue padlocks next to them and the build function is grayed out.
Thanks!
This repo has a CMakeLists.txt file in its root, hence this project can be generated and built via CMake.
Generally you download and install CMake and then you have 2 options:
Use GUI.
Use your console.
For Windows you can use powershell:
git clone https://github.com/baskiton/Img2STL
cd Img2STL
mdkir build
cd build
cmake ../
CMake uses a Generator to configure your projects. It can be defaulted to use your installed Visual Studio.
Or else, you can use Ninja and Visual Studio Code, or Visual Studio with open folder to open your project.
This should be enough to get you started.

How to compile and run a C++ project with a Makefile? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I needed a library for my project that would cover CANFIS functionalities and Fuzzylitex does that. But the problem is, I don't know how to build this project? I am familiar with cmake files but this project has Makefile and I cannot work with it? I am using Visual Studio 2015.
Thanks to the comments, I found out about the difference between Makefile and Cmake files. The tool that can be used to make a project with Makefile in Visual Studio, is NMAKE.EXE. It is built in for Visual Studio. All you need to do is to open the visual studio command prompt (tools -> Visual Studio Command Prompt) and go to the directory of the Makefile and type "nmake" and press enter. The problem just begins here! There is a good chance that you will get errors. Anyway, this is the solution to my problem. Also, this is a good tutorial on using NMAKE.

install opencv in visual studion 2017 [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I would like to install OpenCV in Visual Studio and I have tried several ways and I still have the same problems..
The code doesn't have any errors.
The code says that LNK2019 unresolved external symbol.
Install through the Package Manager Console: PM> Install-Package opencvdefault (c++)
Install through Manage Nuget Package for Solution: opencv.win.native (c++)
Install the file from in internet: opencv_python-3.4.1-cp37-cp37m-win32 (python)
What am I doing wrong? I want to use it in VS 2017 with C++ or Python.
I'd suggest you to download OpenCV sources from opencv.org and latest version of CMake installation kit from cmake.org.
You will be able to built OpenCV on your own PC. My own experience indicated that it's quite easy and Open CV works without any problems.
CMAke has a support for MS Visual Studio 15 (also called MS Visual Studio 2017)
So you have created a project called 'opencv', only slightly confusing the question.
First thing to decide is if you want to use Visual Studio (C++) or Python?
If Visual Studio, I suggest downloading the latest library from the OpenCV website (select 'Win pack') https://opencv.org/releases.html
In your project you will then need to include the OpenCV header folder, and link to the (lib) libraries, then make sure your executable is able to find the main opencv dll library.
I do not recommend compiling the OpenCV library with Cmake - this is not trivial (I've spent half a day on it and failed) - moreover it's not necessary as OpenCV can be used as is.

Any disadvantages of using Qt visual studio addon [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I am just starting to learn how to use Qt in C++. They have a option to use a standalone Qt creator as well as an addon for Visual Studio. I have Visual Studio Community 2015.
The question is, is there any disadvantages of using the addon for Visual Studio over just coding in Qt creator?
UPDATE: How do i use Qt in my Visual Studio 2015 projects?
It seems the below is a bit outdated already considering using Qt extension for VS2015. But I have not personally tried myself yet and suspect Qt Creator still have its advantage as below.
The advantages of Qt Visual Studio Add-In:
It lets us to use better debugger from Visual Studio while working with Qt project
It lets us to easily do the remote debugging by running the executable on other system or VM
Many developers used to Visual Studio
The disadvantages of Qt Visual Studio Add-In:
Very unreliable project import, makes us to fix things manually. And not all add-in versions are good: we still use 1.2.3 because of that
Not convenient with adding file to the project etc. We usually add to and then re-import the project from Qt .pro file
Visual Studio builds the code much slower than Qt Creator does (roughly the proportion between nmake and jom tools, jom parallelizes the build)
Visual Studio must be higher than Express (e.g. Ultimate)
The Qt Visual Studio Add-in allows programmers to create, build, debug
and run Qt applications from within non-Express versions of Microsoft
Visual Studio 2008, 2010, and 2012 (*newer versions also covered).
The rest of advantages and disadvantages can be considered individual developer preferences. I like Qt Creator for its ability to quickly find any definition under the cursor (press Ctrl and hover the mouse cursor and select) while MS Visual Studio does that but not as easy and surprisingly too frequently fails to find the definition (they fix it for years and maintain huge index files for the source code while Qt Creator does not build such files).
And for me the main disadvantage of Qt Creator is CDB from Windows SDK or maybe another external one vs. way better debugger in Visual Studio including remote. So I debug complex issues with Visual Studio but I write the code and quickly test it with Qt Creator.