Visual Studio 2013 crashes when compiling Sqlite C++ library - c++

I'm having an absolute nightmare of a time trying to get the Sqlite C++ library to compile in Visual Studio 2013 Ultimate (Compiles fine in VS2012).
Basically regardless of whether I try to perform a clean or a rebuild VS will claim to successfully finish but will subsequently freeze and become unresponsive, never to recover.
Here is the output
and here is the actual VS project.
Anyone care to give it a crack and see if they are running into the same problem or provide any suggestions?

Tim Heuer gives step by step instructions ON THIS LINK. The batch files are hardcoded for TCL 8.5, you'll save yourself some time if you don't download the latest (8.6)
EDITED - I successfully compiled SQLite with Tim's steps (I just reinstalled Windows 8.1 / VS 2013). Note: the only issue I encountered was taking the steps to literally, be sure to change into the newly created SQLite directory before running the fossil command.
FYI for WinRT, be sure to use the correct path, if you just specify the filename you will get an access denied error (which will surface as a "cannot open database" error).
using namespace Windows::Storage;
using namespace std;
void SqliteWrapper::RunTest(void)
{
sqlite3 *db;
int rc;
auto path = ApplicationData::Current->LocalFolder->Path+"\\MyDatabase.db";
string dataPath(path->Begin(), path->End());
rc = sqlite3_open(dataPath.c_str(), &db);
if( rc ){
fprintf(stderr, "Can't open database: %s\n", sqlite3_errmsg(db));
sqlite3_close(db);
}
sqlite3_close(db);
}

Related

Save a file and make the console not to close: Visual Studio 2019

I am new to C++ and I am using the free version of Microsoft Visual Studio 2019.
I have written a small code which I use to integrate some differential equations (by using odeint libraries provided by Boost).
After the integration process ends, the time evolutions of the state variables are stored in the matrix mat (I use the Eigen libraries to define it row by row):
MatrixXd mat(t,4);
for (int i = 0; i <= t-1; i++)
{
mat.row(i) << times[i], x_vec[i][0], x_vec[i][1], x_vec[i][2] ;
};
Then I save the content of the matrix in a .txt file:
ofstream file("mat_save.txt");
if (file.is_open())
{ file << mat << '\n'; }
file.close();
However the .txt file is created only if I run the code in Debug mode, while if I only compile it the file is no longer created and no output can be displayed in the Console, since it is only opened when Debug mode is chosen.
Is there a way to make the Console appear and remain open and also to make the .txt file to be successfully saved, simply "compiling" the code avoiding debugging?
If so, I would save lot of time because the debugging is quite slow.
Thanks in advance!!
I'm not sure if by debug you mean running the code in Visual Studio vs compiling and then running the created exe. It Kind of sounds like a relative path issue.
Try using a full path. Or try opening a command prompt, cding to the path with the exe and then running it and check to see if the file is created in the folder you cded to.
You can also try opening the exe in Visual Studio like it was a project. Another thing to try is attaching VS to a running process to debug: http://msdn.microsoft.com/en-us/library/c6wf8e4z.aspx
The Windows Powertool "Handle" can display what handles a process is currently using which could be useful in determining if it is writing a file somewhere unexpected: https://learn.microsoft.com/en-us/sysinternals/downloads/handle

It shows error message Cannot create OCI environment in my Visual c++

I am using Microsoft Visualstudio2015, i am trying to run c++ program using OCI functions, but my program terminating.
I set ocilib path in my visual studio and it starting successfully, but i got message initialising failed in my log file
#include "ocilib.h"
ofstream LogFile;
LogFile.open("logfile.txt");
void err_handler(OCI_Error *err)
{
if(OCI_ErrorGetType(err) == OCI_ERR_ORACLE)
{
const mtext* sql =OCI_GetSql(OCI_ErrorGetStatement(err));
if(sql != NULL)
{
LogFile<<"ERROR - SQL : "<<sql<<"\n";
}
}
LogFile<<"ERROR - MSG : "<<OCI_ErrorGetString(err)<<endl;
++nbr_error;
}
if(!OCI_Initialize(err_handler, NULL, OCI_ENV_DEFAULT))
{
LogFile<<"ERROR - Initialise failed\n";
exit(1);
}
After running the program It shows ERROR - MSG: Cannot create OCI environment Program terminating,
what i supposed to do.
Download instantclient-basic and instantclient-sdk-windows from http://www.oracle.com/technetwork/cn/topics/winsoft-085727.html.
You should choose the x86 or the x64 version based on your program.
And then decompress and merge them to one folder.
In your program,
OCI_Initialize(err_handler, the_folder, OCI_ENV_DEFAULT)
Re-check your OCILIB path in Environment variables,
for example:-
Copy ocilib\include\ocilib.h : to a folder listed in the compiler headers folders
Copy ocilib\lib32 |64\ocilib [x].Lib : to a folder listed in the linker libraries folders
Copy ocilib\lib32|64\ocilib [x]. Dll : to a folder included in the PATH environment variable

OCCI app crashes when running in debug mode in Visual Studio 2005

I'm attempting to get a development environment up and running for developing applications with Oracle C++ Call Interface (OCCI) in Visual Studio 2005.
My system specs are:
OS: Windows 7, 64-bit
Oracle: 11g release 11.2.0.2, 32-bit
Instant Client: BasicLite and SDK version 11.2.0.4 32-bit
Visual Studio 2005 Professional Edition version 8.0 with 32-bit tools enabled
I've followed this guide by Mark Williams and I got the example running but only in release mode. When I switch to debug mode the app will build, but when I run it I get the following error:
Problem signature:
Problem Event Name: APPCRASH
Application Name: OCCITest.exe
Application Version: 0.0.0.0
Application Timestamp: 53f5dfdd
Fault Module Name: KERNELBASE.dll
Fault Module Version: 6.1.7601.18229
The small example program that triggers this error is:
#include "employees.h"
using namespace std;
using namespace oracle::occi;
int main (void)
{
Employees *pEmployees = new Employees();
delete pEmployees;
return 0;
}
Employees::Employees()
{
user = "hr";
passwd = "hr";
db = "localhost:1521/service_name";
env = Environment::createEnvironment(Environment::DEFAULT);
try
{
con = env->createConnection(user, passwd, db);
}
catch (SQLException& ex)
{
cout << ex.getMessage();
exit(EXIT_FAILURE);
}
}
Employees::~Employees()
{
env->terminateConnection (con);
Environment::terminateEnvironment (env);
}
If I remove all calls to OCCI functionality the application doesn’t crash. That is, this program runs error-free:
#include "employees.h"
using namespace std;
using namespace oracle::occi;
int main (void)
{
Employees *pEmployees = new Employees();
delete pEmployees;
return 0;
}
Employees::Employees()
{
user = "hr";
passwd = "hr";
db = "localhost:1521/service_name";
cout<<"Look at me, I'm running"<<endl;
}
Employees::~Employees()
{}
In the guide Mark mentions that when running in debug mode, the linker should use the library file oraocci11d.lib. However, this file is not included in the Instant Client SDK version 11.2.0.4, so I’m using the input file oraocci11.lib for both the release and debug version.
I'm running out of ideas about how to proceed in solving this problem, and I would greatly appreciate any and all help.
If the Oracle DLL receives and/or passes objects such as std::string or any other object that either:
Manipulates the heap in any way, or
The objects could have differing internals between app and DLL,
then you have no choice but to use the correct library to link with. Otherwise you wind up with binary or heap incompatible objects being passed, which leads to what you're seeing now.
See here: http://docs.oracle.com/cd/E11882_01/appdev.112/e10764/install.htm#CBHGBBJI
The link above mentions both the debug import library and debug version of the DLL. Also this is stated at the link:
Applications that link to MSVCRTD.DLL, a debug version of Microsoft C-Runtime, /MDd compiler flag, should link with these specific OCCI libraries: oraocci11d.lib and oraocci11d.dll.
Since it took me quite some time to get the debug environment working I figured I'd answer my own question now that I did.
I got a variety of errors throughout the ordeal, but the error that I got most stuck on was an error saying:
'The application was unable to start correctly (0xc0150002).
Click OK to close the application.'
Also, I used http://www.dependencywalker.com which repeatedly told me that either oraocci11d.dll or a the following list of dll's could not be found.
API-MS-WIN-APPMODEL-RUNTIME-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-ERROR-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-ROBUFFER-L1-1-0.DLL
API-MS-WIN-CORE-WINRT-STRING-L1-1-0.DLL
API-MS-WIN-SHCORE-SCALING-L1-1-1.DLL
DCOMP.DLL
IESHIMS.DLL
However, what was really missing was for the executable to be able to find oci.dll. I'm just mentioning the errors in case someone else runs into these.
Here is what was needed to make it work:
First of all, the Instant Client does not contain the oraocci11d.lib or oraocci11d.dll, so it is necessary to install the full Oracle Client.
Next, the following must be added to the PATH:
C:\Program Files\Oracle\11.2.0\OCI\lib\MSVC\vc8
C:\Program Files\Oracle\11.2.0\BIN
In Visual Studio, select Tools -> Options, unfold 'Projects and Solutions' and select VC++ Directories. In 'Show directories for' under:
Include Files add C:\Program Files\Oracle\11.2.0\OCI\include
Library files add C:\Program Files\Oracle\11.2.0\OCI\lib\MSVC\vc8
In the property page for your project under Configuration Properties -> Linker select Input and under Additional Dependencies add oraocci11d.lib (or oraocci11.lib for release mode). Then select debug/release mode in the Configuration Manager
I have a related problem in that I am successfully using oraocci12d.dll/msvcr100d.dll, but this in turn is using oci.dll/msvcr100.dll. ie, oci.dll is not using the debug version of msvcr100.
My program seems to run okay, but any memory leak reporting disappears on exit.

how to create FoxPro dbf files from c++?

I need to read a FoxPro Dbf File and recreate same in c++; I installed foxpro driver version 9.0 but it did not appeared in driver list in windows DSN. I then installed foxpro from visual studio 6 setup and that showed the driver there and I was able to make connection using it through ADO .Problem is that
_ConnectionPtr m_pCon;
_RecordsetPtr m_pRecordset;
AfxOleInit();
_bstr_t bt1(PassedCstringDirectory);//PassedCstringDirectory passed as argument
_bstr_t bt(sqlcmd);//sqlcmd passed as argument
m_pCon.CreateInstance(__uuidof(Connection));
HRESULT hr;
VARIANT *rowseffected=NULL;
try
{
//The SourceDB should be a proper directory
hr=m_pCon->Open("Provider=VFPOLEDB; SourceType=DBF; "
"SourceDB="+bt1+";Extended Properties=FoxPro 3.0;", "","",adModeUnknown);
}
catch(_com_error e)
{
AfxMessageBox("Connection failed, check the direction!");
}
m_pCon->Execute(bt,rowseffected,adConnectUnspecified);
m_pCon->Execute() is returning false(S_FALSE) but files (dbf and fpt) are being created .and i am not able to insert data into files .error being ."Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype."

CascadeClassifier.load() error in release only

I want to ask about cascadeclassfier load doesn't work in release.
I using Microsoft Visual Studio 2010 and OpenCV 2.4.7.
my code:
CascadeClassifier cascade;
if(!cascade.load("D:/data/training.xml"))
{
printf("Error load XML!\n");
return -1;
}
Things i've tried so far:
Tried to specify the path manually using ""
Tried to use / or \ in the path
Tried to give user permission
Tried to call the xml without using absolute path
Tried to use many kind of codes i've found when searching this error
Tried to seperate the xml by creating a new folder for them
Additional Information:
Running in debug mode work 100% perfectly
Running in release while using visual studio trigger a break
Running using the exe created while building only show "Error load XML!"
i really confused right now, so i decided to ask..
Thanks before.
I've had similar problems when switch from Debug to Release Mode. I had copy config from Debug to Release and mistake at Linker > Input > Additional Dependencies. And I had fix this problem by using opencv_world320d.lib for Debug mode and opencv_world320.lib for Release mode.