How to succesfully build a project using the MSBuild? - c++

I have a 3-dr party project that I'd like to build. The author said to build it I have to use the MSBuild. Here is the exact citation from him:
Clone https://github.com/NovaRain/DXSDK_Collection.git to some
Copy \DXSDK_Aug2007\Lib\x86\dinput.lib to \DXSDK_Jun2010\Lib\x86\
Set environment variable DXSDK_DIR to "\DXSDK_Jun2010" (trailing slash is important)
In sfall directory (where ddraw.sln is), create empty PostBuild.cmd
Run VS installer and add "MSVC v140 - VS 2015 C++ build tools (v14.00)" if you don't have it already
Find MSBuild.exe and run: MSBuild.exe path\to\ddraw.sln -p:Configuration=ReleaseXP -p:Platform=Win32 -p:PlatformToolset=v140_xp
I've followed all the steps carefully but when i run the MSBuild command I'm getting followin error: "Cannot open include file: 'algorithm': No such file or directory"
here is the stdafx.h header content for a reference:
#pragma once
#pragma message("Compiling precompiled headers.\n")
#define WINVER _WIN32_WINNT_WINXP
#define _WIN32_WINNT _WIN32_WINNT_WINXP
#include <algorithm>
#include <functional>
#include <initializer_list>
#include <memory>
#include <vector>
#include <unordered_map>
#include <map>
#include <string>
//#define WIN32_LEAN_AND_MEAN
#define NOCRYPT
#define NOSERVICE
#define NOMCX
#define NOIME
#include <Windows.h>
#include <intrin.h>
How could it be that the Standard Library headers isn't available since I've done a standard VS c++ installation?

Related

Visual Studio doesn't find GL/glut.h

I'm using Microsoft Visual Studio Community 2017 on Windows 10 and I've been trying to install GLUT using this online guide that I found on this StackOverflow question. However, when I try to compile my code this error still shows up: fatal error C1083: Cannot open include file: 'GL\glut.h': No such file or directory. I've followed every single step line by line, but nothing seems to work. What could be causing this error?
This is how I'm importing the dependencies:
#include <iostream>
#include <Windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <GL/GL.h>
#include <GL/GLU.h>
#include <GL/glut.h>
#include <cstring>
#include "math.h"
#include <conio.h>
For this, I like to use the Nuget package manager. If you go to
Tools>NuGet Package Manager>Package Manager Console
Then, in the console type:
Install-Package nupengl.core
Your problem should be fixed.

Using Catch2 in Visual C++ 2015

I'm trying to make a Unit Testing project using the Catch framework, but am faced with Link errors.
I've set up the project as follows:
Create a Native Unit Test project
Add Catch to the include directories
Add #include <catch.hpp> to stdafx.h
Write the following simple source file
unittest.cpp:
#include "stdafx.h"
namespace Catch2_Test
{
TEST_CASE("Y U no work")
{
REQUIRE(1);
}
}
For integrating Catch into Visual Studio
refer the ACCU article Integrating the Catch Test Framework into Visual Studio, by Malcolm Noyes
For using Catch2 in pre-compiled headers,
refer Catch2 issue 1061, where horenmar gave an example. The changes have been released as part of v2.1.0
In summary, the solution given is:
// stdafx.h
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
#define CATCH_CONFIG_ALL_PARTS
#include "catch.hpp"
// PCH-test.cpp:
#include "stdafx.h"
#undef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED
#define CATCH_CONFIG_IMPL_ONLY
#define CATCH_CONFIG_MAIN
#include "catch.hpp"
// tests1.cpp:
#include "stdafx.h"
TEST_CASE("FooBarBaz") {
REQUIRE(1 == 2);
}
The problem was that I had cloned Catch2 from the master branch, while the VS integration worked on a branch off Catch.

Linux: Conflicts using inotify with fcntl

I'm having a strange linking issue after I included inotify in my program to monitor changes to a filesystem. The project includes <fcntl.h> in many other source files. However, when I include <sys/inotify.h> in the source file which is doing the directory monitoring, I get this error:
/usr/include/fcntl.h:30:1: error: expected initializer before ‘extern’
__BEGIN_DECLS
My project uses CMake, although that doesn't seem to be relevant for finding inotify. It IS finding the inotify declarations to my knowledge, since when I included , it threw an error that inotify_init() and the other functions I used were not defined. Inotify includes fcntl and is partially built on top of some of the functionality there, so my first thought was that it's importing a different version of fcntl than the rest of my program.
In ObjectManager.h:
#ifndef MANAGE_OBJECT_H
#define MANAGE_OBJECT_H
#include "config.h"
//includes all lua headers under extern 'C'
#include <lua.hpp>
#include <list>
#include <unordered_map>
#include <pthread.h>
class ObjectManager //...
The only thing that changed was ObjectManager.cc, with the addition of sys/notify and the implementation of the watcher (not included because this is a linking issue):
#include "config.h"
#include "ObjectManager.h"
#include "Control.h"
#ifdef OBJECT_MANAGER_ENABLED
#include <string.h>
#include <stdio.h>
#include <dirent.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <vector>
#include <unistd.h>
#include <fstream>
#include <sys/inotify.h>
//... inotify implementation
Where Control.h declares #include <fcntl.h>.
This is the closest issue I found, related to some problems in the implementation of different fcntl headers for userspace usage. https://lkml.org/lkml/2008/9/16/98
The same problem occurs on Linux 2.6 running on Centos 6 and Linux 4.0 running on Centos 7.
Any ideas on what is causing this error and how to successfully include inotify?
Resolution: A function definition lacked a semicolon at the END of ObjectManager.h right before a #endif, and the resulting GCC error that propagated through the next includes in a complicated manner, resulting in a strange preprocessor error in fcntl.h.

libssh2_config.h not created when installing libssh2

The title more or less describes the problem I'm having on my Ubuntu box.
I followed the following steps in installing libssh2, as given in the instructions:
./configure
make
make check (all 3 tests passed)
sudo make install (I have to use sudo due to permissions)
I then try to use some of the examples given in libssh2 page and they all have the following:
#include "libssh2_config.h"
Which isn't found. The following 3 files are created in usr/local/include:
libssh2.h
libssh2_publickey.h
libssh2_sftp.h
Is there anything I am doing wrong?
Thank you!
I still can't figure out why the file isn't created, but it is not really necessary, since removing the following #ifdefs:
#ifdef HAVE_WINDOWS_H
#include <windows.h>
#endif
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
and simply replacing (on linux) with:
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <arpa/inet.h>
as well as removing the rest of #ifdefs in the code solves the problem.
libssh2_config.h is in the example dir, you need to copy into your projects.
There are libssh2_config.h files in the win32 dir, the vms dir and the os400 dir. You need to copy one of these into your projects.

"No such file" Include issue with Boost dynamic_bitset

I'm trying to use Boost's Dynamic_bitset class for a project, and I (believe I) have taken whichever subset of files I needed from the complete library. Now I'm doing an
#include "boost/dynamic_bitset.hpp" inside my manager.cpp file, and when compiling I get this:
In file included from manager.cpp:4:0:
boost/dynamic_bitset.hpp:15:51: fatal error: boost/dynamic_bitset/dynamic_bitset.hpp: No such file or directory
The file ierarchy inside the project folder goes like this:
proj/extras.h
proj/Makefile~
proj/manager.cpp
proj/boost
proj/boost/limits.hpp
proj/boost/dynamic_bitset.hpp
proj/boost/mpl
proj/boost/mpl/if.hpp
proj/boost/mpl/has_xxx.hpp
proj/boost/iterator.hpp
proj/boost/static_assert.hpp
proj/boost/dynamic_bitset
proj/boost/dynamic_bitset/dynamic_bitset.hpp
proj/boost/dynamic_bitset/config.hpp
proj/boost/config
proj/boost/config/select_platform_config.hpp
proj/boost/config/select_compiler_config.hpp
proj/boost/config/user.hpp
proj/boost/config/suffix.hpp
proj/boost/config/select_stdlib_config.hpp
proj/boost/dynamic_bitset_fwd.hpp
proj/boost/config.hpp
proj/boost/type_traits
proj/boost/type_traits/is_same.hpp
proj/boost/type_traits/is_pointer.hpp
proj/boost/type_traits/remove_pointer.hpp
proj/boost/type_traits/remove_const.hpp
proj/boost/type_traits/is_base_and_derived.hpp
proj/boost/type_traits/detail
proj/boost/type_traits/detail/bool_trait_def.hpp
proj/boost/type_traits/detail/yes_no_type.hpp
proj/boost/pending
proj/boost/pending/integer_log2.hpp
proj/boost/detail
proj/boost/detail/limits.hpp
proj/boost/detail/dynamic_bitset.hpp
proj/boost/detail/workaround.hpp
proj/boost/lowest_bit.hpp
proj/Makefile
proj/generator.cpp~
proj/generator.cpp
This same project compiles fine on my university's linux systems(g++ 4.2.4 there but I doubt it matters), but fails to do so (with the above error) on my Ubuntu laptop. Why isn't it finding the file since it evidently exists?
All my includes are as such:
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include "boost/dynamic_bitset.hpp"
#include <cmath>
#include <list>
#include <unistd.h>
#include <sys/sem.h>
#include <sys/shm.h>
#include <errno.h>
#include <wait.h>
#include <time.h>
#include "extras.h"
compilation is done simply with
g++ -o manager manager.c
or
g++ -Iboost -o manager manager.c
if I want to explicitely include the (local..) folder
-I .
At least if you are compiling in the same directory that contains boost.
You wrote -Iboost and #include "boost/…". So it looks in ./boost if there is a boost subdirectory.