Find the answer to your Linux question:
Results 1 to 4 of 4
I want to compile a program for 2 machines, one for the x86 (for testing) and one for the ARM (which is the actual target machine), the ARM machine has ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Feb 2005
    Location
    Delft, Holland
    Posts
    95

    Omitting undefined symbols


    I want to compile a program for 2 machines, one for the x86 (for testing) and one for the ARM (which is the actual target machine), the ARM machine has an LED screen, and during the program many LED functions are called, these are located in a library that can only be build for the ARM machine.

    When I compile for the x86, I get a lot of undefined errors, which is logical since the linker skips the ARM-library and searches for the functions somewhere else, in vain.
    Can't I tell the linker that if he couldn't find the function, he just removes the actual function call from the binary?

  2. #2
    Linux Enthusiast
    Join Date
    Jan 2005
    Posts
    575
    Probably not.The right time to remove the functions is during compilation
    using #ifdef

  3. #3
    Just Joined!
    Join Date
    Feb 2005
    Location
    Delft, Holland
    Posts
    95
    Well I solved it by creating some stub functions for the x86 compilation.

    I thought about using #ifdef but they make the code so ugly that I only use #ifdef's if there's no other option.

    Still, I'd like to know if removing the functions calls during link-time is uberhaupt possible.

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Newbie
    Join Date
    Oct 2004
    Posts
    158
    Not really.

    If the symbol is there the linker has to resolve it. That's the way it works.
    For stuff like this I create an object file loaded with dummy do-nothing symbols for the calls I cannot resolve and do not need on a test box.

    Then my make files invoke different link paths to bring in either the real or the dummy versions of the code. Just like your stubs.

    ie.,
    Code:
    cc myfile.c dummy.o -o myfile -L/path/mylibs
    vs.
    cc myfile.c -o myfile -L/path1  -L/path2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •