Solved

Undefined symbols error

Posted on 1999-01-21
7
353 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
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
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

829 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