- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 theSECTIONS
orMEMORY
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Judy, that makes sense and I did try out as well. It had to conform to what you indicated, appreciate much.
Kittur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That's correct, thx for pointing that out as well Kevin.
Kittur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much for these very helpful comments. The "@file" option is exactly what I've searched.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You're welcome. Glad to hear that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Likewise, glad to hear it's resolved!
Kittur

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page