• C

Undefined symbols error

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
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?

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.


sinner052397Author Commented:
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.
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


[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

Protecting & Securing Your Critical Data

Considering 93 percent of companies file for bankruptcy within 12 months of a disaster that blocked access to their data for 10 days or more, planning for the worst is just smart business. Learn how Acronis Backup integrates security at every stage

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.

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


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial

You must distiributed your directory:

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.


sinner052397Author Commented:
Thank you... took me a while but I got it going
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.