title: file format not recognized; treating as linker script - Compiling c code for arm processor
body: <p>I am struggling to compile a demo program for an arm device.</p>
  
  <p>Documentation is non-existant and I more used to a Windows environment.</p>
  
  <p>I have installed and try on Ubuntu 14 and 13.10, but have the same problem in both. Both are 32 bit.</p>
  
  <p>The makefile is as such:</p>
  
  <pre><code>#
  # program makefile for the POS Application
  #
  
  # build on arm-linux platform
  ARCH    = /opt/gcc-4.0.2-glibc-2.3.5/arm-unknown-linux-gnu/bin/arm-unknown-linux-gnu-
  
  # programs we use...
  CP  = cp -f
  MKDIR   = mkdir -p
  RM  = rm -f
  RMDIR   = rm -rf
  TAR = tar -zcf
  STRIP   = $(ARCH)strip
  RANLIB  = $(ARCH)ranlib
  
  # compiler names:
  CC      = $(ARCH)gcc
  CXX     = $(ARCH)g++
  
  # flags for C/C++ compiler:
  INCFLAG     = -I../include -I../sdk/include
  OPTIM       = -Wall -O2 -Wunused
  CFLAGS      = $(OPTIM)
  CXXFLAGS    = $(OPTIM) -Wno-non-virtual-dtor
  
  # libraries to link with:
  LD_LIBS     = -ldl -lrt
  LD_SDK      = -L../sdk -lkfsdk
  
  LDFLAGS     = $(LD_LIBS) $(LD_SDK)
  
  # Which targets should be built?
  TARGET  = demo_app
  #RELEASEDIR = ../release
  
  # Be quiet when building...
  #.SILENT:
  
  #
  # Files for this directory...
  #
  SRCDIR  = ../src
  
  PATH1       = $(SRCDIR)/gui/
  PATH2       = $(SRCDIR)/platform/
  
  COBJECT     = \
          $(addprefix $(PATH1), $(addsuffix .o, $(basename $(notdir $(wildcard $(PATH1)*.c))))) \
          $(addprefix $(PATH2), $(addsuffix .o, $(basename $(notdir $(wildcard $(PATH2)*.c))))) \
  
  CPPOBJECT   = \
          $(addprefix $(PATH1), $(addsuffix .o, $(basename $(notdir $(wildcard $(PATH1)*.cxx))))) \
          $(addprefix $(PATH2), $(addsuffix .o, $(basename $(notdir $(wildcard $(PATH2)*.cxx))))) \
  
  #CFILES     = $(wildcard *.c)
  #COBJECT    = $(patsubst %.c, %.o, $(CFILES))
  #CPPFILES   = $(wildcard *.cxx)
  #CPPOBJECT  = $(patsubst %.cxx, %.o, $(CPPFILES))
  
  #
  # Make everything...
  #
  all:    $(TARGET)
  #   $(CP) $(TARGET) $(RELEASEDIR)
      @echo "All files have been made"
      @echo "            ************************************"
      @echo "            *                                  *"
      @echo "            *       POS APPLICATION      *"
      @echo "            *                                  *"
      @echo "            ************************************"
      @echo "succeed"
  
  $(TARGET):  $(COBJECT) $(CPPOBJECT)
      @echo Linking $(TARGET)...
      $(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS)
  #   $(CXX) -o $@ $^ $(CXXFLAGS) $(LDFLAGS)
  
  %.o:%.c
      @echo Compiling $&lt;...
      $(CC) $(CFLAGS) $(INCFLAG) -o $@ -c $&lt;
  
  %.o:%.cxx
      @echo Compiling $&lt;...
      $(CXX) $(CXXFLAGS) $(INCFLAG) -o $@ -c $&lt;
  
  #
  # Clean old files...
  #
  clean:
      $(RM) *.o
      $(RM) $(PATH1)*.o
      $(RM) $(PATH2)*.o
      $(RM) $(TARGET)
  
  #
  # End of "$Id: Makefile 2011-01-24 08:21 $".
  #
  # DO NOT DELETE
  </code></pre>
  
  <p>I have run make clean, and then make and get the following message:</p>
  
  <pre><code>Compiling ../src/platform/main.c...
  /opt/gcc-4.0.2-glibc-2.3.5/arm-unknown-linux-gnu/bin/arm-unknown-linux-gnu-gcc -Wall -O2 -Wunused -I../include -I../sdk/include -o ../src/platform/main.o -c ../src/platform/main.c
  Linking demo_app...
  /opt/gcc-4.0.2-glibc-2.3.5/arm-unknown-linux-gnu/bin/arm-unknown-linux-gnu-gcc -o demo_app ../src/platform/main.o -Wall -O2 -Wunused -ldl -lrt -L../sdk -lkfsdk
  /opt/gcc-4.0.2-glibc-2.3.5/arm-unknown-linux-gnu/bin/../lib/gcc/arm-unknown-linux-gnu/4.0.2/../../../../arm-unknown-linux-gnu/bin/ld:/opt/gcc-4.0.2-glibc-2.3.5/arm-unknown-linux-gnu/bin/../lib/gcc/arm-unknown-linux-gnu/4.0.2/../../../../arm-unknown-linux-gnu/lib/libdl.so: file format not recognized; treating as linker script
  /opt/gcc-4.0.2-glibc-2.3.5/arm-unknown-linux-gnu/bin/ld:/opt/gcc-4.0.2-glibc-2.3.5/arm-unknown-linux-gnu/bin/../lib/gcc/arm-unknown-linux-gnu/4.0.2/../../../../arm-unknown-linux-gnu/lib/libdl.so:1: parse error
  collect2: ld return 1 exit status.
  </code></pre>
  
  <p>From the googling I have done, it seems to be a problem linking the files together, but I have no idea why and what is wrong.</p>
  
  <p>I have tried apt-get install gcc-arm-linux-gnueabi</p>
  
  <p>The /opt/gcc-4.0.2-glibc-2.3.5 directory and subdirectories came with the so called SDK supplied for the the device.</p>
  
  <p>Any ideas as to how to get this working?</p>
  
  <p>Thank you</p>
  
  <p>Neill</p>
  
  <p>Edit 1:</p>
  
  <p>If I do a more on <code>libdl.so</code>, it shows <code>libdl.s0.2</code>. If I more that file, it gives <code>libdl-2.3.5.so</code>. And finally if i do a <code>readelf -h libdl-2.3.5.so</code> that file, I get:  </p>
  
  <pre><code>ELF 
  
      Header:
        Magic:   7f 45 4c 46 01 01 01 61 00 00 00 00 00 00 00 00 
        Class:                             ELF32
        Data:                              2's complement, little endian
        Version:                           1 (current)
        OS/ABI:                            ARM
        ABI Version:                       0
        Type:                              DYN (Shared object file)
        Machine:                           ARM
        Version:                           0x1
        Entry point address:               0xc78
        Start of program headers:          52 (bytes into file)
        Start of section headers:          9864 (bytes into file)
        Flags:                             0x2, has entry point, GNU EABI
        Size of this header:               52 (bytes)
        Size of program headers:           32 (bytes)
        Number of program headers:         7
        Size of section headers:           40 (bytes)
        Number of section headers:         32
        Section header string table index: 29
  </code></pre>
  
  <p>Id I do <code>file libdl-2.3.5.so</code> I get:</p>
  
  <pre><code>/opt/gcc-4.0.2-glibc-2.3.5/arm-unknown-linux-gnu/arm-unknown-linux-gnu/lib/libdl-2.3.5.so: ELF 32-bit LSB shared object, ARM, version 1, dynamically linked (uses shared libs), for GNU/Linux 2.4.3, not stripped
  </code></pre>
  
  <p>I edited here because of the long post.</p>
  
  <p>Neill</p>