Gcc - How to remove all absolute path from static library output (.a)

I am using GCC for ARM ( Red Suite 4 NXP ). I am building static library files (.a) that are used for the final application. I need to configure a project so that any developer can create the same static library content. (This is mainly so that a new developer can verify that they are configured correctly.) I have two copies of my project (two checks from SVN). When I build with each one I notice some absolute path information in the static library .a files. This means that SVN is detecting changes. I am already using the ar -D (deterministic) option. Are there other options for removing path information? I tried gcc -s but it didn't work (it seems this is only for the final executable, not the libraries)

I don't know where / why the absolute paths are in .a, but I can provide more information if someone can point me in the right direction.

I looked through the man pages of the strip utility (haven't tried it yet), would it remove this path information?

Also, I am using Red Suite for project management, so I am trying to do something in Red Suite (and let it do it). However, if there is a gcc or ar option that I need to tweak, I know how. I just don't know which option to change.

Here is the build console output. This causes the absolute path of my project to be included in the resulting .a. This is what I am trying to fix.

**** Build of configuration Release for project lib_touch ****

make -j all 
Building file: C:/Users/my_user_name/Documents/My Project Verification build/src/touch/Touch.c
Building file: C:/Users/my_user_name/Documents/My Project Verification build/src/touch/TouchCalibration.c
Building file: C:/Users/my_user_name/Documents/My Project Verification build/src/touch/TouchPoint.c
Building file: C:/Users/my_user_name/Documents/My Project Verification build/src/touch/TouchEventQueue.c
Invoking: MCU C Compiler
Invoking: MCU C Compiler
arm-none-eabi-gcc -D__REDLIB__ -DNDEBUG -D__CODE_RED -D__USE_CMSIS=CMSISv2p00_LPC177x_8x -I"C:\Users\my_user_name\Documents\My Project Verification build\src\build\RedSuite4NXP\CMSISv2p00_LPC177x_8x\inc" -I../../../../board -I../../../../board/lpc1788 -I../../../../communication -I../../../../events -I../../../../geometry -I../../../../graphics -I../../../../hmilogic/include -I../../../../sound -I../../../../util -O3 -Wall -Werror -c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections -std=gnu99 -mcpu=cortex-m3 -mthumb -MMD -MP -MF"touch/Touch.d" -MT"touch/Touch.d" -o"touch/Touch.o" "C:/Users/my_user_name/Documents/My Project Verification build/src/touch/Touch.c"
arm-none-eabi-gcc -D__REDLIB__ -DNDEBUG -D__CODE_RED -D__USE_CMSIS=CMSISv2p00_LPC177x_8x -I"C:\Users\my_user_name\Documents\My Project Verification build\src\build\RedSuite4NXP\CMSISv2p00_LPC177x_8x\inc" -I../../../../board -I../../../../board/lpc1788 -I../../../../communication -I../../../../events -I../../../../geometry -I../../../../graphics -I../../../../hmilogic/include -I../../../../sound -I../../../../util -O3 -Wall -Werror -c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections -std=gnu99 -mcpu=cortex-m3 -mthumb -MMD -MP -MF"touch/TouchCalibration.d" -MT"touch/TouchCalibration.d" -o"touch/TouchCalibration.o" "C:/Users/my_user_name/Documents/My Project Verification build/src/touch/TouchCalibration.c"
Invoking: MCU C Compiler
Invoking: MCU C Compiler
arm-none-eabi-gcc -D__REDLIB__ -DNDEBUG -D__CODE_RED -D__USE_CMSIS=CMSISv2p00_LPC177x_8x -I"C:\Users\my_user_name\Documents\My Project Verification build\src\build\RedSuite4NXP\CMSISv2p00_LPC177x_8x\inc" -I../../../../board -I../../../../board/lpc1788 -I../../../../communication -I../../../../events -I../../../../geometry -I../../../../graphics -I../../../../hmilogic/include -I../../../../sound -I../../../../util -O3 -Wall -Werror -c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections -std=gnu99 -mcpu=cortex-m3 -mthumb -MMD -MP -MF"touch/TouchEventQueue.d" -MT"touch/TouchEventQueue.d" -o"touch/TouchEventQueue.o" "C:/Users/my_user_name/Documents/My Project Verification build/src/touch/TouchEventQueue.c"
Finished building: C:/Users/my_user_name/Documents/My Project Verification build/src/touch/Touch.c
arm-none-eabi-gcc -D__REDLIB__ -DNDEBUG -D__CODE_RED -D__USE_CMSIS=CMSISv2p00_LPC177x_8x -I"C:\Users\my_user_name\Documents\My Project Verification build\src\build\RedSuite4NXP\CMSISv2p00_LPC177x_8x\inc" -I../../../../board -I../../../../board/lpc1788 -I../../../../communication -I../../../../events -I../../../../geometry -I../../../../graphics -I../../../../hmilogic/include -I../../../../sound -I../../../../util -O3 -Wall -Werror -c -fmessage-length=0 -fno-builtin -ffunction-sections -fdata-sections -std=gnu99 -mcpu=cortex-m3 -mthumb -MMD -MP -MF"touch/TouchPoint.d" -MT"touch/TouchPoint.d" -o"touch/TouchPoint.o" "C:/Users/my_user_name/Documents/My Project Verification build/src/touch/TouchPoint.c"

Finished building: C:/Users/my_user_name/Documents/My Project Verification build/src/touch/TouchEventQueue.c
Finished building: C:/Users/my_user_name/Documents/My Project Verification build/src/touch/TouchCalibration.c


Finished building: C:/Users/my_user_name/Documents/My Project Verification build/src/touch/TouchPoint.c

Building target: lib_touch.a
Invoking: MCU Archiver
arm-none-eabi-ar -rD "lib_touch.a"  ./touch/Touch.o ./touch/TouchCalibration.o ./touch/TouchEventQueue.o ./touch/TouchPoint.o   
c:\code_red\RedSuiteNXP_4.3.0_1033\redsuite\tools\bin\arm-none-eabi-ar.exe: creating lib_touch.a
Finished building target: lib_touch.a

make --no-print-directory post-build
Performing post-build steps
arm-none-eabi-size "lib_touch.a" ; cp "lib_touch.a" "../../../../lib/lib_touch.a"; # arm-none-eabi-objdump -h -S "lib_touch.a" >"lib_touch.lss"
   text    data     bss     dec     hex filename
   1864       0     156    2020     7e4 Touch.o (ex lib_touch.a)
    576       0       0     576     240 TouchCalibration.o (ex lib_touch.a)
    320       0       0     320     140 TouchEventQueue.o (ex lib_touch.a)
     96       0       0      96      60 TouchPoint.o (ex lib_touch.a)

      

UPDATE: MORE INFORMATION

I did some more digging and it seems like the full path to the file is before the string constant. The path data in the .a file shows

C:/Users/my_user_name/Documents/My Project Verification build/src/touch/Touch.c.TouchIdleTimer

      

I have a string literal "TouchIdleTimer" in my Touch.c file. This is the reason? How to remove part of the path, or is it possible? TIA

+3


source to share


1 answer


Update

Via this answer in GCC: Static links to only some libraries

Note. If you use the full path to the .so file, it will be dynamically linked again.




Extended static library support in Code Red IDE v4: Creating static library projects

Search around. I see suggestions for -fPIC

or -fPIC

. It was recommended in this comment thread in response to a question similar to yours.

3.2 Shared Libraries and Static Libraries provides a good breakdown of building shared and static libraries.

You have listed static non-shared libraries, but just in case: How to write shared libraries

+2


source







All Articles