在eclipse MaxiSDK中,如何添加用户的代码到工程中,使用的IDE如下:
我是第一次使用这个IDE,偿试添加自己的工程文件,我偿试直接添加到工程根目录时,是可以不用配置工程,然后就可以参与编译了,如果添加了自己的文件夹,然后折腾了好久没有成功。
最后我找到了Makefile里面有说明如下:
# ******************************************************************************* # Set up search paths, and auto-detect all source code on those paths. # The following paths are searched by default, where "./" is the project directory. # ./ # |- *.h # |- *.c # |-include (optional) # |- *.h # |-src (optional) # |- *.c # Configuration Variables: # - VPATH : Tell this Makefile to search additional locations for source (.c) files. # You should use the "+=" operator with this option. # Ex: VPATH += your/new/path # - IPATH : Tell this Makefile to search additional locations for header (.h) files. # You should use the "+=" operator with this option. # Ex: VPATH += your/new/path # - SRCS : Tell this Makefile to explicitly add a source (.c) file to the build. # This is really only useful if you want to add a source file that isn't # on any VPATH, in which case you can add the full path to the file here. # You should use the "+=" operator with this option. # Ex: SRCS += your/specific/source/file.c # - AUTOSEARCH : Set whether this Makefile should automatically detect .c files on # VPATH and add them to the build. This is enabled by default. Set # to 0 to disable. If autosearch is disabled, source files must be # manually added to SRCS. # Ex: AUTOSEARCH = 0 # Where to find source files for this project.
然后在下面就有如下面的Makefile的配置:
# Where to find source files for this project. VPATH += . VPATH += src VPATH := $(VPATH) # Where to find header files for this project IPATH += . IPATH += include IPATH := $(IPATH) AUTOSEARCH ?= 1 ifeq ($(AUTOSEARCH), 1) # Auto-detect all C/C++ source files on VPATH SRCS += $(wildcard $(addsuffix /*.c, $(VPATH))) SRCS += $(wildcard $(addsuffix /*.cpp, $(VPATH))) endif # Collapse SRCS before passing them on to the next stage SRCS := $(SRCS)
为此,我图简单,在根目录下面添加一个src与一个include文件夹,将我自己的.c拷贝进src,将头文件添加进include下面,然后执行编译就可以了。
【小结】
我在工程设置,添加了头文件的路径,然后还是报错找不到头文件,因此,还需要在makefile中添加,才能参与编译。
如果工程不是很复杂,那简单的这样处理就行了,如果有再复杂的工程,那么还得在makefile中添加编译才行。