I have a Makefile that I have copied and use in many small programs that I write in C for Linux. Sadly, I don't understand every detail of how it works and I typically just comment out the name of the output files and insert the name I want and it compiles my programs successfully. I would like to use these instructions:
Those with a command-line compiler will typically use options such as '/I%SQLAPIDIR%\include' or '-I${SQLAPIDIR}/include'. The header files are in the include subdirectory of SQLAPI++ distributions
so that my Makefile will add the libraries when it compiles. I checked this site and found the following links but they didn't help:
What are the GCC default include directories?
how to add a new files to existing makefile project
Adding an include directory to gcc *before* -I
My attempt at including the directory....
OBJS =  testql.o
CC = g++
DEBUG = -g
SQLAPI=/home/developer/Desktop/ARC_DEVELOPER/user123/testsql/SQLAPI
CFLAGS = -I${SQLAPI}/include -Wall -c $(DEBUG)
LFLAGS = -Wall $(DEBUG)
testql: $(OBJS)
    $(CC) $(LFLAGS) $(OBJS) -o testql
clean:
    rm -f testql *.o *~ core
When I run the code below I get the error:
[developer@localhost testql]$ make
g++    -c -o testql.o testql.cpp
testql.cpp:2:44: fatal error: SQLAPI.h: No such file or directory
#include <SQLAPI.h> // main SQLAPI++ header
The directory is as such:
[developer@localhost testql]$ ls -l
total 12
-rw-rw-r--. 1 developer developer  286 Mar  3 12:47 Makefile
drwxr-xr-x. 7 developer developer 4096 Oct 16 02:08 SQLAPI
-rw-rw-r--. 1 developer developer 1169 Mar  3 11:43 testql.cpp
And the SQLAPI directory is as such:
[developer@localhost testql]$ ls SQLAPI/include/SQLAPI.h
SQLAPI/include/SQLAPI.h
code...
 #include <stdio.h>  // for printf
  #include <SQLAPI.h> // main SQLAPI++ header
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;
}
 
     
     
     
    