Thread: Generated absolute path via for in doesn't exist

  1. #1
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    291

    Generated absolute path via for in doesn't exist

    This is seriously confusing me, this:
    Code:
    PRJ_DIR=$(pwd)/
    SRC_DIR=${PRJ_DIR}
    OUT_DIR="${ALL}/lu"
    OBJ_DIR=${PRJ_DIR}objs
    chkdir "${OBJ_DIR}"
    OBJ_DIR="${OBJ_DIR}/${O_DIR}"
    ...
    echo Compiling Lu Objects
    chkdir "${OBJ_DIR}"
    chknam(){
    	n=$(basename $1)
    	compile_obj "${OBJ_DIR}/$n.o" $1 true
    }
    for i in "${SRC_DIR}"*.c
    do
    	chknam "$i"
    done
    unset chknam
    Resulted in this:
    Code:
    sh build.sh (in directory: /media/zxuiji/ZXUIJI_1TB/github/lu/lu)
    CPATH=/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src
    LPATH=/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5
    Compiling Lu Objects
    gcc -Wall -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/gcc/LuScript.c.o" -c "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/LuScript.c"
    gcc: error: "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/LuScript.c": No such file or directory
    gcc: fatal error: no input files
    compilation terminated.
    ...
    Last edited by awsdert; 2 Weeks Ago at 12:40 PM.

  2. #2
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    291
    Found the problem, apparently gcc & other compilers must be run with root permissions ( ͠ ͟ʖ ͡)

    Edit: Nope, only works when I type directly, this is sooo WTF!?
    Here's a root permission terminal output trying both
    Code:
    root@zxuiji-mint:/media/zxuiji/ZXUIJI_1TB/github/lu/lu# clang lu.c
    In file included from lu.c:1:
    ./lu.h:34:10: fatal error: 'lua.h' file not found
    #include <lua.h>
             ^~~~~~~
    1 error generated.
    root@zxuiji-mint:/media/zxuiji/ZXUIJI_1TB/github/lu/lu# sh build.sh
    CPATH=/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src
    LPATH=/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5
    Compiling Lu Objects from /media/zxuiji/ZXUIJI_1TB/github/lu/lu
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/LuScript.c".o" -c "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/LuScript.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/github/lu/lu/LuScript.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lu.c".o" -c "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/lu.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/github/lu/lu/lu.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/luat.c".o" -c "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/luat.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/github/lu/lu/luat.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/ludir.c".o" -c "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/ludir.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/github/lu/lu/ludir.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lufile.c".o" -c "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/lufile.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/github/lu/lu/lufile.c"'
    clang: error: no input files
    Compiling Lua Objects from /media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/lapi.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lapi.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lapi.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/lauxlib.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lauxlib.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lauxlib.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/lbaselib.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lbaselib.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lbaselib.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/lbitlib.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lbitlib.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lbitlib.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/lcode.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lcode.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lcode.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/lcorolib.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lcorolib.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lcorolib.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/lctype.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lctype.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lctype.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/ldblib.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/ldblib.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/ldblib.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/ldebug.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/ldebug.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/ldebug.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/ldo.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/ldo.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/ldo.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/ldump.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/ldump.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/ldump.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/lfunc.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lfunc.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lfunc.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/lgc.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lgc.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lgc.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/linit.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/linit.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/linit.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/liolib.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/liolib.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/liolib.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/llex.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/llex.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/llex.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/lmathlib.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lmathlib.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lmathlib.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/lmem.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lmem.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lmem.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/loadlib.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/loadlib.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/loadlib.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/lobject.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lobject.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lobject.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/lopcodes.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lopcodes.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lopcodes.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/loslib.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/loslib.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/loslib.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/lparser.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lparser.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lparser.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/lstate.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lstate.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lstate.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/lstring.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lstring.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lstring.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/lstrlib.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lstrlib.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lstrlib.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/ltable.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/ltable.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/ltable.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/ltablib.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/ltablib.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/ltablib.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/ltm.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/ltm.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/ltm.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/lua.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lua.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lua.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/luac.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/luac.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/luac.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/lundump.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lundump.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lundump.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/lutf8lib.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lutf8lib.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lutf8lib.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/lvm.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lvm.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lvm.c"'
    clang: error: no input files
    sudo clang -Wall -Wextra -Werror  -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/lua/lzio.c".o" -c "/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lzio.c"
    clang: error: no such file or directory: '"/media/zxuiji/ZXUIJI_1TB/common/lua-5.3.5/src/lzio.c"'
    clang: error: no input files
    Compiling Lu Executable
    clang: error: no input files
    root@zxuiji-mint:/media/zxuiji/ZXUIJI_1TB/github/lu/lu#
    Last edited by awsdert; 1 Week Ago at 04:18 AM.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    36,893
    > sudo clang -Wall -Wextra -Werror -o "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/objs/clang/LuScript.c".o" -c "/media/zxuiji/ZXUIJI_1TB/github/lu/lu/LuScript.c"
    Well there's certainly no reason for running the compiler as root, unless you have basically no permissions to write to directories.

    A problem might be your mis-matched quotes on the .o file
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    291
    Okay tried modifying my build script to put the full command in a string and it finally found the file, makes me think the shell puts it in a fake environment when executing via a variable's contents, here's the snippet I'm using after modified the script several times and reaching this point:
    Code:
    compile_c() {
    	local c="${CC} ${CFLAGS}"
    	echo "$1 from $3"
    	chkdir "$2"
    	for i in "$3/"*.c
    	do
    		n="$(basename \"$i\")"
    		o="$2/$n.o"
    		if chknam "$n" "$o" "$i"; then
    			echo $c -o "$o" -c "$i"
    			$c -o "$o" -c "$i"
    		fi
    	done
    }
    
    compile_c "Compiling Lu Objects" "${OBJ_DIR}" "${SRC_DIR}"
    compile_c "Compiling Lua Objects" "${OBJ_LUA_DIR}" "${SRC_LUA_DIR}"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Absolute path C
    By midnight in forum C Programming
    Replies: 1
    Last Post: 11-13-2009, 08:11 AM
  2. How to judge whether a path is relative or absolute?
    By bbebfe in forum C Programming
    Replies: 2
    Last Post: 11-16-2008, 03:23 AM
  3. problem with fopen and absolute path
    By kobra_swe in forum C Programming
    Replies: 19
    Last Post: 04-17-2008, 01:31 AM
  4. Doesn't exist?
    By Llam4 in forum C# Programming
    Replies: 7
    Last Post: 04-10-2007, 12:33 PM
  5. how to obtain the absolute application path
    By jagerhans in forum Linux Programming
    Replies: 4
    Last Post: 12-23-2004, 05:48 PM

Tags for this Thread