Is the visual c++ express cmd prompt missing features? - c++

I tried compiling the POCO library on my Windows 7 computer. Though I use eclipse cdt, it said that It could only be compiled with Visual C++:
Microsoft Visual Studio 7.1 (2003), 8.0 (2005), 9.0 (2008) or 10.0
(2010) is required to build the POCO C++ Libraries on Windows
platforms. Solution and project files for all versions are included.
For Visual Studio 2008 and 2010, 64-bit (x64) builds are supported as
well. You can either build from within Visual Studio (Build->Batch
Build->Select All;Rebuild) or from the command line. To build from the
command line, start the Visual Studio .NET 2003/2005/2008/2010 Command
Prompt and go (cd) to the directory where you have extracted the POCO
C++ Libraries sources. Then, simply start the buildwin.cmd script and
pass as argument the version of visual studio (71, 80, 90 or 100). You
can customize what is being built by buildwin.cmd by passing
appropriate command line arguments to it. Call buildwin.cmd without
arguments to see what is available. To disable certain components
(e.g., NetSSL_OpenSSL or Data/MySQL) from the build, edit the text
file named components in the distribution root directory and remove
the respective lines. Certain libraries, like NetSSL_OpenSSL, Crypto
or Data/MySQL have dependencies to other libraries. Since the build
script does not know where to find the necessary header files and
import libraries, you have to either add the header file paths to the
INCLUDE environment variable and the library path to the LIB
environment variable, or you'll have to edit the buildwin.cmd script,
where these environment variables can be set as well. In order to run
the test suite and the samples, the top-most bin directory containing
the resulting shared libraries must be in the PATH environment
variable.
I downloaded visual c++ express, but when I run the "buildwin.cmd" I get these errors:
devenv is not recognized as an internal or external command.
I also can't find any "build" menue inside the program. Is the full Visual C++ required to build the library? If so, is there any cheaper option?

Related

CMake generator in Visual Studio Code Windows 10 [duplicate]

I read the documentation.
It says:
A CMake Generator is responsible for writing the input files for a native build system.
What exactly does that mean?
If I have a set of C++ files in my project, are these the input files?
If I'm using Linux, what is my native build system by default? Make?
Why do the input files have to be written by the generator if they already exist?
What's a generator?
To understand what a generator is, we need to first look at what is a build system. CMake doesn't compile or link any source files. It used a generator to create configuration files for a build system. The build system uses those files to compile and link source code files.
So what's a build system?
A build system is a broad term that groups together a set of tools used to generally compile and link source code, but it can also include auxiliary tools used during a build process.
For example, in a multi-stage build system, one executable might be built to be used in the build process of another build.
Depending on the tool chain used on a system, CMake will generate multiple files and folders to allow the building of the source files referenced in the CMakeLists.txt and supporting .cmake files.
Sometimes multiple build systems may be installed on a computer, like for Windows you could have a Visual Studio and MinGW build system. CMake allows you to specify which if these build systems to generate configuration files for.
CMake includes a number of Command-Line, IDE, and Extra generators.
Command-Line Build Tool Generators
These generators are for command-line build tools, like Make and Ninja. The chosen tool chain must be configured prior to generating the build system with CMake.
The following are supported(**):
Makefile Generators
Borland Makefiles
MSYS Makefiles
MinGW Makefiles
NMake Makefiles
NMake Makefiles JOM
Unix Makefiles
Watcom WMake
Ninja Generators
Ninja
Ninja Multi-Config
IDE Build Tool Generators
These generators are for Integrated Development Environments that include their own compiler. Examples are Visual Studio and Xcode which include a compiler natively.
The following are supported(**):
Visual Studio 6
Visual Studio 7
Visual Studio 7 .NET 2003
Visual Studio 8 2005
Visual Studio 9 2008
Visual Studio 10 2010
Visual Studio 11 2012
Visual Studio 12 2013
Visual Studio 14 2015
Visual Studio 15 2017
Visual Studio 16 2019
Visual Studio 17 2022
Green Hills MULTI
Xcode
Extra Generators
These are generators that create a configuration to work with an alternative IDE tool and must be included with either an IDE or Command-Line generator.
The following are supported(**):
CodeBlocks
CodeLite
Eclipse CDT4
KDevelop3 (Unsupported after v3.10.3)
Kate
Sublime Text 2
If I have a set of C++ files in my project, are these the input files?
Yes, they are some of the input files. For a make build system you also have a MakeFile. For Visual Studio you have a solution file (.sln). With both systems there are additional files needed that CMake knows how to create given a proper CMakeLists.txt file.
If I'm using Linux, what is my native build system by default? Make?
Generally, yes, but other build systems could be setup like Ninja.
Why do the input files have to be written by the generator if they already exist?
Some source files may already exist, but CMake has the ability to generate header and source files. Also as mentioned above, there are configuration files that must be generated that depend on the source files supplied in the CMakeLists.txt file.
** According to the documentation for CMake Version 3.9 & 3.15 & 3.25
Maybe a picture is worth a thousand words.
A CMake Generator is responsible for writing the input files for a
native build system.
means that CMake prepares build scripts for a native build system when no generator is specified. In Linux the default build system is Make and its input file are makefiles, which are then interpreted and a build is executed accordingly. Before the first execution of CMake build scripts do not exist.
C++ source files (or any other source files) are not input files to a build system. Build system scripts specify how to handle source file in order to produce binary executables.
As far as I know, the standard native build system in Unix is GNU Make (gmake) known as "make".
The Google guys/gals also released a different tool called Ninja.

How to locate C, C++, and Fortran compilers on my win7x64 machine?

I'm trying to build binary files of the LAPACK 3.7.0 using CMAKE based on what is told here. In order to use them in my Visual Studio 2013 C++ project.
But I really don't know which option should I choose here?
And also which compilers should I choose in the following?
Because I can't find them in the suggested directories within Program Files or Program File(x86) folders.
my machine uses a dual-core Intel(R) Core(TM) 2 Duo CPU
When using Visual Studio < 2015, a common solution is to run CMake GUI from Visual Studio Command line.
Use windows start menu to run "Visual Studio Command Prompt"
Run cmake-gui from command line. If the folder is in your path, simply launch cmake-gui. If not, launch it using the full path
Locate the source folder of your project (the folder containing the top-level CMakeLists.txt) and create a new build folder (ex c:/my-project/build_32). Generating an environment in the source folder is discouraged)
Generate your project selecting the right MSVC version. In your case, it will be "Visual Studio 12 2013". In my case, this is MSVC 2010.
That's all. Click on finish button and it should generate the compilation environment, solutions, projetcs, etc.
This will generate environment for compiling x86 application. If you also need to compile a x64 version of your project, simply follow again that process, generating in a new build folder and selection "Visual Studio 12 2013 Win64".
By default, if you have a paid version of Visual Studio you have both x86 and Win64 compiler installed. If you have the express version, you only have the x86 compiler (so generation using MSVC Win64 will fail).

Building FFMPEG for Visual Studio development

I'm trying to use ffmpeg in Visual Studio 2013 C++ software (ultimately as part of an OpenCV project) - but right now I'm just trying to get basic FFMPEG functionality. In general, when building in Visual Studio, I build 64--bit software with Multi-threaded DLL runtime libraries. I have built ffmpeg using the general instructions for 'Native Windows compilation using ... MinGW-w64' at http://ffmpeg.org/platform.html#Windows (I provide a more detailed set of steps I followed below...).
After building the ffmpeg software on my system, I tried to create a simple 'hello world' project in Visual Studio 2013. Specifically, I tried to implement the initial tutorial file presented at http://dranger.com/ffmpeg/tutorial01.html. Upon building the project, I get the error:
c:\msys64\usr\local\ffmpeg\libavutil\common.h(45): fatal error C1083: Cannot
open include file: 'libavutil/avconfig.h': No such file or directory
The following are the detailed steps I took to build ffmpeg and create my basic Visual Studio project:
============ Building ffmpeg ===============
Downloaded and intalled msys2-x86_64-20160205.exe from http://msys2.github.io
Ran update-core to update the Msys2 install
Ran pacman -Suu (twice) to complete the update (following the instructions about updating shortcuts, etc.)
Then I quit out of the MSys2 shell and opened the MinGW-w64 Win64 Shell. In this new shell:
Installed the following packages using pacman -S <package-name> The list of packages I installed is: make, pkg-config, diffutils, mingw-w64-x86_64-yasm, mingw-w64-x86_64-gcc, mingw-w64-x86_64-SDL, git
Then I cd'd into cd /usr/local
Ran git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg
I wanted to build the ffmpeg library 'out-of-tree' of this MSys64 folder. So, in the regular file system of my Windows machine I created a folder at C:\ffmpeg
Back in the Win64 Shell, I cd'd to this new folder: cd /c/ffmpeg
Then ran /usr/loca/ffmpeg/configure --enable-shared
Then make -r
And, finally make install
Now, if I had to guess, my 'flaw' was in the options I used when calling the 'configure' script of ffmpeg. Do I need to use particular options so that I can take the ffmpeg libraries built here and use them as dynamic (DLL) libraries in Visual Studio?
========== Configuring my Visual Studio Project ============
Here's how I created a simple hello world project in Visual Studio to see if ffmpeg is working.
I created a new Visual C++ 'Empty Project' in Visual Studio 2013
I then configured the project properties as follows:
a. In C/C++ => General => Additional Include Directories, I put
C:\msys64\usr\local\ffmpeg
b. In Linker=>General => Additional Library Directories, I pointed to each of the built library folders (basically I pointed at all of the libraries that were built to ensure I was not inadvertently missing the critical one). The list is as follows:
C:\ffmpeg\libavcodec
C:\ffmpeg\libavdevice
C:\ffmpeg\libavfilter
C:\ffmpeg\libavformat
C:\ffmpeg\libavutil
C:\ffmpeg\libswresample
C:\ffmpeg\libswscale
C:\ffmpeg
c. In Linker=> Input => Additional Dependencies, I pointed to the particular libraries (again - I pointed to all of the ones present). The list is:
avcodec.lib
avdevice.lib
avfilter.lib
avformat.lib
avutil.lib
swresample.lib
swscale.lib
I then created a new source file called 'tut01.c' and copied/pasted the code from http://dranger.com/ffmpeg/tutorial01.c
Then hit F7 and got the error specified above about not finding avconfig.h
The above is my best guess as to the steps I need to follow to get this working in Windows (btw, it's Windows 10, 64-bit) & Microsoft Visual Studio 2013. What should I change to get this basic program to build and run?
#halfelf, thanks for the responses. They caused me to take another look at my files and I realize I was pointing at the wrong location for the include (and lib) files. Turns out that, upon building ffmpeg, it places in lateral folders /usr/local/include and /usr/local/bin, I guess, a more complete set of include and library files, respectively (including avconfig.h!) I updated my Visual Studio project properties to point at these folders which solved that problem.
But subsequently, I ran into a new problem of 'PIX_FMT_RGB24' not being identified. However, I think this is related to the tutorial file I'm using being out of date. I can delete those (and related) lines and the code will build and execute (though it does not do much since the 'money' lines of code are removed). But at least base features of ffmpeg appear to be working.

How to compile a C program with Visual Studio on Windows?

I am trying to compile a library for 2D localization called libdots which can be found on this website with Visual Studio 2015 on Windows for x86 or x64.
The following is stated in the readme file of the lib:
It is written in pure c and has no external library dependencies other
than 'libc'.
What I have done so far:
Installed OpenCV 3.0.0 to C:/opencv
Installed CMake for Windows
Installed MinGW
Set the following System Environment Variable:
OPENCV_DIR C:\opencv\build\x86\vc12
Added the following to the Path variable in Windows settings:
%OPENCV_DIR%;
C:\opencv\build\x86\vc12\lib;
C:\opencv\build\include;
C:\opencv\build\include\opencv;
C:\opencv\build\include\opencv2
Then I configured and generated the Makefile with cmake-gui and selected Visual Studio 14 2015 generator with "Use default native compilers":
This produced a Visual Studio Solution file (*.sln). Opening this file shows me the complete C project in the IDE. But when trying to build the project, I get the following errors:
Does somebody have a hint how to proceed and/or solve these issues?

Compiling libjpeg

Is there anyone who succeed to include libjpeg in some compiler? I tried everything: Dev C++, VS10, CodeBlocks, copy the headers and the lib by hand, add with the linker but nothing. Right now I am really confisued as there is not an official guide on how to compile it in any compiler. I would be really happy if someone could provide a tutorial on how the library can be compiled in any compiler.
Thank you in advance.
To compile libjpeg 9 in Visual Studio 2012, here are the steps (after unzipping the archive file):
Download the file WIN32.MAK (for example, from http://www.bvbcode.com/code/f2kivdrh-395674-down), and place a copy in the root source code directory (possibly C:\jpeg-9, but it depends where you unzipped it). I will refer to this directory as %jpegsrc% from now on. Having this file is important; otherwise step 3 will produce an error.
In the Visual Studio command prompt, open to %jpegsrc%:
cd %jpegsrc%
At the same command prompt, execute the following:
NMAKE /f makefile.vc setup-v10
This will create two Visual Studio 2010 solutions in %jpegsrc%: jpeg.sln and apps.sln.
Open each solution in Visual Studio 2012. Each one will prompt you to update all the projects to 2012 format. Click on “Update.” One time I did it, the prompt did not appear. In case that happens, right-click on the jpeg solution in the Solution Explorer, and choose “Update VC++ projects...,” which will produce the same prompt.
Save and build each solution as normal. (You have to build the jpeg.sln solution before apps.sln, since the latter depends on the former.)
Note: this process should work correctly in Visual Studio 2010, without the updating, but I have not tested it.
Update: This method still works in Visual Studio 2015 for libjpeg-9a.
Here is how I've built libjpeg using MinGW on Windows :
1. Get MinGW with MSYS
I've got a copy from http://sourceforge.net/projects/mingw/.
Quoting from www.mingw.org :
MSYS is a collection of GNU utilities such as bash, make, gawk and grep to allow building of applications and programs which depend on traditionally UNIX tools to be present.
We will need it to run the configure script that comes with libjpeg sources.
2. Get libjpeg sources
From http://www.ijg.org/, take the Unix format package (the Windows one won't work with this procedure). I took the jpeg_8d version.
3. Prepare a building directory
I've made a temporary directory named tmp in D:\, but you could choose whatever suits your needs. The thing that matters is the name of paths in MSYS. As it brings some * Unixity * to Windows, paths cannot be used in their original form.
In a nutshell:
C:\path\to\file becomes /c/path/to/file in MSYS land, an so
D:\tmp becomes /d/tmp.
Decompress the libjpeg sources in D:\tmp, so you have a jpeg-8d directory in there.
Create a jpeg-build directory inside D:\tmp, it will hold the built library.
Now everything is ready for the build.
4. ./configure, make, make install
That is the mantra of building in Unix land. An option should be added to redirect the install process to D:\tmp\jpeg-build.
Run the following commands in an MSYS shell (also named MinGW shell in Windows start menu):
cd /d/tmp/jpeg-8d
./configure --prefix=/d/tmp/jpeg-build
make
make install
As an additional step, you can run make test for safety.
These commands will build both static and shared versions of libjpeg.
5. Take the goods, delete the temporaries
If everything runs fine, you can delete the D:\tmp\jpeg-8d directory, but keep the jpeg-build one. It contains:
an include directory, containing libjpeg headers. You can move them to your compiler's headers directory.
a lib directory, with .a file to pass to the linker. You can move them to your compiler's library directory.
a bin directory, holding the libjpeg shared library libjpeg-8.dll and jpeg tools.
a share directory, containing man pages for the jpeg tools.
You can now build your program and link it against libjpeg by indicating the right include and library paths.
You can find many details about the libjpeg building and installation process in install.txt inside the source package.
I hope this will be useful.
It is really simple to build jpeg.lib with VS10.
First, download the libjpeg source code in zip format. At the time I'm writing this you can find it here.
Then extract the contents of the zip file to your disk.
Then open a VS2010 command prompt shell (or call vcvarsall.bat on any command prompt window), cd to the jpeg source directory (jpeg-8d in the download referenced above) and type the following:
nmake -f makefile.win setup-v10
This will generate two VS2010 solutions, and a bunch of project files. The solutions are:
jpeg.sln, which builds jpeg.lib
apps.sln, which builds the sample applications.
Good luck!
If you don't happen to have Visual Studio 2010 installed, here is what works on Visual Studio 2017:
Basic / Common steps:
Download the latest version of libjpeg from: http://www.ijg.org/ (zip version) and extract it to a folder
Open the "Developer Command Prompt for VS2017"
Change directory (cd) to where you extracted the library source
VS 2017 Approach:
Include the Windows SDK v7.1A directory (required for Win32.Mak by nmake later on) by running: set INCLUDE=%INCLUDE%;c:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include
Run nmake /f makefile.win setup-v15 (note the v15 for VS2017 here)
From here on follow what #AthanasiusOfAlex explained to upgrade the Visual Studio 2010 solution to the Visual Studio version you are running. If you want the Debug configuration, follow what #SteveEng explained.
Errors you might stumble across:
If nmake fails and tells you it doesn't know how to make
jconfig.h, manually rename the file jconfig.vc to jconfig.h
If nmake fails and tells you Win32.Mak cannot be found, manually copy it from the SDK dir mentioned in step #4 to the libjpeg source directory. If you don't happen to have that SDK version installed, download the file from a trustworthy resource.
If nmake fails and tells you it doesn't know how to make setup-v15, trial and error your way through starting with setup-v10, setup-v11, etc... These are VS versions and one of them should work as long as you have any VS version later than VS 2008 installed.
Hope this helps people going through similar pain with this.
If you want debug mode as well in MSVC. Follow AthanasiusOfAlex's method, build the release, then:
Right-click on the project and select properties at the very
bottom
Click on configuration manager and on the active solution
configuration drop-down select -new-
Set the name to debug and on
the drop-down select copy configuration settings from release and
click OK
Close the dialog, go to general settings and under Target
Name add a d to the end so it looks like this: $(ProjectName)d
On Whole Program Optimization drop-down select: No Whole Program Optimization
Then click on the C/C++ under configuration properties on the left and on the Debug Information Format drop-down select C7 compatible (/Z7)
Under optimization select disabled and select NO for both Enable Fiber-Safe Optimizations and Whole Program Optimizations
Under preprocessor, preprocessor definitions, click on edit and use the following:
WIN32
_DEBUG
DEBUG
_LIB
_CRT_SECURE_NO_WARNINGS
Under code generation, under runtime library select Multi-threaded Debug DLL (/MDd)
Build and you're done!
This is for VS2019 with version number 16.0
Consider the Visual Studio Version name correctly like this for creating the .sln file.
Product name Code name Version number
Visual Studio 2019 Dev16 16.0
Visual Studio 2017 Dev15 15.0
Visual Studio 2015 Dev14 14.0
Visual Studio 2013 Dev12 12.0