Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22151

How to add gcc include directory to existing Makefile

$
0
0

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.oCC = g++DEBUG = -gSQLAPI=/home/developer/Desktop/ARC_DEVELOPER/user123/testsql/SQLAPICFLAGS = -I${SQLAPI}/include -Wall -c $(DEBUG)LFLAGS = -Wall $(DEBUG)testql: $(OBJS)    $(CC) $(LFLAGS) $(OBJS) -o testqlclean:    rm -f testql *.o *~ core

When I run the code below I get the error:

[developer@localhost testql]$ makeg++    -c -o testql.o testql.cpptestql.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 -ltotal 12-rw-rw-r--. 1 developer developer  286 Mar  3 12:47 Makefiledrwxr-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.hSQLAPI/include/SQLAPI.h

code...

 #include <stdio.h>  // for printf  #include <SQLAPI.h> // main SQLAPI++ headerint main(int argc, char* argv[]){SAConnection con; // create connection objecttry{    // 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;}

Viewing all articles
Browse latest Browse all 22151

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>