0

I am using cmake 3.20 for a C project in VSCode with MinGW.

I have several nested CMakeLists.txt and also use some imported libraries.

├─ src
│  ├─ Application
│  │  ├─ CMakeLists.txt
│  │  ├─ config
│  │  │  ├─ config_serial.c
│  │  │  ├─ config_serial.h
│  │  └─ main.c
│  ├─ Common
│  │  ├─ CMakeLists.txt
│  │  ├─ common.c
│  │  ├─ common.h
│  │  └─ common.h.in
│  ├─ ErrorHandler
│  │  ├─ CMakeLists.txt
│  │  ├─ error_handler.c
│  │  └─ error_handler.h

It was working fine until I decided to do some restructuring, where I decided to take the configfolder right under src and make a seperate library for it.

For the external libraries I use

# SET EXTERNAL LIBRARY PATH FOR ESX3CM LIBRARY
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/extern/esx3cm")
find_path(ESX3CM_INC NAMES "stwtypes.h" REQUIRED)

# ADD IMPORTED LIBRARY ESX3CM
add_library(ESX3CM STATIC IMPORTED)
set_property(TARGET ESX3CM PROPERTY
                            IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/extern/esx3cm/libesx3cm.a")

# LINK ESX3CM LIB
target_link_libraries(${PROJECT_NAME} PUBLIC ESX3CM)
target_include_directories(${PROJECT_NAME} PUBLIC "${ESX3CM_INC}")

linklibs.rsp before restructuring

  ../../libErrorHandler.a ../../../extern/esx3cm/libesx3cm.a ../../../extern/esx_3cm_osy/GCC_4_6_6_1/libesx3cm_osy_server.a ../../../extern/lwip/liblwip_esx3cm-Os.a ../../libCOMMON_WIN32.a -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 

Now I get a linker error saying it cannot find -lSTATIC.

When I check the linklibs.rsp file I can see all my libs plus an entry -lSTATIC. After restructuring I get

 ../../libConfig.a ../../libErrorHandler.a ../../libConfig.a ../../../extern/esx3cm/libesx3cm.a ../../../extern/esx_3cm_osy/GCC_4_6_6_1/libesx3cm_osy_server.a ../../../extern/lwip/liblwip_esx3cm-Os.a ../../libCOMMON_WIN32.a -lSTATIC -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 

Deleting this entry and recompile the project seems to work.

Any ideas how this -lSTATIC ends up in the list of libraries?

Thx Andy

0 Answers0