make file problem
Posted in 2006
Topics: Installation, Setup & Upgrades, Connectivity: ODBC / JDBC / .NET
I am not v familiar with bash so please don't laugh at me! I am getting that horrible "undefined regerence to main..." when linking two objects, one of whick DOES have main defined. Could some kind soul look at the makefile below and tell me what I am doing wrong? Kate C=cc -m32 -B/usr/lib/i386-redhat-linux3E/lib/ INSTALLPATH=/usr/local EXTRALIBS=-lesrpc -lessupp -lesextra LDPATH=-L ${INSTALLPATH}/easysoft/lib -L${INSTALLPATH}/easysoft/oob/client -L${I NSTALLPATH}/easysoft/unixODBC/lib INCPATH=${INSTALLPATH}/easysoft/oob/client/include OBJS=readisam.o print_error.o CFLAGS=-g -I${INCPATH} all : print_error readisam readisamfile readisam: readisam.o ${CC} ${CFLAGS} -o readisam readisam.o ${LDPATH} \\ -lesoobclient ${EXTRALIBS} print_error: print_error.o ${CC} ${CFLAGS} -o print_errorprint_error.o ${LDPATH} \\ -lesoobclient ${EXTRALIBS} readisamfile: readisam.o print_error.o ${CC} ${CFLAGS} -o readisamfile ${OBJS) ${LDPATH} \\ -lodbc
On 2006-07-28, kjuliff@gmail.com wrote: > I am not v familiar with bash so please don't laugh at me! > > I am getting that horrible "undefined regerence to main..." when > linking two objects, one of whick DOES have main defined. Could some > kind soul look at the makefile below and tell me what I am doing wrong? You mean besides asking a makefile question in a bash group? <OT>"undefined reference to main" mean that you do not have a main() function defined in your .c files.</OT> > C=cc -m32 -B/usr/lib/i386-redhat-linux3E/lib/ > INSTALLPATH=/usr/local > > EXTRALIBS=-lesrpc -lessupp -lesextra > LDPATH=-L ${INSTALLPATH}/easysoft/lib > -L${INSTALLPATH}/easysoft/oob/client -L${I > NSTALLPATH}/easysoft/unixODBC/lib > INCPATH=${INSTALLPATH}/easysoft/oob/client/include > OBJS=readisam.o print_error.o > CFLAGS=-g -I${INCPATH} > > all : print_error readisam > readisamfile > > readisam: readisam.o > ${CC} ${CFLAGS} -o readisam readisam.o ${LDPATH} \\ > -lesoobclient ${EXTRALIBS} > > print_error: print_error.o > ${CC} ${CFLAGS} -o print_errorprint_error.o ${LDPATH} \\ > -lesoobclient ${EXTRALIBS} > > readisamfile: readisam.o print_error.o > ${CC} ${CFLAGS} -o readisamfile ${OBJS) ${LDPATH} \\ > -lodbc > -- Chris F.A. Johnson <http://cfaj.freeshell.org> =================================================================== Author: Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
> You mean besides asking a makefile question in a bash group? > > <OT>"undefined reference to main" mean that you do not have a > main() function defined in your .c files.</OT> > I KNOW what it means. The question is why is it happening. And of course I have a main function - it is in readisam.c The message about main can occur if one's makefile is in error. And as I cannot see the error I posted for help. > =================================================================== > Author: > Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
kjuliff@gmail.com wrote: > I am not v familiar with bash so please don't laugh at me! > > I am getting that horrible "undefined regerence to main..." when > linking two objects, one of whick DOES have main defined. Could some > kind soul look at the makefile below and tell me what I am doing wrong? > <snip> > all : print_error readisam > readisamfile > > readisam: readisam.o > ${CC} ${CFLAGS} -o readisam readisam.o ${LDPATH} \\ > -lesoobclient ${EXTRALIBS} > > print_error: print_error.o > ${CC} ${CFLAGS} -o print_error print_error.o ${LDPATH} \\ > -lesoobclient ${EXTRALIBS} make notices that all depends on print_error, so it looks to see how to build print_error--you've told it to execute: $(CC) $(CFLAGS) -o print_error print_error.o etc... It's trying to find a main reference in print_error.o, and you don't have one. I would suggest removing the dependency on print_error from the target 'all' and completely removing the rule to build the target print_error, since you don't ever want to build print_error. (You only want print_error.o) > > readisamfile: readisam.o print_error.o > ${CC} ${CFLAGS} -o readisamfile ${OBJS) ${LDPATH} \\ > -lodbc Note: this doesn't belong in a group on bash, or on informix databases.
On 28 Jul 2006 11:29:27 -0700, kjuliff@gmail.com <kjuliff@gmail.com> wrote: > > I am not v familiar with bash so please don't laugh at me! OK; but this has essentially nothing to with bash. I am getting that horrible "undefined regerence to main..." when > linking two objects, one of whick DOES have main defined. Could some > kind soul look at the makefile below and tell me what I am doing wrong? I'm going to guess what you're actually trying to do, and then explain why the makefile is wrong based on that assumption. If the assumption is off, the rest of the discussion is too. ASSUMPTION: You are trying to create a single executable 'readisamfile' from two object files, readisam.o and print_error.o. Formatting assumption - the makefile contained tabs and unfolded lines as appropriate. C=cc -m32 -B/usr/lib/i386-redhat-linux3E/lib/ > INSTALLPATH=/usr/local > > EXTRALIBS=-lesrpc -lessupp -lesextra > LDPATH=-L ${INSTALLPATH}/easysoft/lib > -L${INSTALLPATH}/easysoft/oob/client -L${I > NSTALLPATH}/easysoft/unixODBC/lib > INCPATH=${INSTALLPATH}/easysoft/oob/client/include > OBJS=readisam.o print_error.o > CFLAGS=-g -I${INCPATH} > > all : print_error readisam > readisamfile This says 'Build 3 programs' not 'Build 1 program'. Just list the one program you actually want to build - readisamfile. readisam: readisam.o > ${CC} ${CFLAGS} -o readisam readisam.o ${LDPATH} \\ > -lesoobclient ${EXTRALIBS} Delete this - readisam.o is not an object file that can be built into a program on its own (without print_error.o too). print_error: print_error.o > ${CC} ${CFLAGS} -o print_errorprint_error.o ${LDPATH} \\ > -lesoobclient ${EXTRALIBS} Delete this too - print_error.o is not an object file that can be built into a program on its own (without readisam.o too). readisamfile: readisam.o print_error.o > ${CC} ${CFLAGS} -o readisamfile ${OBJS) ${LDPATH} \\ > -lodbc This is almost fine - use ${OBJS} after the colon instead of the separate file names. That way, when you add a third object file to the list, you only need to change one place - the line that defines OBJS. Despite what some people said, this is not completely inappropriate as a question for c.d.i; Kate has been struggling for a while with integrating code to read C-ISAM files with ODBC code to access Informix databases. OTOH, if you weren't paying attention, it would be easy not to be aware of that... Maybe a leading comment such as "The latest stumbling block in the saga of how to get access to C-ISAM file and IDS databases follows:-"... -- Jonathan Leffler #include <disclaimer.h> Email: jleffler@earthlink.net, jleffler@us.ibm.com Guardian of DBD::Informix v2005.02 -- http://dbi.perl.org/