Author Topic: Advanced compiler option: write $link object to a file  (Read 3058 times)

Offline JNo

  • Single posting newcomer
  • *
  • Posts: 7
Advanced compiler option: write $link object to a file
« on: March 25, 2024, 02:29:13 pm »
hello,

I have a particular need for definition of lin obects files to static library:

In command line macro I want to write each object in file as:
objects\file1.o
objects\file2.o
....

then launch cmd:
for /f %%i in (obj.txt) do @echo $liblinker %%i

if I generate file I use following command FOR %%i IN ($link_objects) DO @echo %%i > file.txt
I encounter command line leght limitation.

How I can  generate this temporary file

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1632
Re: Advanced compiler option: write $link object to a file
« Reply #1 on: March 25, 2024, 03:43:55 pm »
Use response files.

Offline lastageoven

  • Single posting newcomer
  • *
  • Posts: 1
Re: Advanced compiler option: write $link object to a file
« Reply #2 on: September 30, 2024, 03:37:11 am »
To avoid the command line length limitation, you can split the list of object files into smaller groups. Use a batch script to process each group like this:
setlocal enabledelayedexpansion
set count=0
set max=100  REM Adjust this number as needed
pizza tower
for /f %%i in (obj.txt) do (
    @echo $liblinker %%i >> file.txt
    set /a count+=1
    if !count! geq %max% (
        set count=0
        echo Processing next batch...
    )
)
This way, you can write to file.txt without hitting the command line length limit.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1632
Re: Advanced compiler option: write $link object to a file
« Reply #3 on: September 30, 2024, 09:03:10 am »
Spam reported to moderator.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6023
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Advanced compiler option: write $link object to a file
« Reply #4 on: September 30, 2024, 09:27:42 am »
Our anti spam firewall is too bad. :(

I mainly guess this lastageoven was a real person.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.