Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is it possible to compile and run on windows? #22

Closed
rikhtehgaran opened this issue Oct 11, 2016 · 3 comments
Closed

is it possible to compile and run on windows? #22

rikhtehgaran opened this issue Oct 11, 2016 · 3 comments

Comments

@rikhtehgaran
Copy link

rikhtehgaran commented Oct 11, 2016

hi
we have bash for windows when I install git, then i have bash.
is it possible to compile in bash and run in windows?
another question is, should I compile for each platform 32 and 64 bit on linux?

@neurobin
Copy link
Owner

You can install it with cygwin on Windows. And if your git (or bash) setup comes with make, then you probably can install it with the usual method, but you may need to install GCC (or another C compiler). If you don't have make but only GCC, then you will have to compile the source like this:

gcc src/shc.c -o shc

Thus you will get a shc binary...

should I compile for each platform 32 and 64 bit on linux?

You should compile for your platform (32, 64 or whatever).

@neurobin neurobin changed the title is it possible compile to run on windows? is it possible to compile and run on windows? Oct 11, 2016
@daubmannus
Copy link

I tried, but it didn't work out.

`
gcc -DPACKAGE_NAME="shc" -DPACKAGE_TARNAME="shc" -DPACKAGE_VERSION="4.0.3" -DPACKAGE_STRING="shc\ 4.0.3" -DPACKAGE_BUGREPORT="http://github.com/neurobin/shc/issues\" -DPACKAGE_URL="" -DPACKAGE="shc" -DVERSION="4.0.3" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_FCNTL_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_UNISTD_H=1 -DHAVE_STRUCT_STAT_ST_RDEV=1 -DHAVE_STDLIB_H=1 -DHAVE_MALLOC=1 -DTIME_WITH_SYS_TIME=1 -DHAVE_SYS_TIME_H=1 -DHAVE_UNISTD_H=1 -DHAVE_ALARM=1 -DHAVE_STDLIB_H=1 -DHAVE_REALLOC=1 -DHAVE_MEMSET=1 -DHAVE_PUTENV=1 -DHAVE_STRCHR=1 -DHAVE_STRDUP=1 -DHAVE_STRRCHR=1 -I. -g -O2 -MT shc.o -MD -MP -MF .deps/shc.Tpo -c -o shc.o shc.c

shc.c: In function ‘parse_an_arg’:

shc.c:752:16: warning: ‘optarg’ redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]

752 |  extern char * optarg;

    |                ^~~~~~

mv -f .deps/shc.Tpo .deps/shc.Po

gcc -g -O2 -o shc.exe shc.o
`

@jackusay
Copy link

jackusay commented Sep 2, 2021

can't compile shc4.0.3 on win7 in msys2

taye@taye-PC MSYS /c/Users/taye/Downloads/New folder (5)/shc-4.0.3
$ ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.exe
checking for suffix of executables... .exe
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for unistd.h... (cached) yes
checking for struct stat.st_rdev... yes
checking for stdlib.h... (cached) yes
checking for GNU libc compatible malloc... yes
checking whether time.h and sys/time.h may both be included... yes
checking for sys/time.h... yes
checking for unistd.h... (cached) yes
checking for alarm... yes
checking for working mktime... yes
checking for stdlib.h... (cached) yes
checking for GNU libc compatible realloc... yes
checking for memset... yes
checking for putenv... yes
checking for strchr... yes
checking for strdup... yes
checking for strrchr... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: executing depfiles commands

taye@taye-PC MSYS /c/Users/taye/Downloads/New folder (5)/shc-4.0.3
$ make
Making all in src
make[1]: Entering directory '/c/Users/taye/Downloads/New folder (5)/shc-4.0.3/s                                                                                    rc'
gcc -DPACKAGE_NAME=\"shc\" -DPACKAGE_TARNAME=\"shc\" -DPACKAGE_VERSION=\"4.0.3\"                                                                                     -DPACKAGE_STRING=\"shc\ 4.0.3\" -DPACKAGE_BUGREPORT=\"http://github.com/neurobi                                                                                    n/shc/issues\" -DPACKAGE_URL=\"\" -DPACKAGE=\"shc\" -DVERSION=\"4.0.3\" -DSTDC_H                                                                                    EADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRIN                                                                                    G_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1                                                                                     -DHAVE_UNISTD_H=1 -DHAVE_FCNTL_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_U                                                                                    NISTD_H=1 -DHAVE_STRUCT_STAT_ST_RDEV=1 -DHAVE_STDLIB_H=1 -DHAVE_MALLOC=1 -DTIME_                                                                                    WITH_SYS_TIME=1 -DHAVE_SYS_TIME_H=1 -DHAVE_UNISTD_H=1 -DHAVE_ALARM=1 -DHAVE_STDL                                                                                    IB_H=1 -DHAVE_REALLOC=1 -DHAVE_MEMSET=1 -DHAVE_PUTENV=1 -DHAVE_STRCHR=1 -DHAVE_S                                                                                    TRDUP=1 -DHAVE_STRRCHR=1 -I.     -g -O2 -MT shc.o -MD -MP -MF .deps/shc.Tpo -c -                                                                                    o shc.o shc.c
shc.c: In function ‘parse_an_arg’:
shc.c:752:16: warning: ‘optarg’ redeclared without dllimport attribute: previous                                                                                     dllimport ignored [-Wattributes]
  extern char * optarg;
                ^
mv -f .deps/shc.Tpo .deps/shc.Po
gcc  -g -O2   -o shc.exe shc.o
make[1]: Leaving directory '/c/Users/taye/Downloads/New folder (5)/shc-4.0.3/sr                                                                                    c'
make[1]: Entering directory '/c/Users/taye/Downloads/New folder (5)/shc-4.0.3'
make[1]: Nothing to be done for 'all-am'.
make[1]: Leaving directory '/c/Users/taye/Downloads/New folder (5)/shc-4.0.3'

taye@taye-PC MSYS /c/Users/taye/Downloads/New folder (5)/shc-4.0.3

try again without MINGW64 :

make clean
make all

result error:

taye@taye-PC MINGW64 /c/Users/taye/Downloads/xxx4
$ make clean
Making clean in src
make[1]: Entering directory '/c/Users/taye/Downloads/xxx4/src'
test -z "shc.exe" || rm -f shc.exe
rm -f *.o
make[1]: Leaving directory '/c/Users/taye/Downloads/xxx4/src'
make[1]: Entering directory '/c/Users/taye/Downloads/xxx4'
make[1]: Nothing to be done for 'clean-am'.
make[1]: Leaving directory '/c/Users/taye/Downloads/xxx4'

taye@taye-PC MINGW64 /c/Users/taye/Downloads/xxx4
$ make all
Making all in src
make[1]: Entering directory '/c/Users/taye/Downloads/xxx4/src'
gcc -DPACKAGE_NAME=\"shc\" -DPACKAGE_TARNAME=\"shc\" -DPACKAGE_VERSION=\"4.0.3\"                                                                                     -DPACKAGE_STRING=\"shc\ 4.0.3\" -DPACKAGE_BUGREPORT=\"http://github.com/neurobi                                                                                    n/shc/issues\" -DPACKAGE_URL=\"\" -DPACKAGE=\"shc\" -DVERSION=\"4.0.3\" -DSTDC_H                                                                                    EADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRIN                                                                                    G_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1                                                                                     -DHAVE_UNISTD_H=1 -DHAVE_FCNTL_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_U                                                                                    NISTD_H=1 -DHAVE_STRUCT_STAT_ST_RDEV=1 -DHAVE_STDLIB_H=1 -DHAVE_MALLOC=1 -DTIME_                                                                                    WITH_SYS_TIME=1 -DHAVE_SYS_TIME_H=1 -DHAVE_UNISTD_H=1 -DHAVE_ALARM=1 -DHAVE_STDL                                                                                    IB_H=1 -DHAVE_REALLOC=1 -DHAVE_MEMSET=1 -DHAVE_PUTENV=1 -DHAVE_STRCHR=1 -DHAVE_S                                                                                    TRDUP=1 -DHAVE_STRRCHR=1 -I.     -g -O2 -MT shc.o -MD -MP -MF .deps/shc.Tpo -c -                                                                                    o shc.o shc.c
shc.c: In function 'read_script':
shc.c:1093:24: warning: implicit declaration of function 'sysconf' [-Wimplicit-f                                                                                    unction-declaration]
  if (l > 0.80 * (cnt = sysconf(_SC_ARG_MAX))) {
                        ^
shc.c:1093:32: error: '_SC_ARG_MAX' undeclared (first use in this function)
  if (l > 0.80 * (cnt = sysconf(_SC_ARG_MAX))) {
                                ^
shc.c:1093:32: note: each undeclared identifier is reported only once for each f                                                                                    unction it appears in
Makefile:344: recipe for target 'shc.o' failed
make[1]: *** [shc.o] Error 1
make[1]: Leaving directory '/c/Users/taye/Downloads/xxx4/src'
Makefile:413: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1

taye@taye-PC MINGW64 /c/Users/taye/Downloads/xxx4


change version since #133
try shc4.0.1:
got same error


#56
#94

_SC_ARG_MAX
Since (I think) its just a check, I commented out that if, thus can compile now

commented out:

	/* Check current System ARG_MAX limit. */
	/*if (l > 0.80 * (cnt = sysconf(_SC_ARG_MAX))) {
		fprintf(stderr, "%s: WARNING!!\n"
"   Scripts of length near to (or higher than) the current System limit on\n"
"   \"maximum size of arguments to EXEC\", could comprise its binary execution.\n"
"   In the current System the call sysconf(_SC_ARG_MAX) returns %d bytes\n"
"   and your script \"%s\" is %d bytes length.\n",
		my_name, cnt, file, l);
	}*/

success!!

download shc.exe of win7 64bit version from my https://github.com/jackusay/shc-for-windows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants