undefined reference uuid_parse

D

djbitchpimp

Please forgive the newb question but I cannot seem to find why this
code is giving me the following error:

]gcc parse_uuid.c
/tmp/ccGKD3b0.o(.text+0x18): In function `main':
: undefined reference to `uuid_generate'
collect2: ld returned 1 exit status

Here is the code:

#include <uuid/uuid.h>


int main (int argc, char **argv) {
uuid_t theID ;

uuid_parse (argv [1], theID) ;
//uuid_generate (theID) ;

printf ("Original UUID: %s\nIn Hex: %i\n", argv [1], theID) ;

return 1 ;


}

Any suggestions would be greatly appreciated, thanks!

-Greg
 
J

Jens.Toerring

Please forgive the newb question but I cannot seem to find why this
code is giving me the following error:
]gcc parse_uuid.c
/tmp/ccGKD3b0.o(.text+0x18): In function `main':
: undefined reference to `uuid_generate'
collect2: ld returned 1 exit status

This is a linker error, so its not directly related to C. And it
can hardly be for the code you posted since there the line where
uuid_generate() is invoked is commented out. If you get such an
error it should about your use of uuid_parse()...
Here is the code:
#include <uuid/uuid.h>

int main (int argc, char **argv) {
uuid_t theID ;
uuid_parse (argv [1], theID) ;

You should check if argc is at least 2 before you use argv[1].
//uuid_generate (theID) ;
printf ("Original UUID: %s\nIn Hex: %i\n", argv [1], theID) ;

Is 'theID' an int variable (i.e. is uuid_t synonymous to int)? Other-
wise you could get in trouble with using the "%i" format specifier.
Moreover, if you, as the text seems to indicate, want to print a
hexadecimal value you must use "%x" or "%X" (but then 'theID' would
have to be an unsigned int).
return 1 ;

Non-portable return value, use either 0 (for success) or, after
Any suggestions would be greatly appreciated, thanks!

Neither the header file <uuid/uiid.h> nor the type uuid_t or the
function uuid_parse() are standard C, so they are probably related
to a 3-party library you're trying to use. But obviously you're
not linking against such a library (you may have append '-luuid'
or something similar to your command line if the library is named
'libuuid.so' and is located in one of the places where the linker
will look for it).
Regards, Jens
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top