Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 08-10-2008, 10:27 PM   #1
LQ Newbie
Registered: Apr 2008
Posts: 3

Rep: Reputation: 0
Unhappy makefile example for sybase esql/c linux

hello does someone have a sample makefile for sybase esql/c on linux?

because I have a makefile but in HP unix and try to adjust it for linux environment but I get this error:

readIncoming: hidden symbol `stat' in /usr/lib/libc_nonshared.a(stat.oS) is referenced by DSO

this is my makefile:

OPTIONS=-g -p -Ae
MAKE = make CC=$CC AS="$(AS)" LD="$(LD)" AR="$(AR)" CPP="$(CPP)"
INCLUDE = -I. -I$${SYBASE}/OCS-12_5/include -I/usr/include
LIBFLAGS = -L$${SYBASE}/OCS-12_5/devlib
SYBLIBDIR= $${SYBASE}/OCS-12_5/devlib/
PRECOMP = $${SYBASE}/OCS-12_5/bin/cpre




all:clean readIncoming

readIncoming: readIncoming.o readIncomingDB.o sybesql.o
${LINK.c} -o$@ readIncoming.o readIncomingDB.o sybesql.o ${SCKLIBS}

sybesql.o :
cc -c $(CFLAGS) ${SYBASE}/OCS-12_5/include/sybesql.c -o $@

readIncomingDB.c: readIncomingDB.cp
case $${SYBPLATFORM} in \
sun4) \
*rs6000) \
*) \
esac ; \
$(PRECOMP) $${PRECOMPFLAGS} readIncomingDB.cp

rm -f *.o readIncomingDB.c


thank you for your help
Old 08-12-2008, 08:32 AM   #2
Senior Member
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060Reputation: 1060
I cannot specifically detail ESQL/C for Sybase (or, for that matter, PostgreSQL) but this is what I do for Makefiles for Informix (which is where ESQL/C comes from to begin with).

I've created a make.rules file that is included in every Makefile used to compiles ESQL/C programs; in Informix, the source code has an .ec file name extension, say, You may need to change a couple of things in the examples to have this work for your platform.

First off, you need to inform make about the file name suffixes that it needs to know about, in this case .ec and .ec~ (the second is for checking source out of SCCS and you may not care about that).

Secondly, you need to inform make how to compile (and, maybe, link and load) an object file from the source code file you're adding to make. For ESQL/C source files this looks like
#       esql/c language section
ESQL    =       esql
#       ESQL/C optimization flags
#               These are for Solaris
ECFLAGS =       -xarch=native64 -xO3 -xautopar -xbuiltin=%all
#               These are for GCC
ECFLAGS =       -O3

        $(GET) $(GFLAGS) $<
        $(ESQL) $(ECFLAGS) -s -o $@ $< $(LDFLAGS)
        -rm -f $*.ec $*.[co]

        $(ESQL) $(ECFLAGS) -s -o $@ $< $(LDFLAGS)
        -rm -f $*.[co]

        $(GET) $(GFLAGS) $<
        $(ESQL) $(ECFLAGS) -e $<
        $(CC) -I${INFORMIXDIR}/incl/esql $(ECFLAGS) -c $*.c
        -rm -f $*.ec $*.c

        $(ESQL) $(ECFLAGS) -e $<
        $(CC) -I${INFORMIXDIR}/incl/esql $(ECFLAGS) -c $*.c
        -rm -f $*.c

        $(GET) $(GFLAGS) $<
        $(ESQL) $(ECFLAGS) -e $<
        $(CC) -I${INFORMIXDIR}/incl/esql $(ECFLAGS) -c $*.c
        $(AR) $(ARFLAGS) $@ $*.o
        -rm -f $*.ec $*.[co]

        $(ESQL) $(ECFLAGS) -e $<
        $(CC) -I${INFORMIXDIR}/incl/esql $(ECFLAGS) -c $*.c
        $(AR) $(ARFLAGS) $@ $*.o
        -rm -f $*.[co]
Note in the above that ESQL is defined as esql, that is the actual name of the ESQL/C preprocessor (all ESQL/C does is preprocess your ESQL/C source code into C that can be compiled). On my systems, INFORMIXDIR is a defined environment variable and the subdirectories (etc, include, lib, etc.) of the Informix parent directory are defined in various places; specifically, the lib directory is appended to the LD_LIBRARY_PATH environment. You may want to follow this method or define the absolute path to the esql preprocessor (not, if you have it, esqlc which compiles to an executable -- we want esql to preprocess the source file and stop).

So, you'd probably want to edit this file, replacing INFORMIXDIR with, say, SYBASEDIR or whatever you've used to define the locating of Sybase' subdirectories on your systems.

Also, in these rules, there are tokens for ECFLAGS, LDFLAGS, and other values that you use as shorthand (so you don't have to type all this stuff over and over again in you Makefiles).

Now, what the heck do you do with this thing?

Here's a (really cut down) Makefile that uses these make.rules on a Linux system with Informix to build a "hello world" helloec program:
#ident  "$Id$

#       Name:           $Source$
#       Version:        $Revision$
#       Modified:       $Date$
#       Purpose:
#       Author:
#       Date:
#       $Log$

MAKEFILE =      Makefile

INSTALL_BASE    =       /usr/local


#       These are the rules for making Informix targets:
include $(BASDIR)/include/make.rules
#       Mess with them at your peril

CFLAGS  =       -O3 -I${BASDIR}/include

ECFLAGS =       -O3 -I${BASDIR}/include

LDFLAGS =       -L$(BASDIR)/lib -lutil -lm

MAINS   =       hello

OBJECTS =       hello.o


LCLINCS =       hello.h

ALL:            $(MAINS)

hello:          hello.o $(LIBRARY)
        $(ESQL) $(ECFLAGS) -s -o hello hello.o $(LDFLAGS)

hello.o:        hello.h

install:        $(MAINS)
        cp $(MAINS) $(BINDIR)
        cd $(BINDIR);\
        chown $(OWNER) $(MAINS);\
        chgrp $(GROUP) $(MAINS);\
        chmod $(BMASK) $(MAINS)
        cd $(BINDIR);\
        rm -f $(MAINS)
        rm -f $(OBJECTS)

        rm -f $(OBJECTS) $(MAINS)
You can download make.rules at and edit the environment variable INFORMIXDIR for your system (one would hope that Sybase is in somewhere like /opt/sybase and that the include and lib directories are located there and you can simple change INFORMIXDIR to something like SYBASEDIR[/I]...). Also, if you need additional CFLAGS or ECFLAGS edit those in make.rules.

I do hope that this helps rather than hurts -- just bear in mind that simple is better than complicated and this is a relatively painless way of having make build ESQL/C files from source. I've used this exact file for, oh, about 12 years now and it may work for you, too.

Last edited by tronayne; 08-12-2008 at 08:34 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux problem when installing sybase. cghcgh Linux - Software 1 06-25-2008 12:44 PM
sybase on linux sailu_mvn Linux - Software 6 08-24-2006 05:59 AM
LXer: Sybase to diversify portfolio to Linux, RFID LXer Syndicated Linux News 0 01-16-2006 07:01 PM
SYBASE Install on Linux Fedora 2 zum Linux - Software 1 05-18-2005 07:59 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:19 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration