9 Replies - 3572 Views - Last Post: 07 February 2012 - 06:39 AM Rate Topic: -----

#1 saman_47  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 06-February 12

SQLAPI.h error: No such file or directory

Posted 06 February 2012 - 08:51 AM

I am trying to run a program connecting to sql server using SQLAPI++.
I have already added the include folder inside SQLAPI to my ldconf file.
but still when I am attempting to compile the code i receive the following error:

g++ connectDB.cpp -lsqlapi
connectDB.cpp:2:44: error: SQLAPI.h: No such file or directory
In file included from /usr/lib/gcc/i486-slackware-linux/4.2.4/../../../../include/c++/4.2.4/backward/iostream.h:31,
from connectDB.cpp:3:
/usr/lib/gcc/i486-slackware-linux/4.2.4/../../../../include/c++/4.2.4/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
connectDB.cpp: In function 'int main(int, char**)':
connectDB.cpp:8: error: 'SAConnection' was not declared in this scope
connectDB.cpp:8: error: expected `;' before 'con'
connectDB.cpp:16: error: 'con' was not declared in this scope
connectDB.cpp:20: error: 'SA_Oracle_Client' was not declared in this scope
connectDB.cpp:30: error: expected type-specifier before 'SAException'
connectDB.cpp:30: error: expected `)' before '&' token
connectDB.cpp:30: error: expected `{' before '&' token
connectDB.cpp:30: error: 'x' was not declared in this scope
connectDB.cpp:30: error: expected `;' before ')' token
connectDB.cpp:49: error: expected `}' at end of input



and the following is the code:

#include <stdio.h>  // for printf
#include <SQLAPI.h> // main SQLAPI++ header
#include <iostream.h>


int main(int argc, char* argv[])
{
    SAConnection con; // create connection object
    
    try
    {
        // connect to database
        // in this example it is Oracle,
        // but can also be Sybase, Informix, DB2
        // SQLServer, InterBase, SQLBase and ODBC
        con.Connect(
            "test",     // database name
            "tester",   // user name
            "tester",   // password
            SA_Oracle_Client);

        printf("We are connected!\n");

        // Disconnect is optional
        // autodisconnect will ocur in destructor if needed
        con.Disconnect();

        printf("We are disconnected!\n");
    }
    catch(SAException &x)
    {
        // SAConnection::Rollback()
        // can also throw an exception
        // (if a network error for example),
        // we will be ready
        try
        {
            // on error rollback changes
            con.Rollback();
        }
        catch(SAException &)
        {
        }
        // print error message
        printf("%s\n", (const char*)x.ErrText());
    }
    
    return 0;
}



any helps will be appreciable.

Your
Saman

Is This A Good Question/Topic? 0
  • +

Replies To: SQLAPI.h error: No such file or directory

#2 jimblumberg  Icon User is offline

  • member icon


Reputation: 4074
  • View blog
  • Posts: 12,568
  • Joined: 25-December 09

Re: SQLAPI.h error: No such file or directory

Posted 06 February 2012 - 08:57 AM

You need to add the -I switch to your compile line to tell the compiler the location of the SQLAPI.h header file. The other solution is to provide the complete path to this include file in the #include directive.

Jim
Was This Post Helpful? 1
  • +
  • -

#3 saman_47  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 06-February 12

Re: SQLAPI.h error: No such file or directory

Posted 06 February 2012 - 03:02 PM

View Postjimblumberg, on 06 February 2012 - 08:57 AM, said:

You need to add the -I switch to your compile line to tell the compiler the location of the SQLAPI.h header file. The other solution is to provide the complete path to this include file in the #include directive.

Jim


well i tried both of them, unfortunately non of them worked!. Let's go back to the early steps, I guess I need to compile the sqlapi library first before trying to add it to the shared libarary, if that's so give me more details. besides, there are a few number of g++ packages available in the sqlapi parent folder, shall I only go for a specific one?

By the way, I want you to run this program on your system and also lemme know about your library compiling steps. This way, I can understand where I am goin the wrong way.

Your
Saman
Was This Post Helpful? 0
  • +
  • -

#4 vividexstance  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 662
  • View blog
  • Posts: 2,273
  • Joined: 31-December 10

Re: SQLAPI.h error: No such file or directory

Posted 06 February 2012 - 03:50 PM

SAConnection could be defined inside a namespace, if it is you need to either qualify the name or use a "using declaration/directive". If you haven't installed the SQL library, then just go download the library and just read the README or INSTALL file that comes with the download(usually). On linux, it's usually only a few commands to compile and install the library. You just need to make sure you have all the required libraries that the library you're compiling needs. Example:

Quote

$> ./configure --prefix=/usr/ # put where you want to install the library
$> make
$> make install

Depending on your system and where you want to install the library, you might need to use the 'sudo' command.
Was This Post Helpful? 0
  • +
  • -

#5 jimblumberg  Icon User is offline

  • member icon


Reputation: 4074
  • View blog
  • Posts: 12,568
  • Joined: 25-December 09

Re: SQLAPI.h error: No such file or directory

Posted 06 February 2012 - 04:28 PM

Quote

well i tried both of them, unfortunately non of them worked!.

What did you try? Show the modified compile line. Where is SQLAPI.h located on your computer?

Quote

By the way, I want you to run this program on your system and also lemme know about your library compiling steps.

I don't think so. If you don't think you have he library compiled properly then you need to read the library documentation and fix your problem. If you are having problems compiling the library then you need to show how you are trying to compile this library, the complete name of the library, and show a link to where you got this library. You also need to state your operating system, including which distribution if applicable. Your compiler, compiler version, any error messages received when compiling etc..

Why are you using outdated include files:

Quote

In file included from /usr/lib/gcc/i486-slackware-linux/4.2.4/../../../../include/c++/4.2.4/backward/iostream.h:31,
from connectDB.cpp:3:
/usr/lib/gcc/i486-slackware-linux/4.2.4/../../../../include/c++/4.2.4/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>.


Read the above error message carefully and fix the problem. The iostream.h header file has been depreciated, use the correct header file.

Jim
Was This Post Helpful? 0
  • +
  • -

#6 saman_47  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 06-February 12

Re: SQLAPI.h error: No such file or directory

Posted 07 February 2012 - 12:47 AM

Well Jim

For the source I pasted above, I ran the followin commands:

 g++ -c -Wall -O2  -DNDEBUG -I/usr/lib/SQLAPI/include -o dbConnection.obj dbConnection.cpp 


 g++ dbConnection.obj -o dbConnection -L/usr/lib/SQLAPI/lib -s  -lsqlapi -lc -lm -lcrypt -ldl 


and finally exported the sqlapi.so path to my current shell shared library:

 export LD_LIBRARY_PATH=/usr/lib/SQLAPI/lib 


This time the code starts compiling, though I get the following error:

Quote

bash-3.1# ./dbConnection

libclntsh.so: cannot open shared object file: No such file or directory

DBMS API Library loading fails
This library is a part of DBMS client installation, not SQLAPI++
Make sure DBMS client is installed and
this required library is available for dynamic loading


well, you know, m pretty confused here, what's libclntsh.so for? as far as I know n checked, libclntsh.so is not in sqlapi.

any helps would be appreciable

Saman
Was This Post Helpful? 0
  • +
  • -

#7 saman_47  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 06-February 12

Re: SQLAPI.h error: No such file or directory

Posted 07 February 2012 - 12:55 AM

SQLServer is the DB of my concern. But, as I googled libclntsh.so is used for
Oracle DB connection!
besides, the functions used in the source code above support SQL Server, or kinda written for that only.
Was This Post Helpful? 0
  • +
  • -

#8 saman_47  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 06-February 12

Re: SQLAPI.h error: No such file or directory

Posted 07 February 2012 - 05:41 AM

View Postsaman_47, on 07 February 2012 - 12:55 AM, said:

SQLServer is the DB of my concern. But, as I googled libclntsh.so is used for
Oracle DB connection!
besides, the functions used in the source code above support SQL Server, or kinda written for that only.


Well, I found out what the problem was, seems I was giving the Oracle connection parameter in my source program.
the correct one should be SA_ODBC_CLIENT
Was This Post Helpful? 0
  • +
  • -

#9 saman_47  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 06-February 12

Re: SQLAPI.h error: No such file or directory

Posted 07 February 2012 - 05:52 AM

View Postsaman_47, on 07 February 2012 - 12:55 AM, said:

SQLServer is the DB of my concern. But, as I googled libclntsh.so is used for
Oracle DB connection!
besides, the functions used in the source code above support SQL Server, or kinda written for that only.


Well, I found out what the problem was, seems I was giving the Oracle connection parameter in my source program.
the correct one should be SA_ODBC_CLIENT which is for SQL Server connections.

You know, another story just started to play as soon as this bug was identified.

Quote

g++ -c -Wall -O2 -DNDEBUG -I/usr/lib/SQLAPI/include -o dbConnection.obj dbConnection.cpp
bash-3.1# g++ dbConnection.obj -o dbConnection -L/usr/lib/SQLAPI/lib -s -lsqlapi -lc -lm -lcrypt -ldl
bash-3.1# export LD_LIBRARY_PATH=/usr/lib/SQLAPI/lib
bash-3.1# ./dbConnection

libiodbc.so: cannot open shared object file: No such file or directory
libiodbc.so.3: cannot open shared object file: No such file or directory
libiodbc.so.2: cannot open shared object file: No such file or directory
libodbc.so: cannot open shared object file: No such file or directory
libodbc.so.1: cannot open shared object file: No such file or directory

DBMS API Library loading fails
This library is a part of DBMS client installation, not SQLAPI++
Make sure DBMS client is installed and
this required library is available for dynamic loading


You know, I think the SQLServer Driver is not included in the SQLAPI++. So, I think I need to install the unixODBC driver for SQLServer. You got the same idea?, moreover, if the case is right, I think m not gonna need SQLAPI++ anymore, as I guess, you know, the ODBC manager driver automatically supports SQL APIs.\

looking forward to hearing from you.
Saman
Was This Post Helpful? 0
  • +
  • -

#10 jimblumberg  Icon User is offline

  • member icon


Reputation: 4074
  • View blog
  • Posts: 12,568
  • Joined: 25-December 09

Re: SQLAPI.h error: No such file or directory

Posted 07 February 2012 - 06:39 AM

According to the SQLAPI++ Documentation you need the FreeTDS ODBC Driver in order to use SQLAPI++ on Linux with an MS-SQL database server. Make sure you use the proper TDS protocol to connect to this DB.

Jim
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1