Home > OS >  Problems compiling makefile
Problems compiling makefile

Time:11-09

everyone. Firstly, I would like to say that I don't know much about programming. I am trying to run a software in a Mac for my phD. I am following the steps to compile the software and they are simple: I just need to add the correct directory and then execute the command make, because that is a makefile in the target folder. However, I keep getting the error message

clang: error: linker command failed with exit code 1 (use -v to see invocation)

This is was terminal shows when I type make:

p-oz-nb030mc:Match pferreira$ make
c   -O4 -c match.cc -o match.o -Wall -g 
clang: warning: -O4 is equivalent to -O3 [-Wdeprecated]
c   -O4 -c normalize.cc -o normalize.o -Wall -g 
clang: warning: -O4 is equivalent to -O3 [-Wdeprecated]
In file included from normalize.cc:35:
./series.hh:67:14: warning: unused function 'intervalmap' [-Wunused-function]
static float intervalmap(float i1b, float i1e, float i2b, 
             ^
1 warning generated.
c   match.o series.o config.o normalize.o floatnan.o -o match 
ld: warning: ignoring file series.o, building for macOS-arm64 but attempting to link with file built for unknown-unsupported file format ( 0x4C 0x01 0x1C 0x00 0x00 0x00 0x00 0x00 0xA4 0x74 0x08 0x00 0x92 0x00 0x00 0x00 )
ld: warning: ignoring file config.o, building for macOS-arm64 but attempting to link with file built for unknown-unsupported file format ( 0x4C 0x01 0x0D 0x00 0x00 0x00 0x00 0x00 0x3A 0x44 0x05 0x00 0x5F 0x00 0x00 0x00 )
ld: warning: ignoring file floatnan.o, building for macOS-arm64 but attempting to link with file built for unknown-unsupported file format ( 0x4C 0x01 0x0A 0x00 0x00 0x00 0x00 0x00 0x22 0x2F 0x02 0x00 0x28 0x00 0x00 0x00 )
Undefined symbols for architecture arm64:
  "read_gapfile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)", referenced from:
      getseries(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, float, float, int, floatnan, floatnan, std::__1::vector<floatnan, std::__1::allocator<floatnan> >, std::__1::vector<floatnan, std::__1::allocator<floatnan> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in match.o
  "read_tiefile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_ostream<char, std::__1::char_traits<char> >&)", referenced from:
      _main in match.o
  "merge_signal_series(std::__1::vector<series, std::__1::allocator<series> >&)", referenced from:
      getseries(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, float, float, int, floatnan, floatnan, std::__1::vector<floatnan, std::__1::allocator<floatnan> >, std::__1::vector<floatnan, std::__1::allocator<floatnan> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in match.o
  "readfile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)", referenced from:
      getseries(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, float, float, int, floatnan, floatnan, std::__1::vector<floatnan, std::__1::allocator<floatnan> >, std::__1::vector<floatnan, std::__1::allocator<floatnan> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) in match.o
  "as_string(float)", referenced from:
      series::lookup_label(int, float) in match.o
  "as_string(int)", referenced from:
      write_new_series(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, path&, series&, series&, int) in match.o
      series::build_labelmap() in match.o
      series::lookup_label(int, float) in match.o
  "as_string(unsigned int)", referenced from:
      gaps::apply_gaps(series&) in match.o
  "config::read(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)", referenced from:
      _main in match.o
  "config::write(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)", referenced from:
      _main in match.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [match] Error 1

And this is the make file:

VERSION=2.3

all: match

%: %.o
    c   $^ -o $@ $(LDFLAGS)

.cc.o:
#   c   -c $< -o $@ -Wall -g $(CFLAGS)
    c   -O4 -c $< -o $@ -Wall -g $(CFLAGS)

match: match.o series.o config.o normalize.o floatnan.o
match.o: match.cc config.hh series.hh normalize.hh floatnan.hh
series.o: series.cc series.hh floatnan.hh
config.o: config.cc config.hh floatnan.hh
normalize.o: normalize.cc normalize.hh series.hh floatnan.hh
floatnan.o: floatnan.cc floatnan.hh

clean: 
    rm -f *.o match *~ match.exe match.log *.new xmatch score_matrix

tar:
    sed '/\S/ ! d;s/^/Match-${VERSION}\//' ../manifest > ../manifest.tmp
    tar -cz -C ../.. -f ../match-${VERSION}.tgz -T ../manifest.tmp

check-manifest:
    cd .. && find . -type f | sed 's/^.\///' | grep -v ,v | sort > manifest.tmp
    sort ../manifest > ../manifest.tmp1
    diff ../manifest.tmp1 ../manifest.tmp; true
    pwd | grep 'Match-${VERSION}/' > /dev/null || (echo version mismatch; false)

Does anyone have a clue on what is happening? I did not make this file, I just need to run it. I downloaded the version 2.3.1 from here: https://lorraine-lisiecki.com/match.html

I searched the error online but I could not fix it.

Thank you for your help

CodePudding user response:

The makefile calls for five object files to be linked to create the target binary "match". It contains rules appropriate for building all of those from corresponding C source files present in the same directory.

The make output shows only two of the object files being built before the attempt to link the final target. That tells me that files with the names expected for the other three object files already existed, and that they were not older than the corresponding sources. Those are the same three that the linker rejects. It seems likely, therefore, that the source package you downloaded contains some pre-built object files that are wrong for your machine. Their inclusion was probably accidental.

The makefile also contains a clean target that should remove the erroneous object files, among other things. You can run make clean to trigger it. Run make or make all again afterward. I can't promise you that the build will succeed, but at least you should not have the same problem.

  • Related