Forum Discussion

adamShiau's avatar
adamShiau
Icon for New Contributor rankNew Contributor
11 months ago
Solved

How to Properly Include a Custom Library in Quartus Prime Nios II Project?

Hi,

I'm using Quartus Prime 18.1 to develop an FPGA project with Nios II.

I have written a UART library (uart.c and uart.h) that I want to include in my main code main.c.

Currently, the way I add the library to the project is shown in the attached picture.

However, using this method, I have to include both "uart.h" and "uart.c" in main.c to compile it correctly.

If I only include "uart.h", the methods defined in uart.c are not recognized by the compiler.

I would like to know how to properly set the library path so that I only need to include the header file.

Thank you!

Adam Shiau

  • Hi


    After adding the .c and .h into the project the make file should be update.

    Could you check if the .h and .c is added into the make file of you project?

    If not you would need to add them in manually.


    You could check the line below in the make file:


    # List of include directories for -I compiler option (-I added when used).

    # Includes the BSP.

    ALT_INCLUDE_DIRS := <File path here>

    # List of library directories for -L linker option (-L added when used).

    # Includes the BSP.

    ALT_LIBRARY_DIRS := <File path here>



    Regards

    Jingyang, Teh


3 Replies

  • tehjingy_Altera's avatar
    tehjingy_Altera
    Icon for Regular Contributor rankRegular Contributor

    Hi


    After adding the .c and .h into the project the make file should be update.

    Could you check if the .h and .c is added into the make file of you project?

    If not you would need to add them in manually.


    You could check the line below in the make file:


    # List of include directories for -I compiler option (-I added when used).

    # Includes the BSP.

    ALT_INCLUDE_DIRS := <File path here>

    # List of library directories for -L linker option (-L added when used).

    # Includes the BSP.

    ALT_LIBRARY_DIRS := <File path here>



    Regards

    Jingyang, Teh


  • tehjingy_Altera's avatar
    tehjingy_Altera
    Icon for Regular Contributor rankRegular Contributor

    Hi


    As we do not receive any response from you on the previous question/reply/answer that we have provided. Please login to ‘https://supporttickets.intel.com/s/?language=en_US’, view details of the desire request, and post a feed/response within the next 15 days to allow me to continue to support you. After 15 days, this thread will be transitioned to community support. The community users will be able to help you on your follow-up questions.


    Regards

    Jingyang, Teh