Use "–defsym" in LDFLAGS

Sysprogs forums Forums VisualGDB Use "–defsym" in LDFLAGS

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #8424
    christoph.p
    Participant

    Hi!

    I’m trying to insert a timestamp in my linker Call. I modified the call to

    But the check says:

    i586-poky-linux-gcc.exe: error: +%s`: No such file or directory

    How to define the symbol with the date?

    Thx!

    • This topic was modified 8 years, 5 months ago by christoph.p.
    • This topic was modified 8 years, 5 months ago by christoph.p.
    • This topic was modified 8 years, 5 months ago by christoph.p.
    • This topic was modified 8 years, 5 months ago by christoph.p.
    #8434
    support
    Keymaster

    If you are building on Windows, please install MinGW/msys to use the Unix-style commands like ‘date’ and then specify the absolute path to the ‘date.exe’ from the msys directory so that it’s not confused with the Windows ‘date’ command.

    #8440
    christoph.p
    Participant

    Ok. I’ve check the command in the windows commandline with

    C:\date.exe +%s

    which outputs

    1466065030

    But I don’t know how to specify the LDFLAGS line…

    I tried

    • -Wl,-gc-sections,–defsym,TIMESTAMP=$(C:\date.exe +%s)
    • -Wl,-gc-sections,–defsym,TIMESTAMP=C:\date.exe +%s
    • -Wl,-gc-sections,–defsym,TIMESTAMP=$(“C:\date.exe” +%s)
    • -Wl,-gc-sections,–defsym,TIMESTAMP=$(“C:\date.exe +%s”)

    But nothing worked. I always get

    • collect2.exe: error: ld returned 1 exit status
    • i586-poky-linux-gcc.exe: error: +%s): No such file or directory
    • i586-poky-linux-gcc.exe: error: +%s`: No such file or directory

     

    #8448
    support
    Keymaster

    Hi,

    Please try this syntax:

    $(shell C:/date.exe +%s)
    #8461
    christoph.p
    Participant

    Returns:

    […]
    i586-poky-linux-gcc.exe: error: +%s): No such file or directory

    #8463
    support
    Keymaster

    Hi,

    OK, please try the following Makefile from the command line:

    test:
        gcc -DTIMESTAMP=$(shell C:/mingw/msys/1.0/bin/date.exe +%s) -E test.c -o test.E

    You can use it with the following test.c file:

    int timestamp = TIMESTAMP;

    If this does not work, please let us know the error you get with this simple file. If it does, please compare the syntax here with your Makefile.

    #8465
    christoph.p
    Participant

    That gives me:

    i586-poky-linux-gcc.exe: error: +%s): No such file or directory

    #8470
    support
    Keymaster

    Looks like you are still trying to use your Makefile with i586-poky-linux-gcc.exe.

    In order to isolate the problem please try using the minimal Makefile we provided (with the normal GCC from the MinGW toolchain and make.exe from MinGW as well). If it works, please try explicitly using the make.exe from the MinGW toolchain instead of make.exe from the i586-poky-linux toolchain.

    #9048
    christoph.p
    Participant

    Sorry I’m a little bit overwhelmed. Which paramters in the Config of the makefile do I have to change and how?</span></span>

    • This reply was modified 8 years, 2 months ago by christoph.p.
    #9053
    support
    Keymaster

    Please start with trying this Makefile literally:

    test:
    <TAB>gcc -DTIMESTAMP=$(shell C:/mingw/msys/1.0/bin/date.exe +%s) -E test.c -o test.E

    If it works, with your make.exe, please compare the syntax in it with your Makefile that is broken. If it does not, please download a clean MinGW toolchain from here and try using make.exe and mingw-make.exe from it.

    #9537
    christoph.p
    Participant

    I have created a bat file in windows with the following command:

    C:\Intel\iotdk-ide-win\devkit-x86\sysroots\x86_64-pokysdk-mingw32\usr\libexec\i586-poky-linux\gcc\i586-poky-linux\4.9.1\gcc.exe -DTIMESTAMP=$(shell C:/mingw/msys/1.0/bin/date.exe +%s) -E helloworld.c -o test.E

    This gives me also the error:

    >C:\Intel\iotdk-ide-win\devkit-x86\sysroots\x86_64-pokysdk-mingw32\usr\libexec\i586-poky-linux\gcc\i586-poky-linux\4.9.1\gcc.exe -DTIMESTAMP=$(shell C:/mingw/msys/1.0/bin/date.exe +s) -E helloworld.c -o test.E
    gcc.exe: error: +s): No such file or directory

    I think something with the part “$(shell C:/mingw/msys/1.0/bin/date.exe +s)” doesn’t work in Windows.

    Any hints?

    #9538
    support
    Keymaster

    Hi,

    The “$(shell)” expansion is specific to GNU Make. I.e. if you just put it into a .bat file, Windows won’t expand it, however if you put it into a Makefile as shown in the previous post and run make.exe from your toolchain, it should get substituted properly.

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.