Skip to content
This repository has been archived by the owner on Apr 15, 2022. It is now read-only.

err at cross-compiling #44

Open
meAbab opened this issue May 26, 2016 · 6 comments
Open

err at cross-compiling #44

meAbab opened this issue May 26, 2016 · 6 comments

Comments

@meAbab
Copy link

meAbab commented May 26, 2016

While I'm doing
$ ./configure --target=arm-linux-gnueabihf --host=arm-linux-gnueabihf
I endup with error

 ----------------------------------------------------
   Unable to find gcrypt.h on this system.
   libgcrypt (libgcrypt11-dev) is required, please install
   and rebuild.
   ----------------------------------------------------

however, libgcrypt is installed, and without target / host errorless configure & make.
How to solve this problem ?

@jbdatko
Copy link
Member

jbdatko commented May 26, 2016

I think you need the armf versions of libgrcypt-dev installed. Note, you need the -dev package installed which includes the headers, not just libgcrypt11.

I usually hand compile libgcrypt & gpg-error and put them in a custom prefix, maybe you can install the armhf versions with x86_64? I've never tried that.

In any case, I really need to refactor this to not use libgcrypt. Hopefully within the next week I'll get some cycles.

@meAbab
Copy link
Author

meAbab commented May 26, 2016

alright, will give a try of armf libgcrypt. Many thanks for your advise!.

@meAbab
Copy link
Author

meAbab commented May 27, 2016

Now try after libgcrypt-dev & gpg-error for armf, error comes as -

src/driver/hashlet-command.o: In function `gen_temp_key_from_nonce':
/home/rafiq32/hashlet-1.1.0/src/driver/command.c:1039: undefined reference to `sha256_buffer'
src/driver/hashlet-command.o: In function `gen_temp_key_from_digest':
/home/rafiq32/hashlet-1.1.0/src/driver/command.c:1107: undefined reference to `sha256_buffer'
src/driver/hashlet-command.o: In function `mac_write':
/home/rafiq32/hashlet-1.1.0/src/driver/command.c:1167: undefined reference to `sha256_buffer'
src/cli/hashlet-cli_commands.o: In function `cli_hmac':
/home/rafiq32/hashlet-1.1.0/src/cli/cli_commands.c:820: undefined reference to `sha256'
src/cli/hashlet-cli_commands.o: In function `cli_verify_hmac':
/home/rafiq32/hashlet-1.1.0/src/cli/cli_commands.c:881: undefined reference to `sha256'
/home/rafiq32/hashlet-1.1.0/src/cli/cli_commands.c:903: undefined reference to `verify_hmac_defaults'
/home/rafiq32/hashlet-1.1.0/src/cli/cli_commands.c:887: undefined reference to `sha256'

While checking source code, I found sha256_buffer and sha256 is well defined in header.

@jbdatko
Copy link
Member

jbdatko commented May 27, 2016

Tonight, I'll hack up hashlet to not have any libgcrypt dependencies and push a new version. I'll try cross compiling too.

@jbdatko
Copy link
Member

jbdatko commented May 28, 2016

Sorry about that... one of those days.

Anyway, I fixed up things on the develop branch. No more libgcrypt dependency!

It's untested, and I probably won't be able to get around to properly testing it until later next week at earliest, but this is how I built it:

hashlet (develop) $ make clean && ./configure --host=arm-linux-gnueabihf --enable-silent-rules && make && file hashlet
Making clean in doc
make[1]: Entering directory '/home/jbd/repos/cryptotronix/hashlet/doc'
test -z "hashlet.dvi hashlet.pdf hashlet.ps hashlet.html" \
|| rm -rf hashlet.dvi hashlet.pdf hashlet.ps hashlet.html
rm -rf .libs _libs
rm -rf hashlet.t2d hashlet.t2p
rm -f *.lo
rm -f vti.tmp* ./version.texi.tmp*
make[1]: Leaving directory '/home/jbd/repos/cryptotronix/hashlet/doc'
Making clean in .
make[1]: Entering directory '/home/jbd/repos/cryptotronix/hashlet'
 rm -f hashlet
rm -rf .libs _libs
rm -f *.o
rm -f src/cli/*.o
rm -f src/driver/*.o
rm -f src/parser/*.o
test -z "src/tests/test_cli.sh.log" || rm -f src/tests/test_cli.sh.log
test -z "src/tests/test_cli.sh.trs" || rm -f src/tests/test_cli.sh.trs
test -z "test-suite.log" || rm -f test-suite.log
rm -f *.lo
make[1]: Leaving directory '/home/jbd/repos/cryptotronix/hashlet'
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for arm-linux-gnueabihf-strip... arm-linux-gnueabihf-strip
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for style of include used by make... GNU
checking for arm-linux-gnueabihf-gcc... arm-linux-gnueabihf-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether arm-linux-gnueabihf-gcc accepts -g... yes
checking for arm-linux-gnueabihf-gcc option to accept ISO C89... none needed
checking whether arm-linux-gnueabihf-gcc understands -c and -o together... yes
checking dependency style of arm-linux-gnueabihf-gcc... gcc3
checking how to run the C preprocessor... arm-linux-gnueabihf-gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking linux/i2c-dev.h usability... yes
checking linux/i2c-dev.h presence... yes
checking for linux/i2c-dev.h... yes
checking sys/ioctl.h usability... yes
checking sys/ioctl.h presence... yes
checking for sys/ioctl.h... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking for arm-linux-gnueabihf-gcc... (cached) arm-linux-gnueabihf-gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether arm-linux-gnueabihf-gcc accepts -g... (cached) yes
checking for arm-linux-gnueabihf-gcc option to accept ISO C89... (cached) none needed
checking whether arm-linux-gnueabihf-gcc understands -c and -o together... (cached) yes
checking dependency style of arm-linux-gnueabihf-gcc... (cached) gcc3
checking for arm-linux-gnueabihf-pkg-config... no
checking for pkg-config... /usr/bin/pkg-config
configure: WARNING: using cross tools not prefixed with host triplet
checking pkg-config is at least version 0.9.0... yes
checking for flex... flex
checking lex output file root... lex.yy
checking lex library... none needed
checking whether yytext is a pointer... no
checking for bison... bison -y
checking build system type... x86_64-unknown-linux-gnu
checking host system type... arm-unknown-linux-gnueabihf
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for fgrep... /bin/grep -F
checking for ld used by arm-linux-gnueabihf-gcc... /usr/arm-linux-gnueabihf/bin/ld
checking if the linker (/usr/arm-linux-gnueabihf/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/arm-linux-gnueabihf-nm -B
checking the name lister (/usr/bin/arm-linux-gnueabihf-nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-unknown-linux-gnu file names to arm-unknown-linux-gnueabihf format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/arm-linux-gnueabihf/bin/ld option to reload object files... -r
checking for arm-linux-gnueabihf-objdump... arm-linux-gnueabihf-objdump
checking how to recognize dependent libraries... pass_all
checking for arm-linux-gnueabihf-dlltool... no
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for arm-linux-gnueabihf-ar... arm-linux-gnueabihf-ar
checking for archiver @FILE support... @
checking for arm-linux-gnueabihf-strip... (cached) arm-linux-gnueabihf-strip
checking for arm-linux-gnueabihf-ranlib... arm-linux-gnueabihf-ranlib
checking command to parse /usr/bin/arm-linux-gnueabihf-nm -B output from arm-linux-gnueabihf-gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for arm-linux-gnueabihf-mt... no
checking for mt... mt
checking if mt is a manifest tool... no
checking for dlfcn.h... yes
checking for objdir... .libs
checking if arm-linux-gnueabihf-gcc supports -fno-rtti -fno-exceptions... no
checking for arm-linux-gnueabihf-gcc option to produce PIC... -fPIC -DPIC
checking if arm-linux-gnueabihf-gcc PIC flag -fPIC -DPIC works... yes
checking if arm-linux-gnueabihf-gcc static flag -static works... yes
checking if arm-linux-gnueabihf-gcc supports -c -o file.o... yes
checking if arm-linux-gnueabihf-gcc supports -c -o file.o... (cached) yes
checking whether the arm-linux-gnueabihf-gcc linker (/usr/arm-linux-gnueabihf/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating doc/Makefile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
make  all-recursive
make[1]: Entering directory '/home/jbd/repos/cryptotronix/hashlet'
Making all in doc
make[2]: Entering directory '/home/jbd/repos/cryptotronix/hashlet/doc'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/jbd/repos/cryptotronix/hashlet/doc'
Making all in .
make[2]: Entering directory '/home/jbd/repos/cryptotronix/hashlet'
  CC       src/driver/hashlet-command.o
  CC       src/driver/hashlet-crc.o
  CC       src/driver/hashlet-i2c.o
  CC       src/driver/hashlet-util.o
  CC       src/driver/hashlet-command_adaptation.o
  CC       src/driver/hashlet-log.o
  CC       src/cli/hashlet-main.o
  CC       src/driver/hashlet-personalize.o
  CC       src/cli/hashlet-sha256.o
  CC       src/cli/hashlet-hash.o
  CC       src/cli/hashlet-cli_commands.o
  CC       src/driver/hashlet-config_zone.o
  CC       src/parser/hashlet-hashlet_bison.o
  CC       src/parser/hashlet-hashlet_flex.o
  CC       src/parser/hashlet-hashlet_parser.o
  CCLD     hashlet
make[2]: Leaving directory '/home/jbd/repos/cryptotronix/hashlet'
make[1]: Leaving directory '/home/jbd/repos/cryptotronix/hashlet'
hashlet: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 3.2.0, BuildID[sha1]=f0e286908d6e77aa1a23a6d100be457244b1e30e, not stripped

@AlephAlpha
Copy link

Sorry about that... one of those days.

Anyway, I fixed up things on the develop branch. No more libgcrypt dependency!

It's untested, and I probably won't be able to get around to properly testing it until later next week at earliest, but this is how I built it:

Found a bug here:

hashlet/src/cli/hash.c

Lines 35 to 42 in b5a6d2a

int c;
int rc = -1;
/* Perform the hash */
while ((c = getc (fp)) != EOF)
{
rc = sha256_process (&state, (const unsigned char *)&c, sizeof c);
if (rc) goto OUT;
}

The type of c is int but only one byte is read for each time, so sizeof c on L40 should be 1.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants