OpenWrt Forum Archive

Topic: Crosscompile oder GCC

The content of this topic has been archived on 7 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hello everybody i have a little from to compile a *.c File like tunslip6.c
I bought me an TPLink TL-MR3020 and then i followed the instructions from the Tutorial: http://www.heise.de/netze/artikel/Tasch … 40851.html
I flashed this Trunk-Firmware on it: openwrt-ar71xx-generic-tl-mr3020-v1-squashfs-factory.bin

Now I'am trying to compile my C-File, but on OpenWRT i could not install gcc! I tried it with "opkg install gcc" !
If I want to cross compile my C-File on another Linux Machine, first which SDK is the correct ?
I tryed to crosscompile my C-File, after i followed the Instruction from this Page: http://manoftoday.wordpress.com/2007/10 … r-openwrt/
Then I copied my new compiled package on my tl-mr3020 and tried to install it with "opkg install" but then i got the error that this package is for another processor!

Did somebody may have an Idea what could i do wink ?

Greetz
Patrick

Hello towolf,
first thanks for your very helpfull Links. i followed the instruction from your first link and loaded over svn the trunk to my PC.
Then I created a folder under /package/ which name is tunslip6! In this folder i created an folder which is named src and i created an Makefile with the following Input:

--------------------------------------------------------------------------------------------------------
##############################################
# OpenWrt Makefile for helloworld program
#
#
# Most of the variables used here are defined in
# the include directives below. We just need to
# specify a basic description of the package,
# where to build our program, where to find
# the source files, and where to install the
# compiled program on the router.
#
# Be very careful of spacing in this file.
# Indents should be tabs, not spaces, and
# there should be no trailing whitespace in
# lines that are not commented.
#
##############################################

include $(TOPDIR)/rules.mk

# Name and release number of this package
PKG_NAME:=tunslip6
PKG_RELEASE:=1

# This specifies the directory where we're going to build the program.
# The root build directory, $(BUILD_DIR), is by default the build_mipsel
# directory in your OpenWrt SDK directory
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)

include $(INCLUDE_DIR)/package.mk

# Specify package information for this program.
# The variables defined here should be self explanatory.
define Package/tunslip6
    SECTION:=utils
    CATEGORY:=Utilities
    TITLE:=tunslip6 -- prints a snarky message
    If you can't figure out what this program does, \\\
    you're probably brain-dead and need immediate \\\
    medical attention.
endef

# Specify what needs to be done to prepare for building the package.
# In our case, we need to copy the source files to the build directory.
# This is NOT the default.  The default uses the PKG_SOURCE_URL and the
# PKG_SOURCE which is not defined here to download the source from the web.
# In order to just build a simple program that we have just written, it is
# much easier to do it this way.
define Build/Prepare
    mkdir -p $(PKG_BUILD_DIR)
    $(CP) ./src/* $(PKG_BUILD_DIR)/
endef

# We do not need to define Build/Configure or Build/Compile directives
# The defaults are appropriate for compiling a simple program such as this one

# Specify where and how to install the program. Since we only have one file,
# the helloworld executable, install it by copying it to the /bin directory on
# the router. The $(1) variable represents the root directory on the router running
# OpenWrt. The $(INSTALL_DIR) variable contains a command to prepare the install
# directory if it does not already exist.  Likewise $(INSTALL_BIN) contains the
# command to copy the binary file from its current location (in our case the build
# directory) to the install directory.
define Package/tunslip6/install
    $(INSTALL_DIR) $(1)/bin
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/tunslip6 $(1)/bin/
endef

# This line executes the necessary commands to compile our program.
# The above define directives specify all the information needed, but this
# line calls BuildPackage which in turn actually uses this information to
# build a package.
$(eval $(call BuildPackage,tunslip6))
--------------------------------------------------------------------------------------------------------------------

Now in the src folder i copied the tunslip6.c File and Created an Makefile with the following Input:


-----------------------------------------------------------------------------------------------------------------------
tunslip6: tunslip6.o
    $(CC) $(LDFLAGS) tunslip6.o -o tunslip6
tunslip6.o: tunslip6.c
    $(CC) $(CFLAGS) -c tunslip6.c

# remove object files and executable when user executes "make clean"
clean:
    rm *.o tunslip6

----------------------------------------------------------------------------------------
/trunk/package/tunslip6/Makfile
/trunk/package/tunslip6/src/Makefile
/trunk/package/tunslip6/src/tunslip6.c
----------------------------------------------------------------------------------------------

Now if I run the make v=99 comand i got this error:

-------------------------------------------------------------------------------------------
ERROR: please fix package/helloworld/Makefile - see logs/package/tunslip6/dump.txt for details
-------------------------------------------------------------------------------------------

If i now look in the file /logs/package/tunslip6/dump.txt I doesn't see any error:

dump.txt:
--------------------------------------------------------------------------------
Makefile:73: *** commands commence before first target.  Stop.
--------------------------------------------------------------------------------


Could somebody please help me!
Thanks

Contents of "Package/tunslip6" must be indented with spaces, contents of "Build/Prepare" and "Package/tunslip6/install" must be indented with tabs because they're actually shell commands.

Hello jow
thanks for your very very Helpfull Reply. Now I got it working!
THANKS

Greetz
Patrick

The discussion might have continued from here.