10466 questions

12474 answers

19396 comments

21924 members

0 votes
395 views 2 comments
by
Hi,

I will run a simple helloworld.c on my RUT955 but I can't find a guide or a tutorial to do this.

I have found the SDK guide to build the entire SDK but I need only to compile my program.

Please, can you suggest how I can do? I have tried to follow the OpenWRT guide but the SDK is a bit different from the RUT one

1 Answer

+1 vote
by
Hi,

There are OpenWRT instructions on how to compile the same helloworld.c with SDK.

https://openwrt.org/docs/guide-developer/helloworld/chapter2?s[]=hello&s[]=world

As it's a cross-compile method - it compiles on your PC and can be used to compile programs for multiple architectures, but default configuration should work for you without any issue.

EB.

EB.
by

Thanks for the suggestion.

I have followed the link but some errors come out when I try to compile.

In order, I have done the following step:

1) In the folder custom_feeds, I have created helloworld folder with helloworld.c and the following Makefile that I have copied fron openWRT guide as follow:

include $(TOPDIR)/rules.mk
# Name, version and release number
# The name and version of your package are used to define the variable to point to the build directory of your package: $(PKG_BUILD_DIR)
PKG_NAME:=helloworld
PKG_VERSION:=1.0
PKG_RELEASE:=1
# Source settings (i.e. where to find the source codes)
# This is a custom variable, used below
SOURCE_DIR:=/home/buildbot/helloworld
include $(INCLUDE_DIR)/package.mk
# Package definition; instructs on how and where our package will appear in the overall configuration menu ('make menuconfig')
define Package/helloworld
  SECTION:=examples
  CATEGORY:=Examples
  TITLE:=Hello, World!
endef
# Package description; a more verbose description on what our package does
define Package/helloworld/description
  A simple "Hello, world!" -application.
endef
# Package preparation instructions; create the build directory and copy the source code. 
# The last command is necessary to ensure our preparation instructions remain compatible with the patching system.
define Build/Prepare
        mkdir -p $(PKG_BUILD_DIR)
        cp $(SOURCE_DIR)/* $(PKG_BUILD_DIR)
        $(Build/Patch)
endef
# Package build instructions; invoke the target-specific compiler to first compile the source file, and then to link the file into the final executable
define Build/Compile
        $(TARGET_CC) $(TARGET_CFLAGS) -o $(PKG_BUILD_DIR)/helloworld.o -c $(PKG_BUILD_DIR)/helloworld.c
        $(TARGET_CC) $(TARGET_LDFLAGS) -o $(PKG_BUILD_DIR)/$1 $(PKG_BUILD_DIR)/helloworld.o
endef
# Package install instructions; create a directory inside the package to hold our executable, and then copy the executable we built previously into the folder
define Package/helloworld/install
        $(INSTALL_DIR) $(1)/usr/bin
        $(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld $(1)/usr/bin
endef
# This command is always the last, it uses the definitions and variables we give above in order to get the job done
$(eval $(call BuildPackage,helloworld))
2) I added "src-link helloworld ../custom_feed/helloworld" in the feeds.conf.default
3) I do the command ./scripts/feeds install helloworld and the result was
Collecting package info: done
Collecting target info: done
Ignoring feed 'luci' - index missing
Ignoring feed 'rut_feeds' - index missing
Ignoring feed 'helloworld' - index missing
WARNING: No feed for package 'helloworld' found, maybe it's already part of the standard packages?
4) After I run ./scripts/feeds update helloworld and I obtained:
Updating feed 'helloworld' from '../custom_feed/helloworld' ...
Create index file './feeds/helloworld.index' 
Collecting package info: done
5) Finally, I do make package/helloworld/compile but I receive this error
 make[1] package/helloworld/compile
make -r package/helloworld/compile: build failed. Please re-run make with V=s to see what's going on
/home/user/Scrivania/rut_sdk/include/toplevel.mk:169: set di istruzioni per l'obiettivo "package/helloworld/compile" non riuscito
make: *** [package/helloworld/compile] Errore 1
Thanks for the help.
B
by

Hi,

I am sorry for being insistent, but I haven't experienced whit these things. Unfortunately, I'm stuck several days on this point
I have seen that the RUT SDK is a little different from this https://openwrt.org/docs/guide-developer/helloworld/chapter2?s[]=hello&s[]=world