2 Replies Latest reply on Jun 22, 2011 11:05 AM by tedk

    Problem cross-compiling for SCC cores

    ally

      Hi

       

      I am trying to get "Hello, world" to run on SCC cores, but am having problems with the cross compiler.

       

      I'm following the instructions on page 24 of the SCC Programmer's Guide, revision 0.75.

       

      The command I try is:

       

      /opt/icc-8.1.038/bin/icpc -DCOPPERRIDGE -static -mcpu=pentium -gcc-version=340 helloSCC.c

       

      This gives me the following errors:

       

      ld: skipping incompatible /usr/lib/libm.a when searching for -lm
      ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.4.3/32/../libstdc++.a when searching for -lstdc++
      ld: cannot find -lstdc++

       

      OK, so it seems like the compiler doesn't know where libraries appropriate for the SCC cores are.

       

      I found libm.a under:

       

      /opt/i386-unknown-linux-gnu/i386-unknown-linux-gnu/lib

       

      Not sure if this is the right version to use, but I tried:

       

      /opt/icc-8.1.038/bin/icpc -DCOPPERRIDGE -static -mcpu=pentium -gcc-version=340 helloSCC.c -L /opt/i386-unknown-linux-gnu/i386-unknown-linux-gnu/lib

       

      This gets rid of the errors about libm.a and libstdc++.a, but gives the following errors:

       

      ld: i386:x86-64 architecture of input file `/usr/lib/crt1.o' is incompatible with i386 output
      ld: i386:x86-64 architecture of input file `/usr/lib/crti.o' is incompatible with i386 output
      ld: i386:x86-64 architecture of input file `/usr/lib/crtn.o' is incompatible with i386 output

       

      Now I am stuck.  crt1.o, crti.o and crtn.o all exist under /opt/i386-unknown-linux-gnu/i386-unknown-linux-gnu/lib, but they are not getting picked up by my -L switch (probably because they are .o files, not .a files).

       

      Does anyone have any advice as to what I should do?

       

      Thanks

       

      Ally

        • 1. Re: Problem cross-compiling for SCC cores
          tedk

          Is your "hello world" C++ or C code. With C, icc should be sufficient. For C++, icpc. Can you post your code here? I can then just run it on your MCPC and capture the commands I used. What Marc system are you on?

           

          Look at Bug74 in our Bugzilla for information about cross-coimpiling c++.

          http://marcbug.scc-dc.com/bugzilla3/show_bug.cgi?id=74

          That -DCOPPERRIDGE ... we use -DSCC now (since the Copperridge boards are defunct; we have RockyLake boards) ... although I think COPPERRIDGE should work as a legacy ... not absolutely sure, though.

           

          You should source a script that puts the cross compiler in your path and not just type out the pathname on the invocation line. I use something like

          #! /bin/sh

          if [ -z "${PATH}" ]
          then
              PATH="/opt/icc-8.1.038/bin:/opt/i386-unknown-linux-gnu/bin"; export PATH
          else
              PATH="/opt/icc-8.1.038/bin:/opt/i386-unknown-linux-gnu/bin:$PATH"; export PATH
          fi

           

          if [ -z "${LD_LIBRARY_PATH}" ]
          then
              LD_LIBRARY_PATH="/opt/icc-8.1.038/lib:/opt/i386-unknown-linux-gnu/lib"; export LD_LIBRARY_PATH
          else
              LD_LIBRARY_PATH="/opt/icc-8.1.038/lib:/opt/i386-unknown-linux-gnu/lib:$LD_LIBRARY_PATH"; export LD_LIBRARY_PATH
          fi

           

          if [ -z "${MANPATH}" ]
          then
              MANPATH="/opt/icc-8.1.038/man:/opt/i386-unknown-linux-gnu/man":$(manpath); export MANPATH
          else
              MANPATH="/opt/icc-8.1.038/man:/opt/i386-unknown-linux-gnu/man:${MANPATH}"; export MANPATH
          fi

           

          if [ -z "${INTEL_LICENSE_FILE}" ]
          then
          INTEL_LICENSE_FILE="/opt/icc-8.1.038/licenses:/opt/intel/licenses:${HOME}/intel/licenses";

          export INTEL_LICENSE_FILE
          else
          INTEL_LICENSE_FILE="${INTEL_LICENSE_FILE}:/opt/icc-8.1.038/licenses:/opt/intel/licenses:${HOME}/intel/licenses";

          export INTEL_LICENSE_FILE
          fi

           

          We recommend sourcing the cross compiler and leaving the default gcc the native one for Ubuntu. This lets you write MCPC programs in one window and cross compile in another while finding all the right libraries.

           

          The cross-compilation environment should look like (note that you need cross versions of both gcc and icc even if you are using just icc because icc is using some gcc under the covers).

          tekubasx@marc006:~/bin$ gcc --version
          gcc (GCC) 3.4.5
          Copyright (C) 2004 Free Software Foundation, Inc.
          This is free software; see the source for copying conditions.  There is NO
          warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

           

          tekubasx@marc006:~/bin$ icc -V
          Intel(R) C Compiler for 32-bit applications, Version 8.1    Build 20060606Z Package ID: l_cc_pc_8.1.038
          Copyright (C) 1985-2006 Intel Corporation.  All rights reserved.

           

          • 2. Re: Problem cross-compiling for SCC cores
            ally

            Hi Ted

             

            Thanks for your post, which exactly solved my problem - my example now compiles.  For the sake of completeness, the code was exactly the standard "Hello, world program":

             

            #include <stdio.h>

             

            int main()
            {
                printf("Hello, world\n");
                return 0;
            }

             

            I feel a bit stupid: in "Getting Started with the SCC.pdf" it clearly says that there is a "crosscompile.sh" script in /opt/compilerSetupFiles, which is exactly the commands you've given me.

             

            I suppose it might be worth reminding the reader of this at the start of Section 6.1 of the SCC Programmer's Guide.

             

            As my code was C, I had figured to use icc, not icpc, but again in Section 6.1 of the Programmer's Guide, icpc is mentioned (as is -DCOPPERRIDGE), so I also tried this verbatim.

             

            Thanks again for all our help!

             

            Ally