Solved

Undefined symbols error

Posted on 1999-01-21
7
357 Views
Last Modified: 2010-04-15
Hello,
I'm trying to figure out a program that my predecesor (sp?) left behind and am having problems re-compiling it.
In the make file I have the following relevant lines:
OBJS3=cgicons.o lock.o web.o dbcore.o formatea.o
CC=gcc
CGIDEST = /netscape/ns-home/cgi-bin/cons
CRONDEST = /netscape/ns-home/cgi-bin
CGIBIN = cgicuota cgiauth cgiclave certmail planimail vantimail contmail visimail cgibenef cartmail actmail cgipen cgigvflt cgigvstr cgivigneta cgihome cgicons cginame

cgicons: $(OBJS3)
      $(CC) -g -o cgicons $(OBJS3)


And when I type "make cgicons" I get the following errors:
/usr/server/>:make cgicons
gcc -g -o cgicons cgicons.o lock.o web.o dbcore.o formatea.o -L/netscape/users/mirapi/tools/lbr -lmirapi -lutil -lsocket -lnsl
Undefined                       first referenced
 symbol                             in file
myfree                              cgicons.o
set_buffline_var                    cgicons.o
load_buffline                       cgicons.o
save_buffline                       cgicons.o
get_buffline_var                    cgicons.o
set_buffline_IP                     cgicons.o

myfree and all others are functions declared in dbcore.c that got compiled into dbcore.o.

Suposedly this was compiling fine last 15th... Is there something I simple I missed?

Thanks
0
Comment
Question by:sinner052397
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 1

Expert Comment

by:ppeck
ID: 1258300
try (i suppose you use some unix)

> rm *.o

and then

> make cgicons

if that does not work, check out, where the 'myfree', 'set_buffline_var' etc. symbols are
defined. you can easily do that using the 'grep' command. maybe you just have to add the
corresponding object file to the OBJS3-variable.

patrick

0
 

Author Comment

by:sinner052397
ID: 1258301
Hi patric. I'm using solaris.
I tried removing the *.o files but that did not work.
The myfree, set_buffline_var et al funstions are declared/defined in the dbcore.c file which in turn generates the dbcore.o file, which is included in the OBJS3 var.

When I generate the dbcore.o file, no error or warnings are issued.
0
 
LVL 5

Expert Comment

by:thoellri
ID: 1258302
Use "nm" to find out, if the symbols are really in dbcore.o. QUick example:

a) I create a dbcore.c file with one function "myfree":

$ cat > dbcore.c
void myfree(char *ptr) {
  printf("Called myfree\n");
}

b) Compile:
$ gcc -c dbcore.c

c) Take a look at symbols in the file:
$ nm dbcore.o

dbcore.o:

[Index]   Value      Size    Type  Bind  Other Shndx   Name

[2]     |         0|       0|SECT |LOCL |0    |3      |
[4]     |         0|       0|SECT |LOCL |0    |2      |
[1]     |         0|       0|FILE |LOCL |0    |ABS    |dbcore.c
[3]     |         0|       0|NOTY |LOCL |0    |2      |gcc2_compiled.
[6]     |         0|      32|FUNC |GLOB |0    |2      |myfree
[5]     |         0|       0|NOTY |GLOB |0    |UNDEF  |printf

If you don't see a "myfree" as FUNC / GLOB in your dbcore.o then you have a problem. Check if these functions are declared as statics.

Hope this helps
  Tobias

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Expert Comment

by:alexo
ID: 1258303
Sounds like you're missing an object file (or files).
Check for source files that define those "missing" variables and include them in the command.
0
 

Accepted Solution

by:
bcn earned 200 total points
ID: 1258304
Hi.

The solution is:

I try explain you with exemple:

You must cc your programs in c with the param -c, for creating the object file.

cc -c program.c -I (path librearies)

cc -c cgicons.c -I../include
cc -c lock.o -I../include
cc -c web.c -I../include
cc -c dbcore.c -I../include
cc -c formatea.c -I../include

cgicons.o lock.o web.o dbcore.o formatea.o

Now, you must create a library with object files.

ar -rv ../lib/libmain cgicons.o lock.o web.o dbcore.o formatea.o











0
 

Expert Comment

by:bcn
ID: 1258305
Hi.

You must distiributed your directory:
  /bin/
  /src/
  /lib/
  /include/

Where bin contains executable.
Where src contains the source programs.
Where lib contains the libraries.
Where include contains the header files.

The solution is:

I try explain you with exemple:

In the src directory you must create a make with folllow setences:

You must cc your programs in c with the param -c, for creating the object file.
The sintaxis is:
cc -c program.c -I(path librearies)

cc -c cgicons.c -I../include
cc -c lock.c -I../include
cc -c web.c -I../include
cc -c dbcore.c -I../include
cc -c formatea.c -I../include

Where include contains cgicons.h, lock.h, web.h, dbcore.h, formate.h.

It will generate...
cgicons.o lock.o web.o dbcore.o formatea.o

Now, you must create a library with object files.
The sintaxis is:
ar -rv(create a library) path_library ../lib/libXXXX where XXXX is the name your main program and the all object files.

ar -rv ../lib/libmain cgicons.o lock.o web.o dbcore.o formatea.o

The last you must do is generated your executable.
The sintaxis is:
cc main.c path_include path_library -lXXXX -o path_executable
where XXXX is the main program.

cc main.c -I../include -L../lib -lmain  -o ../bin/exe

I Hope this helps.

Thanks.














0
 

Author Comment

by:sinner052397
ID: 1258306
Thank you... took me a while but I got it going
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question