none
#include < header file >

    Question

  • Hi

    I've a very basic issue but its baffling me.I'm using VS 2010 in a Windows environment and using c++/cli. The program I'm writing compiles fine with the line:

    #include "sqlite3/sqlite3.h"

    where I've got sqlite3 stored on C: drive in a sqlite3 folder. It doesn't have to be there just is at the moment.

    My problem is I want to add some header files from a sqlite wrapper from another source [ I'll call them a.h, b.h etc ].

    Each header file has #include <sqlite3.h> and generates an error on compilation: "No such file or directory".

    How can I get round this please?

    Thursday, November 01, 2012 11:07 PM

Answers

  • Well, there's some subtle difference between #include <> vs #include ""

    but if you specify the include directory it should work. Check again what you've entered where.

    --pa

    • Marked as answer by nz556 Friday, November 02, 2012 12:54 AM
    Friday, November 02, 2012 12:29 AM

All replies

  • nz556 wrote:

    My problem is I want to add some header files from a sqlite wrapper  from another source [ I'll call them a.h, b.h etc ].

    Each header file has #include <sqlite3.h> and generates an error on  compilation: "No such file or directory".

    How can I get round this please?

    Project | Properties | C/C++ | General | Additional Include Directories.


    Igor Tandetnik

    Thursday, November 01, 2012 11:21 PM
  • HI Igor

    I'm a little confused still.

    My interpretation of the error message from the headers [ a.h, b.h etc ] that have #include <sqlite3.h>  [ message =  fatal error C1083: Cannot open include file: 'sqlite3.h': No such file or directory ] means the headers can't find sqlite.h.

    Yet, I've already done the following: project | Properties | c/c++ | General | Additional Include Directories and specified c:\sqlite3\include which contains sqlite3.h

    Does that make sense?

    Friday, November 02, 2012 12:17 AM
  • Well, there's some subtle difference between #include <> vs #include ""

    but if you specify the include directory it should work. Check again what you've entered where.

    --pa

    • Marked as answer by nz556 Friday, November 02, 2012 12:54 AM
    Friday, November 02, 2012 12:29 AM
  • My additional directories shows: C:\sqlite3\lib;c:\sqlite3\include.

    Had a thought:

    sqlite3.h is actually contained in a subdirectory of c:\sqlite3\include called sqlite3 so I modified my additional directory listing to be:

    C:\sqlite3\lib;c:\sqlite3\include\sqlite3

    and all worked. I'd been assuming a search would be taken of subdirectories but that isn't the case apparently.

    Thanks for the responses

    Friday, November 02, 2012 12:54 AM
  • nz556 wrote:

    Yet, I've already done the following: project | Properties | c/c++ |  General | Additional Include Directories and specified
    c:\sqlite3\include which contains sqlite3.h

    Earlier, you claimed that #include "sqlite3/sqlite3.h" works. This means  that you have sqlite3.h in a directory named sqlite3, not a directory  named include. So which way is it? Which directory is sqlite3.h really  in?


    Igor Tandetnik

    Friday, November 02, 2012 1:21 AM
  • nz556 wrote:

    I'd been assuming a search would be taken of subdirectories

    Which piece of documentation led you to this (erroneous) conclusion? Or  were you simply engaging in wishful thinking?


    Igor Tandetnik

    Friday, November 02, 2012 1:22 AM
  • Hi

    Sorry to take up your time:

    I'd misread information @: http://msdn.microsoft.com/en-us/library/36k2cdd4%28v=vs.100%29.aspx

    My apologies.

    Friday, November 02, 2012 1:35 AM
  • Hi

    Well I've read lots, made mistakes and eventually found what I needed. Thought I'd pass on my findings to help others:

    • http://www.tsjensen.com/blog/post/2011/06/04/SQLite+On+Visual+Studio+2010+Setup+Instructions.aspx is a must read
    • http://code.msdn.microsoft.com/CppUseADONET-f04f0806 is a good read and helped me lots
    • http://www.sqlite.org/lang_keywords.html reminds you that you can't have keywords in sqlite as field names in your DB

    After all that I came up with:

    	SQLiteConnection ^ conn = gcnew SQLiteConnection();
    	SQLiteTransaction ^ trans;
    	conn->ConnectionString = "Data Source="my.db";
    	conn->Open();
    	
    	// setup the transaction process
    	SQLiteCommand ^ cmd = gcnew SQLiteCommand();
    	trans = conn->BeginTransaction();
    	cmd->Connection		= conn;
    	cmd->Transaction	= trans;
    	
    	SQLiteParameter p_date;
    	SQLiteParameter p_fullname;
    	SQLiteParameter p_male;
    	SQLiteParameter p_group;
    	SQLiteParameter p_length;
    	SQLiteParameter p_points;
    	
    	cmd->CommandText	=  String::Format("INSERT INTO '{0}'	(Date, Fullname, Male, Classification, Length, Points) VALUES (?, ?, ?, ?, ?, ?)", race_type); // can't use Group as a field name
    	
    	// set up the six parameters
    	cmd->Parameters->Add( %p_date );
    	cmd->Parameters->Add( %p_fullname );
    	cmd->Parameters->Add( %p_male );
    	cmd->Parameters->Add( %p_group );
    	cmd->Parameters->Add( %p_length );
    	cmd->Parameters->Add( %p_points );
    
    	try
    		{	
    			p_date.Value		= "1/1/1900";
    			p_fullname.Value	= "name";
    			p_male.Value		= "Yes";
    			p_group.Value		= "group name";
    			p_length.Value		= "100m";
    			p_points.Value		= 20;
    
    			cmd->ExecuteNonQuery();
    		} catch (Exception ^e) {
    			MessageBox::Show("Error Executing SQL: " + e->ToString(), "Exception While Inserting Value Into table ...");
    		} 
    
    	trans->Commit();
    	conn->Close();
    This is some payment for all the help you guys have given me heaps of times - I hope.

    Sunday, November 11, 2012 9:19 AM