OpenWrt Forum Archive

Topic: getting Error 2 while trying to make a package

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

I just started using White Russian, and Linux in general so I don't know much. I was trying to just make a hello world C program to test out white russian. I was using this guide and when It got to the makefile to make the package for white russian i was totally lost. I copied and pasted it, and used find and replace to change the filename. when i exectuted "make V=99" i got this


qazmonk@qazmonk-VirtualBox:~/Desktop/OpenWrt-SDK-Linux-x86_64-1$ make V=99
make package/compile
make[1]: Entering directory `/home/qazmonk/Desktop/OpenWrt-SDK-Linux-x86_64-1'
make -C package compile SDK=1
make[2]: Entering directory `/home/qazmonk/Desktop/OpenWrt-SDK-Linux-x86_64-1/package'
make -j1 compile-targets
make[3]: Entering directory `/home/qazmonk/Desktop/OpenWrt-SDK-Linux-x86_64-1/package'
make -C HelloPackage compile
Rebuilding /home/qazmonk/Desktop/OpenWrt-SDK-Linux-x86_64-1/bin/packages/helloWorld_1_mipsel.ipk
make[4]: Entering directory `/home/qazmonk/Desktop/OpenWrt-SDK-Linux-x86_64-1/package/HelloPackage'
CFLAGS="-Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -I/home/qazmonk/Desktop/OpenWrt-SDK-Linux-x86_64-1/staging_dir_mipsel/usr/include -I/home/qazmonk/Desktop/OpenWrt-SDK-Linux-x86_64-1/staging_dir_mipsel/include " LDFLAGS="-L/home/qazmonk/Desktop/OpenWrt-SDK-Linux-x86_64-1/staging_dir_mipsel/usr/lib -L/home/qazmonk/Desktop/OpenWrt-SDK-Linux-x86_64-1/staging_dir_mipsel/lib " make -C /home/qazmonk/Desktop/OpenWrt-SDK-Linux-x86_64-1/build_mipsel/helloWorld AR=mipsel-linux-uclibc-ar AS="mipsel-linux-uclibc-gcc -c -Os -pipe -mips32 -mtune=mips32 -funit-at-a-time" LD=mipsel-linux-uclibc-ld NM=mipsel-linux-uclibc-nm CC="mipsel-linux-uclibc-gcc" GCC="mipsel-linux-uclibc-gcc" CXX=mipsel-linux-uclibc-g++ RANLIB=mipsel-linux-uclibc-ranlib STRIP=mipsel-linux-uclibc-strip OBJCOPY=mipsel-linux-uclibc-objcopy CROSS="mipsel-linux-uclibc-" CXXFLAGS="-Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -I/home/qazmonk/Desktop/OpenWrt-SDK-Linux-x86_64-1/staging_dir_mipsel/usr/include -I/home/qazmonk/Desktop/OpenWrt-SDK-Linux-x86_64-1/staging_dir_mipsel/include " ARCH="mipsel" ;
make[5]: Entering directory `/home/qazmonk/Desktop/OpenWrt-SDK-Linux-x86_64-1/build_mipsel/helloWorld'
mipsel-linux-uclibc-gcc -Os -pipe -mips32 -mtune=mips32 -funit-at-a-time -I/home/qazmonk/Desktop/OpenWrt-SDK-Linux-x86_64-1/staging_dir_mipsel/usr/include -I/home/qazmonk/Desktop/OpenWrt-SDK-Linux-x86_64-1/staging_dir_mipsel/include    -c -o helloWorld.o helloWorld.c
/home/qazmonk/Desktop/OpenWrt-SDK-Linux-x86_64-1/staging_dir_mipsel/bin/mipsel-linux-uclibc-gcc: 3: Syntax error: ")" unexpected
make[5]: *** [helloWorld.o] Error 2
make[5]: Leaving directory `/home/qazmonk/Desktop/OpenWrt-SDK-Linux-x86_64-1/build_mipsel/helloWorld'
make[4]: *** [/home/qazmonk/Desktop/OpenWrt-SDK-Linux-x86_64-1/build_mipsel/helloWorld/.built] Error 2
make[4]: Leaving directory `/home/qazmonk/Desktop/OpenWrt-SDK-Linux-x86_64-1/package/HelloPackage'
make[3]: *** [HelloPackage-compile] Error 2
make[3]: Leaving directory `/home/qazmonk/Desktop/OpenWrt-SDK-Linux-x86_64-1/package'
make[2]: *** [compile] Error 2
make[2]: Leaving directory `/home/qazmonk/Desktop/OpenWrt-SDK-Linux-x86_64-1/package'
make[1]: *** [package/compile] Error 2
make[1]: Leaving directory `/home/qazmonk/Desktop/OpenWrt-SDK-Linux-x86_64-1'
make: *** [world] Error 2
qazmonk@qazmonk-VirtualBox:~/Desktop/OpenWrt-SDK-Linux-x86_64-1$

Here is the code:

c program named helloWorld.c

#include <stdio.h>

int main()
{
    printf("Hello World!\n");
    return 0;
}

2nd Makefile

##############################################
# 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:=helloWorld
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/helloWorld
    SECTION:=utils
    CATEGORY:=Utilities
    TITLE:=helloWorld -- prints a snarky message
    DESCRIPTION:=\
    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/helloWorld/install
    $(INSTALL_DIR) $(1)/bin
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/helloWorld $(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,helloWorld))

1st makefile

helloworld: helloWorld.o
    $(CC) $(LDFLAGS) helloWorld.o -o helloWorld
helloworld.o: helloWorld.c
    $(CC) $(CFLAGS) -c helloWorld.c
clean:
    rm *.o helloWorld

(Last edited by qazmonk on 24 Jan 2011, 01:29)

I tried literally copying the code from the example and It still doesn't work. Also the code will compile in the helloWorld file, it just wont compile in the SDK

(Last edited by qazmonk on 24 Jan 2011, 01:30)

I realized a day ago that I installed the wrong version of Open WRT SDK.... I feel like a dumbass

How do you know which version will work? i am getting same error please help. my system info is:
fyp@linux-57jt:~> uname -a
Linux linux-57jt 2.6.27.7-9-default #1 SMP 2008-12-04 18:10:04 +0100 x86_64 x86_64 x86_64 GNU/Linux

The discussion might have continued from here.