4

我正在为 ARM 使用 GCC(Red Suite 4 NXP)。我正在编译用于最终应用程序的静态库文件 (.a)。我需要配置项目,以便任何开发人员都可以生成完全相同的静态库输出。(这主要是为了让新开发人员可以验证他们的设置是否正确。)我有两个项目副本(来自 SVN 的两个结帐)。当我使用每个构建时,我注意到静态库 .a 输出文件中的一些绝对路径信息。这意味着 SVN 会检测到变化。我已经在使用 ar -D (确定性)选项。是否有任何其他选项可以删除路径信息?我尝试了 gcc -s 但这不起作用(看来这仅适用于最终可执行文件,而不是库)

我不知道绝对路径在 .a 中的位置/原因,但如果有人能指出我正确的方向,我可以提供更多信息。

我查看了 strip 实用程序手册页(尚未尝试过),这会删​​除此路径信息吗?

另外,我正在使用 Red Suite 来管理项目,所以我正在尝试以 Red Suite 的方式做事(并让它做它的事)。但是,如果我需要调整 gcc 或 ar 选项,我确实知道该怎么做。我只是不知道要更改什么选项。

这是构建控制台输出。这会导致我的项目的绝对路径包含在生成的 .a 中。这就是我要解决的问题。

**** 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)

更新:更多信息

我做了更多的挖掘,看起来完整的文件路径位于字符串常量的前面。.a 文件中的路径数据显示

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

我在文件 Touch.c 中有一个字符串文字“TouchIdleTimer”。这是原因吗?我将如何删除路径部分,或者有可能吗?TIA

4

1 回答 1

2

更新

通过这个对GCC 的回答: static linking only some libraries

注意:如果您使用 .so 文件的完整路径,它将再次动态链接。


Code Red IDE v4 中增强的静态库支持:创建静态库项目

环顾四周,我看到了有关-fPICor的建议-fpic在此评论线程中建议您回答与您类似的问题。

3.2 共享库和静态库提供了编译共享库和静态库的一个很好的细分。

您说静态不是共享库,但以防万一:如何编写共享库

于 2013-02-07T01:44:27.857 回答