How to build libfilex.a

Sai 45 Reputation points
2023-09-04T10:04:58.8433333+00:00

I built libthreadx.a and linked to my application to threadx kernel, it seems work well.

When I tried to built filex library, I used "include_directories" and change "target_link_libraries" to relative path to build secussfully. But this doesn’t seem to be the original intention of cmake project.

I am quit new with cmake.With help from the Azure RTOS team, I learned threadx and tested it. So here I am again looking for help.

Thanks!

Azure RTOS
Azure RTOS
An Azure embedded development suite including a small but powerful operating system for resource-constrained devices.
333 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Sai 45 Reputation points
    2023-09-05T06:12:17.5366667+00:00

    I followed https://github.com/azure-rtos/threadx and built threadx library. When I followed the build steps of filex, compilation failed at step 5 https://github.com/azure-rtos/filex#:~:text=Building%20as%20a%20static%20library. The error message is

    CMake Error at CMakeLists.txt:19 (add_library):
      Target "filex" links to target "azrtos::threadx" but the target was not
      found.  Perhaps a find_package() call is missing for an IMPORTED target, or
      an ALIAS target is missing?
    
    

    I changed CMakeLists.txt and built filex library successffuly. But I do not know the changes is whether proper.

    if(NOT FX_STANDALONE_ENABLE)
        target_link_libraries(${PROJECT_NAME} PUBLIC
            "libthreadx.a"
        )
        target_include_directories(${PROJECT_NAME} PUBLIC ../threadx/common/inc)
        target_include_directories(${PROJECT_NAME} PUBLIC ../threadx/ports/cortex_m4/gnu/inc)
        link_directories(${CMAKE_CURRENT_BINARY_DIR}/../threadx/build)
    endif()
    
    
    .
    ├── filex
    └── threadx
    

  2. LeelaRajeshSayana-MSFT 15,886 Reputation points Microsoft Employee
    2023-09-26T18:34:24.43+00:00

    Hi @Sai I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to accept the answer .

    Error Message:

    CMake Error at CMakeLists.txt:19 (add_library):
      Target "filex" links to target "azrtos::threadx" but the target was not
      found.  Perhaps a find_package() call is missing for an IMPORTED target, or
      an ALIAS target is missing?
    
    

    Solution:

    Changing the CMakeLists.txt as follows resulted to built filex library successfully.

    if(NOT FX_STANDALONE_ENABLE)
        target_link_libraries(${PROJECT_NAME} PUBLIC
            "libthreadx.a"
        )
        target_include_directories(${PROJECT_NAME} PUBLIC ../threadx/common/inc)
        target_include_directories(${PROJECT_NAME} PUBLIC ../threadx/ports/cortex_m4/gnu/inc)
        link_directories(${CMAKE_CURRENT_BINARY_DIR}/../threadx/build)
    endif()
    
    

    . ├── filex └── threadx

    If I missed anything please let me know and I'd be happy to add it to my answer, or feel free to comment below with any additional information.

    I hope this helps!

    If you have any other questions, please let me know. Thank you again for your time and patience throughout this issue.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.