Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Mario_K_
Beginner
76 Views

ICPC read linker commands from file

Hello,

I want to read linker commands from a file by the option -T but there is a syntax error

ld:linkerCommands:1: syntax error

Called command is: icpc ... -TlinkerCommands

Where the file "linkerCommands" has the content "-L/myPath/" (only one line)

Do I need a special syntax in the file? Is it possible to write more then one command to the file?

Thank you very much.

icpc version 16.0.0 under RedHat 7.1

 

0 Kudos
7 Replies
Judith_W_Intel
Employee
76 Views

 

If you look in the GNU ld documentation here:

https://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_node/ld_3.html#SEC3

You'll see the following description of the -T option:

-T commandfile
 
--script=commandfile
Read link commands from the file commandfile. These commands replace ld's default link script (rather than adding to it), so commandfile must specify everything necessary to describe the target format. You must use this option if you want to use a command which can only appear once in a linker script, such as the SECTIONS or MEMORY command. See section Command Language. If commandfile does not exist, ld looks for it in the directories specified by any preceding `-L' options. Multiple `-T' options accumulate.

 

So

(1) The -T option needs to be a complete replacement for all linker options

(2) The syntax needs to use the special Command Language described here:

https://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_node/ld_5.html#SEC5

 

 
 

 

Kittur_G_Intel
Employee
76 Views

Thanks Judy, that makes sense and I did try out as well. It had to conform to what you indicated, appreciate much.

Kittur

Kevin_D_Intel
Employee
76 Views

The GNU ld @<file> option can be used to augment the linker options.

@file
    Read command-line options from file.  The options read are inserted
    in place of the original @file option.  If file does not exist, or
    cannot be read, then the option will be treated literally, and not
    removed.

    Options in file are separated by whitespace.  A whitespace
    character may be included in an option by surrounding the entire
    option in either single or double quotes.  Any character (including
    a backslash) may be included by prefixing the character to be
    included with a backslash.  The file may itself contain additional
    @file options; any such options will be processed recursively.

For example:

$ cat h.cpp
#include <iostream>

int main() {
 std::cout << "Testing...." << std::endl;
 return 0;
}

$ cat h.lds
-V -L./mypath

$ icpc -Wl,@h.lds h.cpp
GNU ld version 2.23.52.0.1-55.el7 20130226
  Supported emulations:
   elf_x86_64
   elf32_x86_64
   elf_i386
   i386linux
   elf_l1om
   elf_k1om

 

Kittur_G_Intel
Employee
76 Views

That's correct, thx for pointing that out as well Kevin.

Kittur

Mario_K_
Beginner
76 Views

Thank you very much for these very helpful comments. The "@file" option is exactly what I've searched.

Kevin_D_Intel
Employee
76 Views

You're welcome. Glad to hear that.

Kittur_G_Intel
Employee
76 Views

Likewise, glad to hear it's resolved!

Kittur

Reply