error C2995: 'getVector' : template function has already been defined - c++

I am using VC 6.0 and While compiling the code i am getting this error "error C2995: 'getVector' : template function has already been defined"
I have included the value of WIN32COMMON in the project Settings->C++ tab and in the
category combo box as Preprocessor and in the preprocessordefinition text box as _WIN32COMMON and in the Addition include Libraries text box the complete path as "E:\app\user\product\11.1.0\db_1\OCI\include". in this include folder all the header files are present such as "occi.h".
I also tried with defining WIN32COMMON in my code Explicitly as follows
#include<iostream>
#define WIN32COMMON
#include <occi.h>
using namespace oracle::occi;
using namespace std;
but then it started me giving 102 errors stating that 'DbManager undeclared identifier'.
i had also tried with including the addition libraries in the project settings->link tab->
and in category combobox i selected Input and in the Additional library path i gave the complete path for .lib files as "E:\app\user\product\11.1.0\db_1\OCI\lib\MSVC\vc8" but that also did'nt work. can somebody please guide me.Where iam lacking or i need to define some thing else in my code.

MSVC++ 6.0 doesn't support partial ordering of function templates. Try to replace getVector() with getVectorOfRefs() in your code.
Oracle added getVectorOfRefs() into OCCI to support older Microsoft compilers, such as MSVC6, and recommends to use it in place of getVector().

Related

'optional': is not a member of 'std' in Visual Studio

The code I am writing is throwing this error:
'optional': is not a member of 'std'
I understand that the file <optional> is located in MSVC/tools and this external dependencies section is usually populated by Intellisense, but the file appears not to be included even though I confirmed that the file does indeed exist and I have #include <optional>.
What is the best way to close the gap here?
Is there a way to tell Visual Studio to include all the MSVC tools?
Code snippet from header:
#pragma once
#include Examples.h
#include <optional>
#include <vector>
namespace Samples
Code snippet from cpp:
#include 'Examples.h'
std::optional<Samples::Matrix> Samples::TestFunction()
You must have your C++ Language Standard option in Project Settings set to C++17 or later:
Right-Click on the project in the Solution Explorer
Select Properties
Under Configuration Properties > General > C++ Language Standard
Select ISO C++17 Standard (/std:c++17) or Preview Latest (/std:latest)
Future readers: ISO C++20 Standard (/std:c++20) is also an option.
Click OK
Save All to save the changes to the project.

C++ an VS error: <experimental/filesystem> header providing std::experimental::filesystem is deprecated by Microsoft and will be REMOVED

I coded in C++ on Visual Studio (Windows 10) and got this error:
#error The <experimental/filesystem> header providing std::experimental::filesystem is deprecated by Microsoft \
and will be REMOVED. It is superseded by the C++17 <filesystem> header providing std::filesystem. \
You can define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING to acknowledge that you have received this warning.
With this headers:
#include <iostream>
#include <fstream>
#include <string>
#include <windows.h>
#include <filesystem>//If I will disable it nothing happens.
#include <experimental/filesystem> //If I will disable it happens another error.
namespace fs = std::experimental::filesystem;
using namespace std;
I've tried: #define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING in the main cpp file. It didnt help.
So then I paste this code from here:
#ifdef __cpp_lib_filesystem
#include <filesystem>
using fs = std::filesystem;
#elif __cpp_lib_experimental_filesystem
#include <experimental/filesystem>
using fs = std::experimental::filesystem;
#else
#error "no filesystem support ='("
#endif
Didn't helped too.
What is the easiest way to get out that error?
Add _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING to Preprocessor definitions.
Project -> Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions.
This solved the issue for me.
According to the link
C++17’s is supported. This is a completely new
implementation, incompatible with the previous std::experimental
version, necessitated by symlink support, bug fixes, and changes in
standard-required behavior. Currently, including provides
the new std::filesystem and the previous
std::experimental::filesystem, and including
provides only the old experimental implementation. The experimental
implementation will be REMOVED in the next ABI-breaking release of the
libraries.
MS abandoned 'experimental' in filesystem.
You could try to use #include <filesystem>instead of #include <experimental/filesystem> and the std::experimental::filesystem is slated for removal, this means you should use std::filesystem.
I had the same problem and then, when I removed the experimental filesystem and added:
#include <filesystem>
namespace fs = std::filesystem;
I would get the error:
namespace “std” has no member “filesystem”
The solution was to go to project properties and do as instructed in the link.
VS2017: E0135 namespace "std" has no member "filesystem"
Adding the define where necessary worked for me:
#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING 1;
ie.
#ifdef __cpp_lib_filesystem
#include <filesystem>
namespace fs = std::filesystem;
#elif __cpp_lib_experimental_filesystem
#define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING 1;
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
#else
#error "no filesystem support ='("
#endif
I've been researching this same problem for weeks, and I'm using visual studio 2019 on an Unreal Engine 4 project. It's difficult to enable c++17 headers in visual studio and make them work. A lot of people online suggests using the boost library instead, but this is my attempt in using filesystem because I don't want to deal with trying to download / import external libraries, and so here's what I know...
** Before you start coding in visual studio, you should build / compile your project and see if Visual Studios needs anything set up; for me, I had to download / setup a free license with Incredibuild (there are tutorials online if someone needs to get this setup). Incredibuild is helpful and necessary to build projects in Visual Studio (at least if you're using Unreal Engine 4), but sometimes I get 1 or 2 "errors" in visual studio, but will compile in Unreal Engine 4 because those errors aren't actually errors (people say online that Incredibuild is weird, and wanted to mention that)**
1) How to enable c++17 Headers
When trying to #include which is a c++ version 17 header, it's necessary to enable c++17: Look inside the visual studio "solution explorer" to view the project files, and right-click the project itself and open "properties". Go to the "C/C++ language" tab and switch the version to c++17 (this is easy to find this online). Unless you're doing an Unreal Engine project because there is not a "C/C++ language" tab, so instead find the "NMake" tab and in the text-box to the right of "Addition Options" type in:
/std:c++17 OR /std:c++latest (Microsoft has a list I found online of others, but these are fine)
and visual studios will recognize as a header.
2) How NOT to get c++17 namespaces to work (things I've tried)
After the headers start working you can try to finally make a namespace variable:
namespace fs = std::filesystem; => ERROR: 'std does not have a namespace or class filesystem'
OR if you also #include you can try:
namespace fs = std::experimental::filesystem; OR namespace fs = std::experimental::filesystem::v1; => ERROR: 'we want you to define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING'
how does one fix these errors?
Online, I found that adding these lines of code to your ProjectName.Build.cs file (which can be found and edited after clicking on the file in "solution explorer") instead of the original declaration for PCHUsage:
PCHUsage = PCHUsageMode.NoSharedPCHs; PrivatePCHHeaderFile = "Folder.h"; CppStandard = CppStandardVersion.Cpp17;
this did get rid of the Errors when using std::filesystem BUT caused wayyyy more problems, and seemed harmful. After looking through other websites / possible solutions, it seems people online don't know how to actually use the filesystem library in visual studio, I've been looking for working code for weeks.
if you want to try and use the std::experimental::filesystem or std::experimental::filesystem::v1, I tried #define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING, but no dice.
I'm in the same boat as you man, and it looks like you didn't get much help from the previous comments. If we can't find a solution / video tutorial online, I have a plan B. Maybe we could try and write a c++17 project using some different software, or maybe we could write a program using a different software that could be launched instead of enabling c++17 into Visual Studio; for example, if you wanted to list the files in a directory, make an executable file in your preferred other software, and launch that executable / feed it arguments from your visual studio project. That's the best I got man. I hope that sparks some creativity or whatever, but I think it's a lot more helpful than what I've seen online. Good luck to you! and I need that luck too

Visual C++ : XGBoost does not work when called from a DLL

I have a requirement to use XGBoost within a Visual C++ project DLL.
I have been able to download and build the XGBoost source using VC++ and CMake.
When I include the XGBoost code in a test console application, it works fine.
However, when I try to replicate what I've done with the console application in a DLL project, it won't compile.
I am struggling to even use a basic XGBoost type within the project.
I suspect the problem is my ignorance with DLL projects and would appreciate your help.
Here's what's happening in my DLL project:
When I use the following include as the very first line in a cpp class file, it compiles:
#include <xgboost\c_api.h>
With it compiling, if I try to use a simple type defined in this include file, the build fails with the following message:
...\dll_test\xgb_driver.cpp(20): error C2065: 'BoosterHandle': undeclared identifier
This is the line that causes the error:
BoosterHandle my_handle;
"BoosterHandle" is in fact defined in <xgboost\c_api.h>
When I put the include below any other include, I get the following error messages:
1>c:\tools\src\xgboost\include\xgboost\c_api.h(29): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\tools\src\xgboost\include\xgboost\c_api.h(29): error C2146: syntax error: missing ';' before identifier 'bst_ulong'
Below is a little more information on what I did to get XGBoost working with a console app and how I created the DLL project.
=-=-=-=-=-=
Here's what I did to use XGBoost with a console. Everything about it seems to work. I've tested the model predictions, and they are
consistent with what I'm seeing in R.
Using the documentation found here:
https://xgboost.readthedocs.io/en/latest/build.html
I downloaded the XGBoost source and built it using CMake and Visual Studio 2015.
Under Project > Linker > Input > Additional Dependencies,
I added the xgboost.lib file
Under Project > Linker > General > Additional Library Directories
I added a reference to ...\xgboost\build\Release
Under Project > VC++ Directories > Include Directories
I added the path to ...\xgboost\rabit\include and ...\xgboost\include
I put the xgboost.dll in the directory where the .exe is generated.
From here, it was smooth sailing.
=-=-=-=-=-=
Here's what I've done to create a Visual C++ DLL Project:
After choosing File > New > Project, I select an ATL DLL Project (this is part of the project requirement).
For the XGBoost include to the project, I repeated steps 1-5 above, but placed the xgboost.dll file where the
project DLL would be generated.
Here is the source for the header file for the simple class I have created:
#pragma once
class XGB_Driver
{
public:
XGB_Driver();
~XGB_Driver();
float callXGB(float sample_input);
};
Here is the source for the simple cpp file:
#include <xgboost/c_api.h>
#include "stdafx.h"
#include "XGB_Driver.h"
XGB_Driver::XGB_Driver()
{
}
XGB_Driver::~XGB_Driver()
{
}
float XGB_Driver::callXGB(float simple_input) {
BoosterHandle my_handle;
return(0);
}
Why this doesn't work for the ATL DLL project, but does for the console app really has me banging my head against the keyboard.
Your help would be very much appreciated.
Best,
Dave
With the help of CristiFati, I believe this question has been answered.
For whatever reason, it seems that using XGBoost with C++ in a DLL project requires additional includes above and beyond what is required for using it in a console application.
I am currently building the DLL project with the addition of:
#include <cstdint>

error C2976: 'std::tr1::array' : too few template arguments in MS C++ express 2010

I'm working on a Windows forms project in C++ Express 2010. Made some changes to the the Form.h and now get an error when compiling the program. Note the compiler suggests the error is in the main program - open gl test 2 - that #includes the form. All compiled fine for days as I developed the code, then changed something last night and now I get the error.
The main program in open gl test 2 is identical to that of any other forms based project I have created - I've compared to check [except for the obvious changes of namespace etc cause its a different project]
// open gl test 2.cpp : main project file.
#include "stdafx.h"
#include "Form1.h"
using namespace opengltest2;
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
// Create the main window and run it
Application::Run(gcnew Form1());
return 0;
}
The error is:
1>open gl test 2.cpp(9): error C2976: 'std::tr1::array' : too few template arguments
1> D:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\array(18) : see declaration of 'std::tr1::array'
1>open gl test 2.cpp(9): error C3699: '^' : cannot use this indirection on type 'std::tr1::array'
1> compiler replacing '^' with '*' to continue parsing
line that compiler is complaining about is
int main(array<System::String ^> ^args)
So the fault cant be in where the compiler claims it is - and I can not find a fault in the code in the included files - they compile correctly. I assume the error MUST be in form.h cause that's what I modified that causes this error, but I can not see it. And I'm pretty sure I did not change some project settings.
I ain't including the code for form1.h cause it's toooooo long. Guess what I'm looking for is peoples experience of searching for the error. What strategies can I use to resolve this? If I had hair to pull out I would be surrounded by it. Please help me save my non-existant hair.
It looks like the compiler is getting confused between the managed array type and the array type in the std library. This is probably because somewhere you're doing using namespace std - you should ideally explicitly reference the correct namespace (std::array or cli::array), or remove the include of <array> if it's not needed.
Note that the constant size std::array isn't suitable for use with command-line arguments - you'd need to use a variable size container like cli::array anyway.

How to use Directory.GetFiles

I want to use Directory.GetFiles to read files from a folder. From msdn website i found:
For c, i have include:
using System;
using System.IO;
For C++, i have include:
#using <mscorlib.dll>
using namespace System;
using namespace System::IO;
as header.
For the C++, after the line #using is added, the "fatal error C1190: managed targeted code requires a '/clr' option" appears. So i tried by adding /clr in the visual studio Properties\Linker\Command Line as i found it in other website, but i fail too.
I did it wrongly. So, How to handle error of "fatal error C1190: managed targeted code requires a '/clr' option"? How to "compile with the /clr flag"?
Because i am writing for OpenCv, i have include the following additional dependencies in order to use c and c++:
cv210d.lib
cxcore210d.lib
highgui210d.lib
cvaux210d.lib
Cannot work. What other requirements in order to use Directory.GetFiles?
I also cannot use foreach even i #include .
Is there something similar to use foreach and Directory.GetFiles which is necessary to be included in a project?
I am using Visual Studio 2008
Please help me. Tq
You need to create managed c++ CLI, this should include all the flags for you.
To set /clr from visual studio, go to porject properities->configurations properities->general set common language runtime support to /clr