Problem with linking static libraries and build system

Discuss how to use the features of Atollic TrueSTUDIO, including the editor, assembler, C/C++ compiler, linker, debugger, static code analysis and team collaboration tools.

Moderators: Markus Girdland, Mattias Norlander

piotr
Posts: 5
Joined: Fri Feb 03, 2017 10:21 am

Problem with linking static libraries and build system

Postby piotr » Fri Feb 03, 2017 10:43 am

Hello,

I decided to migrate my projects from System Workbench to Atollic 7.1.0 and have problems with build system:

1) Linker problem: My main application uses static libraries, that are built as other projects in the same workspace. In project properties, all dependencies, libraries and library paths are configured correctly ('C/C++ Build -> Settings -> Tool Settings -> C++ Linker -> Libraries' and 'C/C++ General -> Paths and Symbols -> Libraries, Library Paths, References'). It seems that these settings are ignored when linking. Static library files exist and naming convention is in line with GCC.
I cannot find in the Console invoking of linker instruction.

2) Build problem: when I do Build, build system first does incremental build of active configuration of dependency and then does Rebuild of referenced configuration (Project Properties -> C/C++ General -> Paths and Symbols -> References). It unnecessarily compiles active configuration and unnecessarily makes Rebuild of the referenced (Build would be enough). That makes the build very slow.
Release configuration of the executable project references Release configurations only, and Debug configuration references Debug configurations only.
It looks like unchecking Project Properties -> Project References solves this issue, but switching between configuration checks all the checkboxes back.

Could you please help me to solve this problems?

Thanks

Mattias Norlander
Posts: 273
Joined: Fri Apr 29, 2016 10:01 am

Re: Problem with linking static libraries and build system

Postby Mattias Norlander » Wed Feb 08, 2017 8:26 am

Hi Piotr,

#1: Could you post your build log so that we can see + a screenshot of the Linker settings in the tool settings GUI?

#2: This seem to be a problem. In some cases it works, in some it does not. Will file a bug report.

piotr
Posts: 5
Joined: Fri Feb 03, 2017 10:21 am

Re: Problem with linking static libraries and build system

Postby piotr » Wed Feb 08, 2017 9:07 am

Hi Mattias,

Thanks for your response. Below log and linker details.

Build log:
09:39:06 **** Incremental Build of configuration Debug for project stm32f7_main ****
Info: Internal Builder is used for build
arm-atollic-eabi-g++ -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -std=c++11 -IC:\ws_stm32f7_atollic\library_project -O0 -g3 -fstack-usage -Wall -fno-threadsafe-statics -o src\main.o ..\src\main.cpp
c:/program files (x86)/atollic/truestudio for arm 7.1.0/armtools/bin/../lib/gcc/arm-atollic-eabi/5.3.1/../../../../arm-atollic-eabi/bin/ld.exe: warning: cannot find entry symbol _start; defaulting to 0000800c
C:\AppData\Local\Temp\ccWsIqdu.o: In function `main':
C:\ws_stm32f7_atollic\stm32f7_main\Debug/..\src/main.cpp:24: undefined reference to `LibraryInit'
C:\ws_stm32f7_atollic\stm32f7_main\Debug/..\src/main.cpp:39: undefined reference to `RunTest()'
c:/program files (x86)/atollic/truestudio for arm 7.1.0/armtools/bin/../lib/gcc/arm-atollic-eabi/5.3.1/../../../../arm-atollic-eabi/lib/armv7e-m/fpu/fpv5-sp-d16\libc.a(lib_a-abort.o): In function `abort':
abort.c:(.text.abort+0xa): undefined reference to `_exit'
c:/program files (x86)/atollic/truestudio for arm 7.1.0/armtools/bin/../lib/gcc/arm-atollic-eabi/5.3.1/../../../../arm-atollic-eabi/lib/armv7e-m/fpu/fpv5-sp-d16\libc.a(lib_a-signalr.o): In function `_kill_r':
signalr.c:(.text._kill_r+0xe): undefined reference to `_kill'
c:/program files (x86)/atollic/truestudio for arm 7.1.0/armtools/bin/../lib/gcc/arm-atollic-eabi/5.3.1/../../../../arm-atollic-eabi/lib/armv7e-m/fpu/fpv5-sp-d16\libc.a(lib_a-signalr.o): In function `_getpid_r':
signalr.c:(.text._getpid_r+0x0): undefined reference to `_getpid'
c:/program files (x86)/atollic/truestudio for arm 7.1.0/armtools/bin/../lib/gcc/arm-atollic-eabi/5.3.1/../../../../arm-atollic-eabi/lib/armv7e-m/fpu/fpv5-sp-d16\libc.a(lib_a-mallocr.o): In function `_malloc_r':
mallocr.c:(.text._malloc_r+0x42c): undefined reference to `malloc_getpagesize_P'
mallocr.c:(.text._malloc_r+0x43c): undefined reference to `malloc_getpagesize_P'
c:/program files (x86)/atollic/truestudio for arm 7.1.0/armtools/bin/../lib/gcc/arm-atollic-eabi/5.3.1/../../../../arm-atollic-eabi/lib/armv7e-m/fpu/fpv5-sp-d16\libc.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text._sbrk_r+0xc): undefined reference to `_sbrk'
c:/program files (x86)/atollic/truestudio for arm 7.1.0/armtools/bin/../lib/gcc/arm-atollic-eabi/5.3.1/../../../../arm-atollic-eabi/lib/armv7e-m/fpu/fpv5-sp-d16\libc.a(lib_a-freer.o): In function `_malloc_trim_r':
mallocr.c:(.text._malloc_trim_r+0xa8): undefined reference to `malloc_getpagesize_P'
collect2.exe: error: ld returned 1 exit status
Info: Parallel threads used: 1

09:39:06 Build Finished (took 408ms)


Project properties -> C/C++ Build -> Settings -> Tool Settings -> C++ Linker:

Command: arm-atollic-eabi-g++
All options: -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -T"C:\ws_stm32f7_atollic\stm32f7_main\STM32F765IIKx_FLASH.ld" -Wl,--start-group -lc -lm -lstdc++ -lsupc++ -Wl,--end-group -specs=nano.specs -specs=nosys.specs -static -L"C:\ws_stm32f7_atollic\library_project\Debug" -Wl,-cref,-u,Reset_Handler "-Wl,-Map=${BuildArtifactFileBaseName}.map" -Wl,--defsym=malloc_getpagesize_P=0x1000
Command line pattern: ${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}
Project properties -> C/C++ Build -> Settings -> Tool Settings -> C++ Linker -> General:
Linker script: (tested with GCC on System Workbench - without problems)
Runtime Library: Reduced C and C++
System calls: minimal implementation
Only 'No shared libraries' selected.
Project properties -> C/C++ Build -> Settings -> Tool Settings -> C++ Linker -> Libraries:
Libraries: library_project
Library search path: "${workspace_loc:/library_project/Debug}"
(library file exist in this directory, its name is liblibrary_project.a)

Cheers,
Piotr

piotr
Posts: 5
Joined: Fri Feb 03, 2017 10:21 am

Re: Problem with linking static libraries and build system

Postby piotr » Mon Feb 13, 2017 5:29 pm

Do you have any insights?

This linking issue prevents me from using Atollic TrueStudio.

Thank you,
Piotr

Mattias Norlander
Posts: 273
Joined: Fri Apr 29, 2016 10:01 am

Re: Problem with linking static libraries and build system

Postby Mattias Norlander » Tue Feb 14, 2017 6:44 am

How did you migrate your project from Ac6 into Atollic TrueSTUDIO?
Did you start new projects from scratch in TrueSTUDIO or did you do any sort of import?

Is it possible that you are missing the "-c" on the "C compiler" or "C++ Compiler" or "Assembler"?
This question arises because of the following line you mentioned:
arm-atollic-eabi-g++ -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -std=c++11 -IC:\ws_stm32f7_atollic\library_project -O0 -g3 -fstack-usage -Wall -fno-threadsafe-statics -o src\main.o ..\src\main.cpp


It should most likely say:
arm-atollic-eabi-g++ -c -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -std=c++11 -IC:\ws_stm32f7_atollic\library_project -O0 -g3 -fstack-usage -Wall -fno-threadsafe-statics -o src\main.o ..\src\main.cpp

piotr
Posts: 5
Joined: Fri Feb 03, 2017 10:21 am

Re: Problem with linking static libraries and build system

Postby piotr » Tue Feb 14, 2017 9:50 am

Thanks, it works now! It was the missing -c switch so the linking was carried out too soon. That switch was probably deleted unintentionally during migration. I created new projects in TrueSTUDIO and modified some settings.

However now I encountered another problem. When I change setting in 'Project Properties -> C/C++ Build -> Settings - > Tool Settings -> Target' to 'Hardware implementation' of floating point (Thumb2 and FPv5-SP-D16), then click 'Apply' and then 'OK' and reopen project properties, it is back 'Software implementation'. But during compilation it uses '-mfloat-abi=hard'. So it looks like settings that I see are not in line with the compilation command I see in the console. It is strange, I used to change it already and it worked fine..
Restarting TrueSTUDIO does not help. I also made sure I'm looking at correct build configuration in the settings.

It also seems that debug configurations that I created before for j-link and st-link are lost. Is it possible that at any circumstances TrueSTUDIO can delete them?

Thanks again for your support,
Piotr

piotr
Posts: 5
Joined: Fri Feb 03, 2017 10:21 am

Re: Problem with linking static libraries and build system

Postby piotr » Thu Feb 16, 2017 4:22 pm

When I change e.g. C++ standard in Tool Settings -> C++ Compiler -> General, it is preserved. Looks like the issue concerns only 'Target' section...

Mattias Norlander
Posts: 273
Joined: Fri Apr 29, 2016 10:01 am

Re: Problem with linking static libraries and build system

Postby Mattias Norlander » Fri Feb 17, 2017 2:12 pm

Hi Piotr,

I know that there is a bug inte project wizard currently not taking writing down some changes into the project file. But I dont think it is on this tab. Will notify support-team to investigate and perhaps fix for next release.

Torbjörn Svensson
Posts: 12
Joined: Thu Mar 02, 2017 6:53 pm

Re: Problem with linking static libraries and build system

Postby Torbjörn Svensson » Tue Mar 07, 2017 1:34 pm

We just released TrueSTUDIO 7.1.1 that fixes these issues.


Return to “Atollic TrueSTUDIO tool discussions”

Who is online

Users browsing this forum: No registered users and 6 guests