I'm trying to run a .exe file compiled from c, but got results 'this app can't open in this pc and I don't understand why. The c code is made from python file using cython, and I'm sure the python code works. The python code is:
import socket
import os
import sys
import struct
def socket_service():
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
# IP address for pc
s.bind(('', 8088))
s.listen(7)
except socket.error as msg:
print(msg)
sys.exit(1)
print("Connection open, waiting for picture...")
while True:
sock, addr = s.accept()
deal_data(sock, addr)
s.close()
def deal_data(sock, addr):
print("Connection done {0}".format(addr))
while True:
fileinfo_size = struct.calcsize('128sl')
buf = sock.recv(fileinfo_size)
if buf:
filename, filesize = struct.unpack('128sl', buf)
fn = filename.decode().strip('\x00')
#PC saved pic address
#new_filename = os.path.join('C:/Users/user/Desktop', fn)
new_filename = os.path.join('C:/Users/lguo8', fn)
recvd_size = 0
fp = open(new_filename, 'wb')
while not recvd_size == filesize:
if filesize - recvd_size > 1024:
data = sock.recv(1024)
recvd_size += len(data)
else:
data = sock.recv(1024)
recvd_size = filesize
fp.write(data)
fp.close()
sock.close()
break
if __name__ == '__main__':
socket_service()
And I use cython to convert python to c by:
python translate.py build_ext --inplace -DMS_WIN64
where the translate.py is
from setuptools import setup
from Cython.Build import cythonize
setup(ext_modules=cythonize('try_pi_socket_10.py'))
After I got try_pi_socket_10.c, I enter command:
gcc -DMS_WIN64 try_pi_socket_10.c -o output -IC:/Users/lguo8/AppData/Local/Programs/Python/Python39/include -LC:/Users/lguo8/AppData/Local/Programs/Python/Python39/libs -lpython39 -municode -shared
in order to get execute file. However, I was expected to get a file 'output' without any extension. But actually the file is 'output.exe', and when I tried to run it in cmd, I got result 'this app can't open in this pc, permission denied'. Can anyone please help me to run this execute file please? Thank you!