Libraries include

efi1234
Posts: 5
Joined: Fri May 17, 2019 2:43 pm

Libraries include

Postby efi1234 » Fri May 17, 2019 3:01 pm

Hello,

I'm using MSYS2 to compile and flash the ESP32.
My ESP-IDF library is defined as C:\msys32\home\user\esp\esp-idf
I need to include a header file which is located in a common library (for another project to use).
The header file is located in another drive D:\project\common
I tried to use EXTRA_COMPONENT_DIRS in makefile and tried some other stuff like COMPONENT_SRCDIRS & COMPONENT_ADD_INCLUDEDIRS for component.mk with no success. what I'm I doing wrong?
what is the difference between makfile, *.mk file and CMakeLists.txt which located in different libraries (when I'm using one of the examples)?

Thank you,

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: Libraries include

Postby Ritesh » Fri May 17, 2019 9:55 pm

efi1234 wrote:
Fri May 17, 2019 3:01 pm
Hello,

I'm using MSYS2 to compile and flash the ESP32.
My ESP-IDF library is defined as C:\msys32\home\user\esp\esp-idf
I need to include a header file which is located in a common library (for another project to use).
The header file is located in another drive D:\project\common
I tried to use EXTRA_COMPONENT_DIRS in makefile and tried some other stuff like COMPONENT_SRCDIRS & COMPONENT_ADD_INCLUDEDIRS for component.mk with no success. what I'm I doing wrong?
what is the difference between makfile, *.mk file and CMakeLists.txt which located in different libraries (when I'm using one of the examples)?

Thank you,
Please share your sample code with Makefile as well.

Also, There is no any much difference between makefile and *.mk files. There is a common make component in which all mk files are present which can be called from component mk file.

Espressif Team now started to move into CMake to reduce compilation time overall. So that is also one kind of tool or file which can be used to compile source code as per requirement.
Regards,
Ritesh Prajapati

efi1234
Posts: 5
Joined: Fri May 17, 2019 2:43 pm

Re: Libraries include

Postby efi1234 » Sun May 19, 2019 10:47 am

Hi,

Thank you for your reply,

My project tree:
i2c_esp32 dir--->
------------------CmakeLists.txt
------------------sdkconfig
------------------Makefile
------------------main dir --->
-------------------------CmakeLists.txt
-------------------------component.mk
-------------------------i2c_example_main.c
-------------------------kconfig.projbuild
------------------components dir --->
-------------------------CmakeLists.txt
-------------------------component.mk
-------------------------i2c_ctrl.c
-------------------------include dir --->
------------------------- i2c_ctrl.h


The file I want to include as I stated located in D:\project\common
right now I just copied the file to component\include directory to bypass the problem.
i2c_ctrl.h and i2c_example_main.c use #include to include the common file and use it.

Files contents:
i2c_esp32 dir--->
CmakeLists.txt:
# The following lines of boilerplate have to be in your project's CMakeLists
# in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
#set(EXTRA_COMPONENT_DIRS "$ENV{COMMON_PATH}")
project(i2c-example)

Makefile:
#
# This is a project Makefile. It is assumed the directory this Makefile resides in is a
# project subdirectory.
#

PROJECT_NAME := i2c-example
#EXTRA_COMPONENT_DIRS := COMMON_PATH
#COMPONENT_DIRS += $(COMMON_PATH)

include $(IDF_PATH)/make/project.mk

COMMON_PATH defined as D:\project\common using file .sh located in c:\msys2\etc\profile.d

main dir --->
CmakeLists.txt:
set(COMPONENT_SRCS "i2c_example_main.c")
set(COMPONENT_ADD_INCLUDEDIRS ".")
set(COMPONENT_PRIV_REQUIRES "/d/Projects/common") another thing I tried.
register_component()

component.mk
COMPONENT_ADD_INCLUDEDIRS += $(COMMON_PATH)

components dir --->
CmakeLists.txt
#
# Component Makefile
#
COMPONENT_ADD_INCLUDEDIRS := include
set(COMPONENT_SRCS "i2c_ctrl.c")
component.mk
#
# Component Makefile
#
COMPONENT_SRCDIRS += include
COMPONENT_ADD_INCLUDEDIRS += include

Can you please help my figure it out?

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: Libraries include

Postby Ritesh » Sun May 19, 2019 3:04 pm

efi1234 wrote:
Sun May 19, 2019 10:47 am
Hi,

Thank you for your reply,

My project tree:
i2c_esp32 dir--->
------------------CmakeLists.txt
------------------sdkconfig
------------------Makefile
------------------main dir --->
-------------------------CmakeLists.txt
-------------------------component.mk
-------------------------i2c_example_main.c
-------------------------kconfig.projbuild
------------------components dir --->
-------------------------CmakeLists.txt
-------------------------component.mk
-------------------------i2c_ctrl.c
-------------------------include dir --->
------------------------- i2c_ctrl.h


The file I want to include as I stated located in D:\project\common
right now I just copied the file to component\include directory to bypass the problem.
i2c_ctrl.h and i2c_example_main.c use #include to include the common file and use it.

Files contents:
i2c_esp32 dir--->
CmakeLists.txt:
# The following lines of boilerplate have to be in your project's CMakeLists
# in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
#set(EXTRA_COMPONENT_DIRS "$ENV{COMMON_PATH}")
project(i2c-example)

Makefile:
#
# This is a project Makefile. It is assumed the directory this Makefile resides in is a
# project subdirectory.
#

PROJECT_NAME := i2c-example
#EXTRA_COMPONENT_DIRS := COMMON_PATH
#COMPONENT_DIRS += $(COMMON_PATH)

include $(IDF_PATH)/make/project.mk

COMMON_PATH defined as D:\project\common using file .sh located in c:\msys2\etc\profile.d

main dir --->
CmakeLists.txt:
set(COMPONENT_SRCS "i2c_example_main.c")
set(COMPONENT_ADD_INCLUDEDIRS ".")
set(COMPONENT_PRIV_REQUIRES "/d/Projects/common") another thing I tried.
register_component()

component.mk
COMPONENT_ADD_INCLUDEDIRS += $(COMMON_PATH)

components dir --->
CmakeLists.txt
#
# Component Makefile
#
COMPONENT_ADD_INCLUDEDIRS := include
set(COMPONENT_SRCS "i2c_ctrl.c")
component.mk
#
# Component Makefile
#
COMPONENT_SRCDIRS += include
COMPONENT_ADD_INCLUDEDIRS += include

Can you please help my figure it out?
So, still not able to include common directory with include files?
Regards,
Ritesh Prajapati

efi1234
Posts: 5
Joined: Fri May 17, 2019 2:43 pm

Re: Libraries include

Postby efi1234 » Mon May 20, 2019 5:51 am

Still,

I need to figure it out soon - my company needs to deliver the software asap and this problem influence the schedule.
Please help if you can,

Thank you

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Libraries include

Postby WiFive » Mon May 20, 2019 9:42 am

I think you are mixing up some things

Make uses msys2 so you need to use syntax /d/project/common
Cmake uses native so you can use D:\project\common but it should run in Windows shell so you can't use profile.d

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: Libraries include

Postby Ritesh » Mon May 20, 2019 2:15 pm

efi1234 wrote:
Mon May 20, 2019 5:51 am
Still,

I need to figure it out soon - my company needs to deliver the software asap and this problem influence the schedule.
Please help if you can,

Thank you
Hi,

Would you please make sure that PATH is correct as you have mentioned that D:\project\common and "/d/Projects/common" which one is correct?

Also which ESP32 IDF you are using? It will be good if you can provide error logs over here so that we can have idea like what can be factors which can cause this type of issue
Regards,
Ritesh Prajapati

efi1234
Posts: 5
Joined: Fri May 17, 2019 2:43 pm

Re: Libraries include

Postby efi1234 » Tue May 21, 2019 6:46 am

Hi,

Thanks again,
Where can I see the error logs? or do you mean the compilation error?

I posted the project tree - which file should be changed (project dir has Makefile & CmakeLists.txt, main dir has component.mk & CmakeLists.txt, component dir has component.mk & CmakeLists.txt)? What is the exact command I should use? my tests and tries are not important - lets start fresh, what should be written exactly according to the PATH i posted?

My ESP-IDF version:
v4.0-dev-478-gdf61612f8-dirty

Thank you very much,

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: Libraries include

Postby Ritesh » Tue May 21, 2019 8:16 am

efi1234 wrote:
Tue May 21, 2019 6:46 am
Hi,

Thanks again,
Where can I see the error logs? or do you mean the compilation error?

I posted the project tree - which file should be changed (project dir has Makefile & CmakeLists.txt, main dir has component.mk & CmakeLists.txt, component dir has component.mk & CmakeLists.txt)? What is the exact command I should use? my tests and tries are not important - lets start fresh, what should be written exactly according to the PATH i posted?

My ESP-IDF version:
v4.0-dev-478-gdf61612f8-dirty

Thank you very much,
Yes. we need compilation error logs which you are facing as of now. Also would you please check with suggestions provided by WiFive?
Regards,
Ritesh Prajapati

efi1234
Posts: 5
Joined: Fri May 17, 2019 2:43 pm

Re: Libraries include

Postby efi1234 » Thu May 23, 2019 12:14 pm

Hi,

I tried what you wrote me and added the line:

EXTRA_COMPONENT_DIRS := /d/Projects/common

to Makefile,

This is what i get:

$ make
WARNING: esp-idf git submodule components/json/cJSON may be out of date. Run 'git submodule update' in IDF_PATH dir to update.
Toolchain path: /opt/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc
Toolchain version: crosstool-ng-1.22.0-80-g6c4433a5
Compiler version: 5.2.0
Python requirements from C:/msys32/home/efio/esp/esp-idf/requirements.txt are satisfied.

Project is not inside a git repository, will not use 'git describe' to determine PROJECT_VER.
App "i2c-example" version: 1
CC build/components/HostCommApp.o
In file included from C:/msys32/home/efio/esp/i2c_self_test/components/include/HostCommApp.h:6:0,
from C:/msys32/home/efio/esp/i2c_self_test/components/HostCommApp.c:7:
C:/msys32/home/efio/esp/i2c_self_test/components/include/i2c_ctrl.h:6:30: fatal error: comm_definitions.h: No such file or directory
compilation terminated.
make[1]: *** [/home/efio/esp/esp-idf/make/component_wrapper.mk:290: HostCommApp.o] Error 1
make: *** [C:/msys32/home/efio/esp/esp-idf/make/project.mk:582: component-components-build] Error 2

Who is online

Users browsing this forum: fengcai, Google [Bot] and 86 guests