Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Howto pass commands to the linker script via .pro file
QtWS25 Last Chance

Howto pass commands to the linker script via .pro file

Scheduled Pinned Locked Moved General and Desktop
linker qmake se
2 Posts 1 Posters 981 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Burner
    wrote on last edited by
    #1

    I'm using Qt 5.3.2 with GCC 4.8.2. I have legacy C code in my project which I cannot change. But I need to reset its variables in order to reset the whole legacy codes state. But most of the variables are static and dont have functions to access them for resetting. Therefore I want to map the legacy codes variables to a defined section via the linker script, read them when starting my program and if needed write them back in order to reset this part of the program.

    What my linker script should look like to achieve this is something like this:

    SECTIONS
    {
      .legacy_vars :
      {
        *legacyModule.o (.bss)
        *legacyModule.o (.data)
        *legacyModule.o (COMMON)
      }
      .everything_else :
      {
        * (.bss)
        * (.data)
        * (COMMON)
        * (.text)
      }
    

    }

    I have already tried to pass this linker script with the value "QMAKE_LFLAGS" using "-T myscript.ldf" and just "myscript.ldf". But both ways result in errors since:

    1. qmake is creating an own linker script called "object_script" which defines the input files for the linkage.
    2. If I'm removing the object_script from the linkage no input files are being defined -> my project gets compiled but nothing is linked since no files are defined.
    3. If I'm adding the input files in my script with INPUT(...) it results in not linking with the error: "crt0_c.c:-1: Fehler: undefined reference to `WinMain@16'" "File not found: crt0_c.c" which is not a file of my project

    Is there a way i can achieve what I want?
    Thanks in advance!

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Burner
      wrote on last edited by
      #2

      Found a solution and posted it on stackoverflow:

      solution

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved