Path: csiph.com!news.redatomik.org!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: Peng Yu Newsgroups: gnu.bash.bug Subject: Re: How to compile hashlib.c for testing? Date: Thu, 27 Dec 2018 18:58:12 -0600 Lines: 71 Approved: bug-bash@gnu.org Message-ID: References: <31ae9367-7968-aff5-d0e8-0f9da667d584@case.edu> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: usenet.stanford.edu 1545959701 11616 208.118.235.17 (28 Dec 2018 01:15:01 GMT) X-Complaints-To: action@cs.stanford.edu Cc: bug-bash To: Chester Ramey Envelope-to: bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Z8II/noauFgyYiuZruZ9EuvqYzEfy1muxFrVC0BEdFQ=; b=f/zgxo2HPoEw2KozccWIMv+illHj1eL1F0Ixc4DlwT9HihHACrsbgjG3eMKibPyLzu BPStOQ4+MyYIIa3NHBp+PwV96hDF4waH0WbjITbGnoj/ZlhPvJlFHun8SqSc1VAOlmAm r5b05bdCVLiFJdB4zYVJY+vha0LsN7uN14CL6npWLMS/a4bteclKM3kUhtdE6BLQh7xF 5M0iSwp6q74QaJTEmh33Ruc1w4frXh4KRsNdhyJpz6TGREct17WGzIqBXSzkcZhHZNHd HOu2BrpbAAO0teuwBHNhGPA1u4vaJ/NM9WExg1o9txG0KmeCbJ17udbqkySVRiOwThT6 JIeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Z8II/noauFgyYiuZruZ9EuvqYzEfy1muxFrVC0BEdFQ=; b=Zup5nRzJJ2FaOdQNTR08FsPBn+pFCHhDPJLH4qx1mhWuzDTQicyJ1EU8GKysMTSVlN 14Mmm1fC/9JO4bmDpml4WwFHoH113adSOPsax2miPNSDl+H98w6JcrSWZHpvr81fCAhF GWxRh5bO4b3FlzAxRKIP0f5r9bv6dlMThXWrV6tm/wh8ym+HpwsEsSpWIP4VtXRq4r1E 9QIU3R5av9X0ye02xJkX2e98YyAWUa/ta2fWe6qI3uh0PPNB7YAqcZmjRppNECgwDr9a LlUPtCNVEY3KrE/IsS990929BZK7MK6Ff7fxCNAU9UoQuCLXYKdpd+Tb85pA9LWxeuro 7SAg== X-Gm-Message-State: AA+aEWYsSWPvQOcfom0f8kPgU/Kb+qvTfm1IGh8zno3YHY9uajO/er9s 06bt5YfqirEgbk0qQwiILyl8uk5Dek3GVbX0a4I= X-Google-Smtp-Source: AFSGD/Wpwd2vvQlNPCUgmZwUwhb3JSHuoqWe0EdCkgdI8UGHvbSfIY+BD/qiE0ILJlv3j62SmBiGFGUJYXC4XdB/4+g= X-Received: by 2002:a24:8e43:: with SMTP id h64mr15496391ite.26.1545958703626; Thu, 27 Dec 2018 16:58:23 -0800 (PST) In-Reply-To: <31ae9367-7968-aff5-d0e8-0f9da667d584@case.edu> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::134 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:14976 On Thu, Dec 27, 2018 at 12:27 PM Chet Ramey 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