OS: Windows 8 64-bit
Compiler: Visual Studio 2012
Problem Description: When I try to compile codes with "dirent.h" in "x64", error occurs. No matter dirent.h is used or not. The error won't occur if the codes were compile under "win32" setting.
Error MSG: C:\Program Files (x86)\Windows Kits\8.0\Include\um\winnt.h(146): fatal error C1189: #error : "No Target Architecture"
EXAMPLE:
#include stdio.h
#include sys/types.h
#include dirent.h
int main(int argc, char* argv[])
{
const char *name = ".";
DIR *dirp;
struct dirent *dp;
dirp = opendir(name);
if (dirp != NULL) {
printf("opendir %s succeed!\n", name);
}
closedir(dirp);
return 0;
}
I had the same problem... Try to go PROJECT-> PROPERTIES -> Configuration Properties -> C/C++ -> Preprocessor, and in Preprocessor Definitions add AMD64. It works for me. PS put underscore before and after AMD64.
Related
I have this program
#include <stdio.h>
#include <mpi.h>
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
int size;
int rank;
MPI_Init(NULL, NULL);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
printf("Hello, World!");
cout << MPI_Comm_rank << " " << MPI_Comm_size << endl;
MPI_Finalize();
return 0;
}
When I debug this in Microsoft Visual Studios it works just fine. But when I try it in the command prompt or any terminal I get this error,
Project_1.cpp:2:10: fatal error: mpi.h: No such file or directory
2 | #include <mpi.h>
| ^~~~~~~
compilation terminated.
I have g++ installed already and it works with other programs just fine. I have MPI installed too. Was able to link it to my Microsoft Visual Studio but it only works in its debug section. I am using a windows computer. Not really sure what to do. Any help would be great thanks.
There are some problem with your program:
You don't define MPI_Comm_rank and MPI_Comm_size but you try to print them in cout. In the following piece of code, I've rewritten your code.
#include <stdio.h>
#include <mpi.h>
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
int size;
int rank;
MPI_Init(NULL, NULL);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
printf("Hello, World!");
cout << rank << " " << size << endl;
MPI_Finalize();
return 0;
}
You also need to add the location of mpiexec.exe to your system PATH by :
1- Open Window’s System Properties dialog box => click on Environment Variables
2- Click edit for the Path variable => add C: Program Files\Microsoft MPI\Bin \ (Assuming the default install)
To include the appropriate libraries.
1- The MPI code should be compiled as a Console Application
2- Once you have created the project you need to add the appropriate library
Right-click on the project in the Solution Explorer and go to Properties
Click on VC++ Directories and (assuming the MPI SDK is installed in the default directory) add:
C:/ Program Files (x86)/Microsoft SDKs/Include to the Include Directories
C:/Program Files (x86)/Microsoft SDKs/Lib/x64 or C:/Program Files (x86)/Microsoft SDKs/Lib/x86 to the Library Directories
Depends on whether you wish to compile your code as 32bit or 64bit
3- Click on Linker =>Input
Under Additional Dependencies add msmpi.lib
I am syncing and building a project using jenkins with msbuild tool, but I keep getting this error everytime I run the build, either in VS or through Jenkins. I honestly have no idea what it means and I have not found any information on internet. I have another very similar project which runs fine. Any help or what to start checking it would be much appreciated as I have delete and set the job from scratch with the same result. This is the output I get from jenkins:
"C:\Users\User\.jenkins\workspace\Age_3_DE\Source\Age3DE.sln" (default target) (1) ->
"C:\Users\User\.jenkins\workspace\Age_3_DE\Source\age3\age3.vcxproj" (default target) (2) ->
(PreBuildEvent target) ->
PerforceChangeList : error : No matching clients for root=C:\Users\User\.jenkins\workspace\Age_3_DE\ [C:\Users\User\.jenkins\workspace\Age_3_DE\Source\age3\age3.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(128,5): error MSB3073: The command "C:\Users\User\.jenkins\workspace\Age_3_DE\Source\..\Scripts\PerforceChangeList.bat age3 "C:\Users\User\.jenkins\workspace\Age_3_DE\Source\age3\PerforceVersion.inc" "C:\Users\User\.jenkins\workspace\Age_3_DE\Source\age3\resource_version.h" [C:\Users\User\.jenkins\workspace\Age_3_DE\Source\age3\age3.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(128,5): error MSB3073: :VCEnd" exited with code -1. [C:\Users\User\.jenkins\workspace\Age_3_DE\Source\age3\age3.vcxproj]
27 Warning(s)
2 Error(s)
resource_version.h file:
#pragma once
#define VERSION_MAJOR 100
#define VERSION_MINOR 10
#define VERSION_BUILD 0
#define VERSION_STRING "100.10.0.0"
and PerforceVersion.inc:
#pragma once
namespace PerforceInfo {
const char* gChangeList = "00000";
const char* gVersionString = "100.10.0.0";
const char* gUserName = "";
const char* gClientName = "";
const char* gClientHost = "";
const char* gClientRoot = "";
const char* gClientStream = "";
}
Here is an image with the exactly error and the line where the error happens from VS Error
we would like to upgrade from occi 18 to occi 19.3.0.0.0 because we want to be independent of old MS libraries (MSVCR120.DLL).
But there is the following error while connecting the database:
"Program: C:\Windows\SYSTEM32\MSVCP140D.dll
File: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\xstring
Line: 1695 Expression: string subscript out of range
For information ..."
When we remove "OCCIUTF16", "OCCIUTF16" in createEnvironment the connection succeeds.
We also recognized, that oci.dll was not loaded in this simple programm using occi 19. With occi 18 oci.dll was loaded.
#include "occi.h"
#include <iostream>
using namespace oracle::occi;
using namespace std;
int main(int argc, wchar_t * argv[])
{
try {
// OK
//auto env = Environment::createEnvironment(Environment::Mode(Environment::OBJECT | Environment::THREADED_MUTEXED));
//auto conn = env->createConnection("SCOTT", "tiger", "ORATEST");
// ERROR
auto env = Environment::createEnvironment("OCCIUTF16", "OCCIUTF16", Environment::Mode(Environment::OBJECT | Environment::THREADED_MUTEXED));
UString user((utext*)L"SCOTT");
UString pwd((utext*)L"tiger");
UString host((utext*)L"ORATEST");
auto conn = env->createConnection(user, pwd, host);
}
catch (SQLException & ex) {
cout << ex.what();
}
return 0;
}
Environment:
ORACLE SERVER 12.1.0.2
Microsoft Visual C++ 2017 Compiler Version 15.9.13
Basic Light Package Information
Wed May 29 22:35:38 MDT 2019
Client Shared Library 64-bit - 19.3.0.0.0
Any ideas?
Thanks in advance!
Can you provide the complete stack when it fails
The issue you are pointing at MSVCP140D.dll (D - Debug) -> so, I presume you are compiling with ORAOCCIxxD.LIB (Debug version). If you are using debug build, please use all components in debug build.
Yes, OCI.DLL will not be loaded along with ORAOCCI.DLL now.
Thanks,
-P. Venkatraman.
I'm building a GTK+ VS2010 project configuration on (VS2013) and I'm trying to add a browse folder functionality (I want to use Native Windows way). I'm using the following code:
#include <windows.h>
#include <ShlObj.h>
DWORD WINAPI BrowseFolder(void *ptr)
{
char path[MAX_PATH];
cchar * path_param = (cchar*)ptr;
BROWSEINFO bi = { 0 };
bi.lpszTitle = ("Select Folder");
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
bi.lpfn = BrowseCallbackProc;//callback function defined..
bi.lParam = (LPARAM)path_param;
LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
if (pidl != 0)
{
//get the name of the folder and put it in path
SHGetPathFromIDList(pidl, path);
//free memory used
IMalloc * imalloc = 0;
if (SUCCEEDED(SHGetMalloc(&imalloc)))
{
imalloc->Free(pidl);
imalloc->Release();
}
strcpy(g_sDefaultDir, path);
return 0;
}
}
but when compiling I'm getting this error message
1>C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Include\shobjidl.h(17624): error C2061: syntax error : identifier 'IXMLDOMDocument'
This is my configuration:
I'm running VS2010 solution on VS2013
Use Standard Windows Libraries
Not Using ATL
and Use Multi-Byte character set
Any ideas?
I found 2 ways to answer solve my problem.
I had msxml and ISoftDistExt previously defined to solve ambiguity problem, so I had to #undef them like the following:
#undef __msxml_h__
#undef __ISoftDistExt_INTERFACE_DEFINED__
#include <MsXml.h>
#include <ShlObj.h>
Also, you can use the #import statement like the follownig
#undef __msxml_h__
#undef __ISoftDistExt_INTERFACE_DEFINED__
#import <msxml6.dll>
using namespace MSXML2;
#include <ShlObj.h>
Hope this will help someone later.
I have a similar problem to this:
Current working directory is visual studio directory
Except that I am working with a C++ project in Visual Studio. Any suggestions?
For example if I try the solution in the following post:
GetCurrentDirectory for startup App. c++
I get this:
"C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 11.0\COMMON7\IDE"
But I want it to be the Debug folder under my project/solution folders.
Using the _fullpath command allowed me to extract the current directory. For example you can modify the example code on the linked page :
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <direct.h>
void PrintFullPath( char * partialPath )
{
char full[_MAX_PATH];
if( _fullpath( full, partialPath, _MAX_PATH ) != NULL )
printf( "Full path is: %s\n", full );
else
printf( "Invalid path\n" );
}
int main( void )
{
// Get current directory
PrintFullPath( ".\\" );
}