cancel
Showing results for 
Search instead for 
Did you mean: 

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!

OBorg.1
Associate III

0693W00000UnvFVQAZ.jpg

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

6 REPLIES 6
Semer CHERNI
ST Employee

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
Associate III

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
Associate III

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?

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

Hello Pavel,

Many thanks for the explanations.

How is a requirement like mine implemented?

(This should be a common use case.)

Maybe some more background information will help:

The code (several libraries) that I create should later be used in various executable MCU projects (by other developers) in the simplest possible way.

In order to prevent manipulation of the code, the actual C code must not be distributed.

(Hence my idea to use .a file(s))