bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to compile hashlib.c for testing?


From: Peng Yu
Subject: Re: How to compile hashlib.c for testing?
Date: Thu, 27 Dec 2018 18:58:12 -0600

On Thu, Dec 27, 2018 at 12:27 PM Chet Ramey <chet.ramey@case.edu> wrote:
>
> On 12/26/18 4:31 PM, Peng Yu wrote:
> > Hi,
> >
> > I'd like to compile hashlib.c to try its main(). But I got the
> > following error. What is the correct commands to compile it? Thanks.
>
> Think about the error message:
>
> >   "_xmalloc", referenced from:
> >       _hash_create in hashlib.o
> >       _hash_copy in hashlib.o
> >       _hash_search in hashlib.o
> >       _hash_insert in hashlib.o
> >       _main in hashlib.o
> > ld: symbol(s) not found for architecture x86_64
>
> So you need a definition for xmalloc. The easiest thing to do is to add
> an xmalloc function in the TEST_HASHING block, or you could follow the
> directions in the comment there.
>
> Sooner or later, you're going to have to pick this stuff up on your own.


I run make in lib/malloc, then I got the following error. What is wrong?

~/Downloads/bash-4.4$ gcc hashlib.o xmalloc.o lib/malloc/libmalloc.a
-o hashlib.exe
Undefined symbols for architecture x86_64:
  "_libintl_gettext", referenced from:
      _xmalloc in xmalloc.o
      _xrealloc in xmalloc.o
      _internal_malloc in libmalloc.a(malloc.o)
      _internal_realloc in libmalloc.a(malloc.o)
      _internal_free in libmalloc.a(malloc.o)
      _xbotch in libmalloc.a(malloc.o)
  "_running_trap", referenced from:
      _internal_malloc in libmalloc.a(malloc.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Then I add ./lib/intl/libintl.a, I got additional errors. This does
not seem to be an efficient way to resolve the problem. Is there an
easy way to figure out all the necessary libraries (but no more) to
link.

$ gcc hashlib.o  xmalloc.o ./lib/intl/libintl.a lib/malloc/libmalloc.a
-o hashlib.exe
Undefined symbols for architecture x86_64:
  "_iconv", referenced from:
      __nl_find_msg in libintl.a(dcigettext.o)
  "_iconv_close", referenced from:
      __nl_free_domain_conv in libintl.a(loadmsgcat.o)
  "_iconv_open", referenced from:
      __nl_init_domain_conv in libintl.a(loadmsgcat.o)
  "_libiconv_set_relocation_prefix", referenced from:
      _libintl_set_relocation_prefix in libintl.a(relocatable.o)
  "_running_trap", referenced from:
      _internal_malloc in libmalloc.a(malloc.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Since the main() function is already there, why there is not already
an easy way to compile it? How do you do unit-testing then for the
code?

-- 
Regards,
Peng



reply via email to

[Prev in Thread] Current Thread [Next in Thread]