Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14976 > unrolled thread

Re: How to compile hashlib.c for testing?

Started byPeng Yu <pengyu.ut@gmail.com>
First post2018-12-27 18:58 -0600
Last post2018-12-27 18:58 -0600
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: How to compile hashlib.c for testing? Peng Yu <pengyu.ut@gmail.com> - 2018-12-27 18:58 -0600

#14976 — Re: How to compile hashlib.c for testing?

FromPeng Yu <pengyu.ut@gmail.com>
Date2018-12-27 18:58 -0600
SubjectRe: How to compile hashlib.c for testing?
Message-ID<mailman.6427.1545959700.1284.bug-bash@gnu.org>
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

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web