Thread: redirect problems

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

    redirect problems

    Okay so I compile fine, I run fine inside my source directory but as soon as I run the app in another working directory the output file refuses to be made, here's the snippet from my built-in lua script
    Code:
    function system(command,tmpenv)\n\
    	local name = os.tmpname() .. '_txt'\n\
    	local env,prv,pfx = setenvs(tmpenv)\n\
    	name = Lake.getcwd() .. '/' .. name:gsub('[/\\\\]','_')\n\
    	name = name:gsub('\\\\','/')\n\
    	command = pfx .. command .. ' >' .. name\n\
    	print( command )\n\
    	local r = Lake.system( command )\n\
    	if (Lake.access(name,0)~=0) then setenv(prv) return r end\n\
    	for line in io.lines(name) do\n\
    		print(line)\n\
    	end\n\
    	os.remove(name)\n\
    	setenv(prv)\n\
    	return (r or 1)\n\
    end\n\
    All those \n\ are just because this came from a string in my lake.c file,
    the result of Lake.access(name,0) should always be 0 but as I said before whenever I try outside the source directory of my lake.c file the temporary file doesn't get created, any ideas as to what might be causing this?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    > command = pfx .. command .. ' >' .. name\n\
    > print( command )\n\
    Does your printed command look valid?
    Is there anything suspicious about the printed redirect name?
    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.

  3. #3
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,733
    No it works fine in my source directory as I stated, I'll give you the dump of both since each are short.
    Source directory:
    Code:
    lake debug (in directory: O:\Data\C_Playground\lake)
    Loading lua file...
    gcc --pass-exit-codes -Wall -I "O:/Common/argparse-master" -mconsole -mwindows -mwin32 -m64 -D _WIN64 -I "O:\Common\lua64-53\include" -L "O:\Common\lua64-53" -l lua53 -c "lake.c" -o "obj/win64/lake.c.o" >O:/Data/C_Playground/lake/_s68c._txt
    gcc --pass-exit-codes -Wall -I "O:/Common/argparse-master" -mconsole -mwindows -mwin32 -m64 -D _WIN64 -I "O:\Common\lua64-53\include" -L "O:\Common\lua64-53" -l lua53 -c "O:/Common/argparse-master/argparse.c" -o "obj/win64/argparse.o" >O:/Data/C_Playground/lake/_s68c.1_txt
    gcc --pass-exit-codes -Wall -I "O:/Common/argparse-master" -mconsole -mwindows -mwin32 -m64 -D _WIN64 -I "O:\Common\lua64-53\include" "O:\Common\lua64-53\lua53.dll" obj/win64/lake.c.o obj/win64/argparse.o -o O:/Common/lake64/lake64.exe >O:/Data/C_Playground/lake/_s68c.2_txt
    gcc --pass-exit-codes -Wall -I "O:/Common/argparse-master" -ggdb -mconsole -mwindows -mwin32 -m64 -D _WIN64 -I "O:\Common\lua64-53\include" -L "O:\Common\lua64-53" -l lua53 -c "lake.c" -o "obj/win64/dlake.c.o" >O:/Data/C_Playground/lake/_s68c.3_txt
    gcc --pass-exit-codes -Wall -I "O:/Common/argparse-master" -ggdb -mconsole -mwindows -mwin32 -m64 -D _WIN64 -I "O:\Common\lua64-53\include" -L "O:\Common\lua64-53" -l lua53 -c "O:/Common/argparse-master/argparse.c" -o "obj/win64/dargparse.o" >O:/Data/C_Playground/lake/_s68c.4_txt
    gcc --pass-exit-codes -Wall -I "O:/Common/argparse-master" -ggdb -mconsole -mwindows -mwin32 -m64 -D _WIN64 -I "O:\Common\lua64-53\include" "O:\Common\lua64-53\lua53.dll" obj/win64/dlake.c.o obj/win64/dargparse.o -o O:/Common/lake64/dlake64.exe >O:/Data/C_Playground/lake/_s68c.5_txt
    Compilation finished successfully.
    Project directory:
    Code:
    lake debug (in directory: O:\Data\C_Playground\iux)
    Loading lua file...
    set OBJC_INCLUDE_PATH=O:/Common/iup64-3.25/include;O:/Common/MinGW64/include/freetype
    set PATH=O:/Common/iup64-3.25/include;O:/Common/MinGW64/include/freetype;O:/Common/iup64-3.25/Lua53;O:/Common/MinGW64/bin;X:\PortableApps\GeanyPortable\App\Geany\bin;X:\PortableApps\GeanyPortable\App\Geany\bin;;O:\Common\MinGW64\bin;O:\Common\lake64;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;A:\Tools\WinSDK\10\Windows Performance Toolkit\;C:\Users\awsde_000\AppData\Local\Microsoft\WindowsApps;
    set LIBRARY_PATH=O:/Common/iup64-3.25/Lua53;O:/Common/MinGW64/lib/freetype;X:\PortableApps\GeanyPortable\App\Geany\bin;X:\PortableApps\GeanyPortable\App\Geany\bin;;O:\Common\MinGW64\bin;O:\Common\lake64;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;A:\Tools\WinSDK\10\Windows Performance Toolkit\;C:\Users\awsde_000\AppData\Local\Microsoft\WindowsApps;
    set C_INCLUDE_PATH=O:/Common/iup64-3.25/include;O:/Common/MinGW64/include/freetype
    set CPATH=O:/Common/iup64-3.25/include;O:/Common/MinGW64/include/freetype
    set CPLUS_INCLUDE_PATH=O:/Common/iup64-3.25/include;O:/Common/MinGW64/include/freetype
    gcc -Wall -liuplua53 -liup -llua53 -mconsole -mwindows -mwin32 -m64 src/mem.c -o src/mem.c.o >O:/Data/C_Playground/iux/_s6s._txt
    set OBJC_INCLUDE_PATH=O:/Common/iup64-3.25/include;O:/Common/MinGW64/include/freetype
    set PATH=O:/Common/iup64-3.25/include;O:/Common/MinGW64/include/freetype;O:/Common/iup64-3.25/Lua53;O:/Common/MinGW64/bin;X:\PortableApps\GeanyPortable\App\Geany\bin;X:\PortableApps\GeanyPortable\App\Geany\bin;;O:\Common\MinGW64\bin;O:\Common\lake64;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;A:\Tools\WinSDK\10\Windows Performance Toolkit\;C:\Users\awsde_000\AppData\Local\Microsoft\WindowsApps;
    set LIBRARY_PATH=O:/Common/iup64-3.25/Lua53;O:/Common/MinGW64/lib/freetype;X:\PortableApps\GeanyPortable\App\Geany\bin;X:\PortableApps\GeanyPortable\App\Geany\bin;;O:\Common\MinGW64\bin;O:\Common\lake64;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;A:\Tools\WinSDK\10\Windows Performance Toolkit\;C:\Users\awsde_000\AppData\Local\Microsoft\WindowsApps;
    set C_INCLUDE_PATH=O:/Common/iup64-3.25/include;O:/Common/MinGW64/include/freetype
    set CPATH=O:/Common/iup64-3.25/include;O:/Common/MinGW64/include/freetype
    set CPLUS_INCLUDE_PATH=O:/Common/iup64-3.25/include;O:/Common/MinGW64/include/freetype
    gcc -Wall -liuplua53 -liup -llua53 -mconsole -mwindows -mwin32 -m64 src/main.c -o src/main.c.o >O:/Data/C_Playground/iux/_s6s.1_txt
    set OBJC_INCLUDE_PATH=O:/Common/iup64-3.25/include;O:/Common/MinGW64/include/freetype
    set PATH=O:/Common/iup64-3.25/include;O:/Common/MinGW64/include/freetype;O:/Common/iup64-3.25/Lua53;O:/Common/MinGW64/bin;X:\PortableApps\GeanyPortable\App\Geany\bin;X:\PortableApps\GeanyPortable\App\Geany\bin;;O:\Common\MinGW64\bin;O:\Common\lake64;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;A:\Tools\WinSDK\10\Windows Performance Toolkit\;C:\Users\awsde_000\AppData\Local\Microsoft\WindowsApps;
    set LIBRARY_PATH=O:/Common/iup64-3.25/Lua53;O:/Common/MinGW64/lib/freetype;X:\PortableApps\GeanyPortable\App\Geany\bin;X:\PortableApps\GeanyPortable\App\Geany\bin;;O:\Common\MinGW64\bin;O:\Common\lake64;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;A:\Tools\WinSDK\10\Windows Performance Toolkit\;C:\Users\awsde_000\AppData\Local\Microsoft\WindowsApps;
    set C_INCLUDE_PATH=O:/Common/iup64-3.25/include;O:/Common/MinGW64/include/freetype
    set CPATH=O:/Common/iup64-3.25/include;O:/Common/MinGW64/include/freetype
    set CPLUS_INCLUDE_PATH=O:/Common/iup64-3.25/include;O:/Common/MinGW64/include/freetype
    gcc -Wall -liuplua53 -liup -llua53 -mconsole -mwindows -mwin32 -m64 src/mem.c.o src/main.c.o -o "O:/Common/iux64/iux.exe" >O:/Data/C_Playground/iux/_s6s.2_txt
    Compilation finished successfully.

  4. #4
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,733
    After attempting to run gcc via a batch file I've found that gcc is not actually compiling my file/s and because it produces no output in that scenario the log doesn't get created, here's the batch file:
    Code:
    set SBITS=64
    set ABITS=64
    set PBITS=64
    set ALL=%~d0\Common
    set SRCD=%~dp0
    set MGW=%ALL%\MinGW64
    if not defined PROCESSOR_ARCHITEW6432 (set PBITS=32)
    if "%PROCESSOR_ARCHITECTURE%" == "x86" (set SBITS=%PBITS%)
    if "%PROCESSOR_ARCHITEW6432%" == "AMD64" (set ABITS=32)
    if "%SBITS%" == "32" (set ABITS=32 && set MGW=%ALL%\MinGW)
    set X_DISTRO=nuwen
    set LUA=%ALL%\Lua%SBITS%-53
    set LUA_DLL=%LUA%\lua53.dll
    set PATH=%MGW%\bin;%PATH%
    set CPATH=%LUA%\include;%MGW%\include;%MGW%\include\freetype
    set LIBRARY_PATH=%LUA%;%MGW%\lib
    set C_INCLUDE_PATH=%CPATH%
    set OBJC_INCLUDE_PATH=%CPATH%
    set CPLUS_INCLUDE_PATH=%CPATH%
    set OUTD=%ALL%\lake%SBITS%
    pushd %SRCD%
    gcc -mconsole -mwindows -llua53 -o lake.o lake.c
    gcc -mconsole -mwindows -llua53 -o %OUTD%\lake%SBITS%.exe lake.o
    popd
    exit /b 0
    Any ideas as to why gcc won't run?
    Edit: I should mention that gcc does execute since it reports no lake.o file but reports nothing more than that

    Edit 2: Added the -v flag to the c file run and got this:
    Code:
    ...
    O:\Data\C_Playground\lake>set PATH=O:\Common\MinGW64\bin;X:\PortableApps\GeanyPortable\App\Geany\bin;X:\PortableApps\GeanyPortable\App\Geany\bin;;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;A:\Tools\WinSDK\10\Windows Performance Toolkit\;C:\Users\awsde_000\AppData\Local\Microsoft\WindowsApps;
    ...
    gcc -v -mconsole -mwindows -llua53 -o lake.c.o lake.c
    Using built-in specs.
    COLLECT_GCC=gcc
    COLLECT_LTO_WRAPPER=o:/common/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/6.1.0/lto-wrapper.exe
    Target: x86_64-w64-mingw32
    Configured with: ../src/configure --with-gmp=/c/temp/gcc/gmp --with-mpfr=/c/temp/gcc/mpfr --with-mpc=/c/temp/gcc/mpc --enable-languages=c,c++ --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --disable-multilib --prefix=/c/temp/gcc/dest --with-sysroot=/c/temp/gcc/dest --disable-libstdcxx-pch --disable-nls --disable-shared --disable-win32-registry --enable-checking=release --with-tune=haswell
    Thread model: win32
    gcc version 6.1.0 (GCC)
    COLLECT_GCC_OPTIONS='-v' '-mconsole' '-mwindows' '-o' 'lake.c.o' '-mtune=haswell' '-march=x86-64'
     o:/common/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/6.1.0/cc1.exe -quiet -v -iprefix o:\common\mingw64\bin\../lib/gcc/x86_64-w64-mingw32/6.1.0/ -U_REENTRANT lake.c -quiet -dumpbase lake.c -mconsole -mwindows -mtune=haswell -march=x86-64 -auxbase lake -version -o C:\Users\AWSDE_~1\AppData\Local\Temp\ccH1MeNo.s
    ...
    Last edited by awsdert; 01-07-2019 at 04:47 AM.

  5. #5
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,733
    Tried running the batch file from explorer and it showed a crash dialouge for cc1, gonna try uninstalling MINGW completely then reinstalling

  6. #6
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,733
    struggling to load cboard pages atm, posted my reply

  7. #7
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,733
    Quote Originally Posted by awsdert View Post
    This is actually related to another post but the cboard seems down for the count for the time being, anyways I'm encountering a problem with gcc after running it via batch (fallback file for when I muck up something in my usual program), here's what I was going to post after resintalling both 32bit&64bit MinGW.
    Code:
    O:\Data\C_Playground\lake\run_gcc.bat (in directory: O:\Data\C_Playground\lake)
    ...
    O:\Data\C_Playground\lake>set PATH=O:\Common\MinGW64\bin;X:\PortableApps\GeanyPortable\App\Geany\bin;X:\PortableApps\GeanyPortable\App\Geany\bin;;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;A:\Tools\WinSDK\10\Windows Performance Toolkit\;C:\Users\awsde_000\AppData\Local\Microsoft\WindowsApps;
    ...
    O:\Data\C_Playground\lake>set OBJS=
    O:\Data\C_Playground\lake>set SRCS=lake.c
    O:\Data\C_Playground\lake>cd O:\Data\C_Playground\lake\
    O:\Data\C_Playground\lake>for %i in (lake.c) do (
    set OBJS= %i.o
     x86_64-w64-mingw32-gcc -Wall -mconsole -mwindows -llua53 -o %i.o %i
    )
    O:\Data\C_Playground\lake>(
    set OBJS= lake.c.o
     x86_64-w64-mingw32-gcc -Wall -mconsole -mwindows -llua53 -o lake.c.o lake.c
    )
    lake.c: In function 'LakeCopy':
    lake.c:498:2: internal compiler error: Segmentation fault
      case ERROR_FILE_NOT_FOUND: code = ENOENT; break;
      ^~~~
    libbacktrace could not find executable to open
    ...
    Any ideas?
    Well I managed to get it to compile, I also found a very helpful example of beating dirent.h into Lua so I made use of that and modified my "classes" to reflect hopefully resolving a side issue I had, anyway I'm still having issues with redirect, I made a deliberate error to check, batch gcc spits it out but my program lake won't

    Edit: The "Reply with Quote" thing didn't do as expected, had to manually copy and paste the missed part

    Edit 2: I just tried running it via command line to see if it would spit it out there but same issue
    Last edited by awsdert; 01-10-2019 at 03:01 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. IO Redirect error.
    By dtow1 in forum Linux Programming
    Replies: 3
    Last Post: 10-20-2012, 10:23 AM
  2. redirect output
    By Maga in forum C Programming
    Replies: 5
    Last Post: 02-27-2010, 04:58 AM
  3. Redirect FAQ...
    By Queatrix in forum A Brief History of Cprogramming.com
    Replies: 21
    Last Post: 05-21-2007, 04:48 PM
  4. Redirect stdout
    By GoLuM83 in forum C Programming
    Replies: 6
    Last Post: 12-15-2006, 04:17 PM
  5. DLL Redirect
    By username in forum Windows Programming
    Replies: 5
    Last Post: 05-30-2003, 09:58 AM

Tags for this Thread