LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 08-10-2008, 10:27 PM   #1
hagdanan
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:

CXX=cc
LINKER=${CXX} -o
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/
CFLAGS = -g -DMD5=5 -DDEBUG $(INCLUDE) $(LIBFLAGS)
PRECOMP = $${SYBASE}/OCS-12_5/bin/cpre

MATHLIBS = -lm
SYBLIBS = \
$(SYBLIBDIR)libct.so\
$(SYBLIBDIR)libcs.so\
$(SYBLIBDIR)libcomn.so\
$(SYBLIBDIR)libsybtcl.so\
$(SYBLIBDIR)libintl.so

SCKLIBS = $(SYBLIBS) \
$(SYBLIBDIR)libinsck.so.12.5.0.1\
$(MATHLIBS)

LINK.c = ${CXX} $(INCLUDE) $(LIBFLAGS)

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) \
PRECOMPFLAGS="$(KRC_FLAGS)" export PRECOMPFLAGS ;; \
*rs6000) \
PRECOMPFLAGS="-l -m" export PRECOMPFLAGS ;; \
*) \
PRECOMPFLAGS="-m" export PRECOMPFLAGS ;; \
esac ; \
$(PRECOMP) $${PRECOMPFLAGS} readIncomingDB.cp

clean:
rm -f *.o readIncomingDB.c




---------------------------

thank you for your help
 
Old 08-12-2008, 08:32 AM   #2
tronayne
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, prog.ec. 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
Code:
#       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

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

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

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

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

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

.ec.a:
        $(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:
Code:
#ident  "$Id$

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

MAKEFILE =      Makefile

INSTALL_BASE    =       /usr/local

BASDIR  =       ${INSTALL_BASE}

#       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

SOURCES =       hello.ec

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)
remove:
        cd $(BINDIR);\
        rm -f $(MAINS)
clean:
        rm -f $(OBJECTS)

clobber:
        rm -f $(OBJECTS) $(MAINS)
You can download make.rules at http://ronayne.dyndns.org/downloads/make.rules 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.
 
  


Reply


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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

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