Solved

Undefined symbols error

Posted on 1999-01-21
7
349 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
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 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 and use conditional statements in the C programming language.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now