Skip to main content
OBorg.1
Associate II
October 12, 2022
Solved

Creating a static-lib project I want to use the GCC flag: fvisibility=hidden Adding this to the compiler flags it is not working. Many thanks in advance for helpful tips!

0693W00000UnvFVQAZ.jpg

This topic has been closed for replies.
Pavel A.
Pavel A.Best answer
October 19, 2022

You're making a static library (.a), not a .so. Visibility of publics applies only to exports of shared libraries.

6 replies

Semer CHERNI
ST Employee
October 14, 2022

Hello @OBorg.1​ 

First let me thank you for posting.

I am trying to investigate this issue and it would be very helpful if you provide me with:

  • What are you trying to achieve and why? 
  • Could you let us know the rest of the compiler linker settings?

I will be waiting for your feedback.

Kind regards,

Semer.

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
OBorg.1
OBorg.1Author
Associate II
October 14, 2022

Here are the other GCC settings:

-mcpu=cortex-m4 -std=gnu11 -g3 -DDEBUG -DUSE_HAL_DRIVER -DSTM32G431xx -c -I../Drivers/CMSIS/Device/ST/STM32G4xx/Include -I../Drivers/CMSIS/Include -I../Inc -I../Drivers/STM32G4xx_HAL_Driver/Inc -I../Drivers/STM32G4xx_HAL_Driver/Inc/Legacy -I"C:\Users\TE228673\SW_Dev\STM32CubeIDE\workspace_1.7.0\KMX-D\DESIGN_DEMOS\PRIVATE_INCLUDE_FILE_TEST_LIB\Module\PrivateLogicFunctions\Inc" -I"C:\Users\TE228673\SW_Dev\STM32CubeIDE\workspace_1.7.0\KMX-D\DESIGN_DEMOS\PRIVATE_INCLUDE_FILE_TEST_LIB\Module\PublicLogicFunctions\Inc" -O0 -ffunction-sections -fdata-sections -Wall -fvisibility=hidden -v -fstack-usage --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb

I am creating a static-lib project.

This project contains a lot of functions for internal use only. These functions MUST NOT be callable from outside the static lib.

Referring the: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options

This can usually be achieved by simply using the GCC flag:

-fvisibility=hidden

Unfortunately, this flag does not work in my project in CubeIde.

OBorg.1
OBorg.1Author
Associate II
October 18, 2022

Hello,

Unfortunately I still haven't found a solution to my problem.

I am looking for a solution in CubeIDE for the following situation:

I need to create a library which:

* implemented some functions that need to be callable from outside

* numerous functions implemented that must NOT be accessible from outside

I have to integrate this library later in an executable project.

How can I achieve this?

Pavel A.
Pavel A.Best answer
October 19, 2022

You're making a static library (.a), not a .so. Visibility of publics applies only to exports of shared libraries.

OBorg.1
OBorg.1Author
Associate II
October 19, 2022

Hello Pavel,

Many thanks for the explanations.

How is a requirement like mine implemented?

(This should be a common use case.)