question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

buildNatives_osx64 build is broken

See original GitHub issue

Describe the bug gradle buildNatives_osx64 fails with error message

> Task :CabExtract:osx64CabExtractMake
/Applications/Xcode.app/Contents/Developer/usr/bin/make  all-am
gcc -DHAVE_CONFIG_H -I.  -I./mspack -DMSPACK_NO_DEFAULT_SYSTEM   -g -O2 -c -o system.o `test -f 'mspack/system.c' || echo './'`mspack/system.c
gcc -DHAVE_CONFIG_H -I.  -I./mspack -DMSPACK_NO_DEFAULT_SYSTEM   -g -O2 -c -o cabd.o `test -f 'mspack/cabd.c' || echo './'`mspack/cabd.c
gcc -DHAVE_CONFIG_H -I.  -I./mspack -DMSPACK_NO_DEFAULT_SYSTEM   -g -O2 -c -o lzxd.o `test -f 'mspack/lzxd.c' || echo './'`mspack/lzxd.c
gcc -DHAVE_CONFIG_H -I.  -I./mspack -DMSPACK_NO_DEFAULT_SYSTEM   -g -O2 -c -o mszipd.o `test -f 'mspack/mszipd.c' || echo './'`mspack/mszipd.c
gcc -DHAVE_CONFIG_H -I.  -I./mspack -DMSPACK_NO_DEFAULT_SYSTEM   -g -O2 -c -o qtmd.o `test -f 'mspack/qtmd.c' || echo './'`mspack/qtmd.c
rm -f libmspack.a
ar cru libmspack.a system.o cabd.o lzxd.o mszipd.o qtmd.o 
/opt/local/bin/ranlib: object: libmspack.a(system.o) malformed object (unknown load command 1)
ar: internal ranlib command failed
make[1]: *** [libmspack.a] Error 1
make: *** [all] Error 2

> Task :CabExtract:osx64CabExtractMake FAILED

To Reproduce Steps to reproduce the behavior: This applies to the current Ghidra github repo, the last commit was https://github.com/NationalSecurityAgency/ghidra/commit/cafbb77db0a2120c529aef45d2d6bc47fa1edc29

mkdir ~/git2
cd ~/git2
git clone https://github.com/NationalSecurityAgency/ghidra.git
cd ghidra/
gradle eclipse
gradle prepDev -x yajswDevUnpack eclipse
mkdir -p /git2/ghidra.bin/GhidraBuild/EclipsePlugins/GhidraDev/buildDependencies/
cp ~/git/ghidra.bin/GhidraBuild/EclipsePlugins/GhidraDev/buildDependencies/* ~/git2/ghidra.bin/GhidraBuild/EclipsePlugins/GhidraDev/buildDependencies/
gradle prepDev -x yajswDevUnpack eclipse

gradle buildNatives_osx64

Expected behavior Build should work.

Environment (please complete the following information):

  • OS: macOS 10.14.5
  • Java Version: openjdk 11.0.2 2019-01-15
  • Ghidra Version: fresh clone from github

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:17 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
mh-commented, Jun 24, 2019

Ok, I found the problem - apparently my ranlib (“Apple Inc. version cctools-895”) was installed with another package, maybe libtools (?), and didn’t match ar.

Now, with

$ ranlib -V
Apple Inc. version cctools-927.0.2

everything builds ok.

It generates a warning

mktime.c:367:7: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
  if (TIME_T_MAX / INT_MAX / 366 / 24 / 60 / 60 < 3)
      ^~~~~~~~~~
mktime.c:90:21: note: expanded from macro 'TIME_T_MAX'
# define TIME_T_MAX TYPE_MAXIMUM (time_t)
                    ^~~~~~~~~~~~~~~~~~~~~
mktime.c:77:41: note: expanded from macro 'TYPE_MAXIMUM'
#define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
                                        ^~~~~~~~~~~~~~~~
mktime.c:76:20: note: expanded from macro 'TYPE_MINIMUM'
                              ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0))
                                ~~~~~~~ ^
1 warning generated.

but it builds 😃

Thanks for your help.

0reactions
wanchouchoucommented, Sep 15, 2021

Thanks for your information, it helps me a lot.

I have also occurred this problem after I updated my MAC with command brew upgrade.

But my error info is:

ld: warning: ignoring file libmspack.a, building for macOS-x86_64 but attempting to link with file built for macOS-x86_64
Undefined symbols for architecture x86_64:
  "_mspack_create_cab_decompressor", referenced from:
      _main in cabextract.o
  "_mspack_destroy_cab_decompressor", referenced from:
      _main in cabextract.o
  "_mspack_sys_selftest_internal", referenced from:
      _main in cabextract.o
ld: symbol(s) not found for architecture x86_64

Using command nm libmspack.a | grep _mspack_create_cab_decompressor, I get:

0000000000000000 T _mspack_create_cab_decompressor

It’s clear that I have successfully built and archived the target functions, but why I cannot link them?

The command ar -V and ranlib -V gives me the result:

GNU ar/ranlib (GNU Binutils) 2.37
Copyright (C) 2021 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) any later version.
This program has absolutely no warranty.

So it’s not about the incompatible between AR and RANLIB. What about the LD? Then I use system default AR and RANLIB instead:

Apple Inc. version cctools-959.0.1
error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: no archives specified
Usage: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib [-sactfqLT] [-] archive [...]

Build again. Bingo! Compile successfully.

CONCLUSION: The AR and RANLIB from GNU Binutils does not compatible with the system linker LD on mac OSX, we should use the system default toolchains.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native build breaking - 64 bit support #2684 - GitHub
Our react-native xcode build is failing to archive due to realm. I've searched exhaustively, but haven't found a lead on what could fix...
Read more >
Can't build gdal in x64 - Stack Overflow
I managed to build x64 version of GDAL under Visual Studio 2012 using steps ... Start VS2012 x64 Native Tools Command Prompt :...
Read more >
MSBuild and 64-bit Visual Studio 2022 - .NET Blog
Visual Studio's shift to 64-bit means your builds in Visual Studio 2022 will run in a 64-bit MSBuild. This will not cause any...
Read more >
Building native software - Gradle User Manual
The software model is being retired and the plugins mentioned in this chapter will eventually be deprecated and removed. We recommend new projects...
Read more >
Visual Studio not able to compile a simple Hello World
Run Build Command:"C:/Program Files (x86)/Microsoft Visual ... Open your x64 Native Tools Command prompt from your Start Menu (while at it, pin it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found