Scons error 127 for OpenWrt

asked 2014-09-22 05:44:43 -0700

Marina Gorshkova gravatar image

updated 2014-09-26 09:00:29 -0700

stevek gravatar image


Scons command line is the following:

scons V=1 ICE=off BR=on BT=off WS=off CPU=openwrt OS=openwrt BINDINGS="core,cpp" SERVICES="about,notification,controlpanel,config" VARIANT=release "TARGET_CFLAGS=-march=4181 -fPIC -mllsc" "TARGET_CC=mips-linux-gcc" "TARGET_CXX=mips-linux-g++" "TARGET_AR=mips-linux-ar" "TARGET_RANLIB=mips-linux-ranlib" "TARGET_LINK=mips-linux-gcc" "TARGET_CPPFLAGS=-I/home/full-package/rtl819x/toolchain/rsdk-1.5.5-4181-EB-2.6.30- -I/home/full-package/rtl819x/toolchain/include/c++ -I/home/full-package/rtl819x/toolchain/rsdk-1.5.5-4181-EB-2.6.30- -I/home/full-package/rtl819x/toolchain/rsdk-1.5.5-4181-EB-2.6.30- -I/home/full-package/rtl819x/users/hostapd-0.6.10/src" "TARGET_PATH=/home/full-package/rtl819x/toolchain/rsdk-1.5.5-4181-EB-2.6.30-" "TARGET_LINKFLAGS=-L/home/full-package/rtl819x/users/openssl-0.9.8i -L/home/full-package/rtl819x/toolchain/rsdk-1.5.5-4181-EB-2.6.30-" "STAGING_DIR=/home/full-package/rtl819x/toolchain/rsdk-1.5.5-4181-EB-2.6.30-"

The output is:

scons: Reading SConscript files ...
Building bindings: cpp, core
Building services: notification, about, controlpanel, config
GTEST_DIR not specified skipping common unit test build
GTEST_DIR not specified skipping alljoyn_core unit test build
GTEST_DIR not specified skipping About Service unit test build
scons: done reading SConscript files.
scons: Building targets ...
mips-linux-g++ -o alljoyn_core/build/openwrt/openwrt/release/obj/AllJoynCrypto.o -c -std=c++0x -fno-exceptions -march=4181 -fPIC -mllsc -Wno-deprecated -DNDEBUG -DQCC_OS_GROUP_POSIX -DQCC_OS_LINUX -Ibuild/openwrt/openwrt/release/dist/cpp/inc -Ibuild/openwrt/openwrt/release/dist/c/inc -Ibuild/openwrt/openwrt/release/dist/cpp/inc/alljoyn -Icommon/inc -Ialljoyn_core/src alljoyn_core/src/AllJoynCrypto.cc
scons: *** [alljoyn_core/build/openwrt/openwrt/release/obj/AllJoynCrypto.o] Error 127
scons: building terminated because of errors.

There are no detailed diagnostics about error. It seems "TARGET_PATH" is not set. Also "-I/path" options from "TARGET_CPPFLAGS" also are not set. What is wrong in scons command line?

I tried to execute the same compiler command added path to compiler and include directories, compilation was successfull.

CPPPATH variable is used in openwrt script to set CPATH:


I added debug output in the script file: print flags

CPPPATH is empty even if I add it in the command line.

{'CPPFLAGS': [], 'FRAMEWORKPATH': [], 'LIBPATH': [], 'CXXFLAGS': [], 'LIBS': [], 'ASFLAGS': [], 'LINKFLAGS': [], 'RPATH': [], 'CPPDEFINES': [], 'FRAMEWORKS': [], 'CCFLAGS': ['-mllsc', '-fPIC', '-march=4181', '-mllsc', '-fPIC', '-march=4181'], 'CFLAGS': [], 'CPPPATH': []}

So I changed the script:

comment the line "env['ENV']['CPATH']=':'.join(flags['CPPPATH'])"

And set:


The code is compiling.

Maybe you can advice more convenient way to set CPATH? :)

{updated information]

Linker command line with error:

mips-linux-g++ -o alljoyn_core/build/openwrt/openwrt/release/obj/liballjoyn.so -shared common/build/openwrt/openwrt/release/obj/ASN1.os common/build/openwrt/openwrt/release/obj ...
edit retag flag offensive close merge delete


I slightly tweaked the formatting to improve readability only.

stevek ( 2014-09-22 12:17:06 -0700 )edit

Can you indicate the version of GCC that you are using? Please include the full output of "mips-linux-gcc --version".

stevek ( 2014-09-23 08:59:58 -0700 )edit

> mips-linux-gcc --version mips-linux-xgcc (GCC) 4.4.5-1.5.5p2 Copyright (C) 2010 Free Software Foundation, Inc.

Marina Gorshkova ( 2014-09-23 23:33:16 -0700 )edit

I still can't see why you are having a problem linking -lcrypto. Could you try setting TARGET_LINK="mips-linux-g++ --print-search-dirs"? Hopefully that can give you a clue as to where GCC is looking for the libraries.

stevek ( 2014-09-26 13:34:13 -0700 )edit

I tried this option. At first, script file contains vars.Add('TARGET_LINK', 'OpenWRT Linker', os.environ.get('TARGET_CC')) # Normally use the C compiler for linking. So "TARGET_LINK" env. variable from command line is ignored. I changed this line and add " --print-search-dirs" to command line option, I see the list of directories which do not realy exist, Like <target_path>/../lib/gcc/mips-linux/4.4.5-1.5.5p2/4181/, <target_path>/../lib/gcc/4181/ and so on, where <target_path> is path from my command line. Library directories from "LIBRARY_PATH" do not exist in this list.

Marina Gorshkova ( 2014-09-29 00:43:48 -0700 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2014-09-22 12:25:38 -0700

stevek gravatar image

updated 2014-09-24 11:20:15 -0700

I had to look at what the scons files for the OpenWrt platform does to remind myself. Any include paths that you specify to TARGET_CPPFLAGS are put into the environment variable CPATH rather than put on the command line for GCC. GCC will treat include paths found in CPATH to be equivalent to -I but will be search after directories specified with -I on the command line. You can read more details here https://gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html (search for CPATH).

SCons error 127 means that SCons was not able to find the everything it needed in the executable path that you gave it. Since the mips-linux-g++ command line works in the shell, try setting TARGET_PATH="$PATH". Once you have verified that works, you can pick out the paths in PATH that need to be given to TARGET_PATH.

[updated response below...]

I am unable to reproduce the problem you are seeing with respect to CPATH. When I add print commands to the build_core/conf/openwrt/SConscript file as you have, I see that flags['CPPPATH'] is set and that env['ENV']['CPATH'] is set without the need to modify any other code in that file. I used your scons command line exactly as it appears (direct cut-n-paste) in your question for verification.

You don't mention where you put the print statement for printing out the "flags" dictionary. There is code around line 56 that clears out flags['CPPPATH']. I put print flags right after the line where the flags dictionary is set and I see CPPPATH listing all the paths from all the -I directives given to TARGET_CFLAGS. I also put a print env['ENV'] right after the line where env['ENV']['CPATH'] is set and I see that CPATH is in fact set. Do note that I did nothing to manually set CPATH.

edit flag offensive delete publish link more


Thanks for response. I add path to corss-compiler to PATH. It runs now. But I still have problem with include directories. I set CPATH env variable. I execute: export COMPILER_FOLDER=/full-package/rtl819x/toolchain/rsdk-1.5.5-4181-EB-2.6.30- export PATH=$PATH:$COMPILER_FOLDER/include/c++:$COMPILER_FOLDER/include/c++/mips-linux:$COMPILER_FOLDER/include/c++/backward In the SCons command line I set CPATH=$PATH. The output is the following: In file included from common/inc/qcc/STLContainer.h:124, from alljoyn_core/src/CompressionRules.h:37, from alljoyn_core/src/AllJoynPeerObj.cc:44: /full-package/rtl819x/toolchain/rsdk-1.5.5-4181-EB-2.6.30- error: backward_warning.h: No such file or directory The file is located in the directory defined in CPATH env variable: root@/core/alljoyn# ls $COMPILER_FOLDER/include/c++/backward auto_ptr.h backward_warning.h binders.h hash_fun.h hash_map

Marina Gorshkova ( 2014-09-23 03:20:04 -0700 )edit

You are right - include pathes were added to env['ENV']['CPATH'] correctly. The problem was with PATH variable, 'PATH' env. variable is set in script as env['ENV']['PATH'] = env['TARGET_PATH'] I set "TARGET_PATH=path to compiler" in the command line and have Error 127. Debug output (print env['ENV']) shows:"'PATH': /full-package/rtl819x/toolchain/rsdk-1.5.5-4181-EB-2.6.30-'" As I understund "sh" was not run. I add to TARGET_PATH "/bin" - "TARGET_PATH=/bin:path_to_compiler" Debug output shows:"'PATH': /bin:/full-package/rtl819x/toolchain/rsdk-1.5.5-4181-EB-2.6.30-'" No error 127 is generated. Code is compiled. But I needed to modify script to add "libdl" to libraries env.Append(LIBS=['m', 'dl']) without this library I had errors when "alljoyn-daemon" is built: build/openwrt/openwrt/release/dist/cpp/lib/liballjoyn.so: undefined reference to `dlopen' build/openwrt/openwrt/release/dist/cpp/lib ...(more)

Marina Gorshkova ( 2014-09-25 02:26:10 -0700 )edit

I still have problem with linker. Libraries "libcrypto" and "libssl" are not found: "ld: cannot find -lcrypto". I set pathes to libraries in TARGET_LINKFLAGS and see correct debug output from scripts: 'LIBRARY_PATH': '/full-package/rtl819x/users/openssl-0.9.8i' Libraries libcrypto.a and libssl.a are located in this directories. If I copy them to the directory "build/openwrt/openwrt/release/dist/cpp/lib" which are defined in linker command line explicitly, Linker works correctly and found libraries. What is my error in libraries pathes definition? The command line is still the same as in the beginning of this post, Thanks,

Marina Gorshkova ( 2014-09-25 02:39:02 -0700 )edit

For the -ldl issue try adding -ldl to TARGET_LINKFLAGS. For the libcrypto problem, can you add the linker command line that SCons is running to your question? Also, include the exact linker error too text too if you can.

stevek ( 2014-09-25 13:45:17 -0700 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2014-09-22 05:44:43 -0700

Seen: 2,942 times

Last updated: Sep 26 '14