我对 libssh (libssh.org) 有疑问。我需要在远程服务器上运行一个 makefile。我用命令“channel_request_exec”来做:
int SSHExecCmd (void(* MessSender)(char* CurMessage, bool IsError, CWnd* MainWnd),ssh_session session, CString & ShellEcho, char * cmd, CWnd* MainWnd)
{
ssh_channel channel;
int rc;
channel = ssh_channel_new(session);
if (channel == NULL) return SSH_ERROR;
rc = ssh_channel_open_session(channel);
if (rc != SSH_OK)
{
ssh_channel_free(channel);
return rc;
}
rc = ssh_channel_request_exec(channel, cmd);
if (rc != SSH_OK)
{
ssh_channel_close(channel);
ssh_channel_free(channel);
return rc;
}
char buffer[256];
unsigned int nbytes;
nbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 0);
while (nbytes > 0)
{
if (fwrite(buffer, 1, nbytes, stdout) != nbytes)
{
ssh_channel_close(channel);
ssh_channel_free(channel);
return SSH_ERROR;
}
nbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 0);
}
if (nbytes < 0)
{
ssh_channel_close(channel);
ssh_channel_free(channel);
return SSH_ERROR;
}
return SSH_OK;
}
Makefile 位于根目录下:
all: mpi_cuda.o pattern2d.o
mpicc mpi_cuda.o pattern2d.o -o mpi_cuda -lrt -lpthread -L/opt/cuda/lib64 -lcudart -lm
mpi_cuda.o: mpi_cuda.c
mpicc -g -std=c99 -D_GNU_SOURCE -I/opt/cuda/include -c $< -o $@
pattern2d.o: pattern2d.cu
nvcc -g -c $< -o $@
我发送命令“make”并接收回声:
mpicc -g -std=c99 -D_GNU_SOURCE -I/opt/cuda/include -c mpi_cuda.c -o mpi_cuda.oda
但什么也没发生(不执行编译)。
如果我用腻子做:一切正常。回声:
make
mpicc -g -std=c99 -D_GNU_SOURCE -I/opt/cuda/include -c mpi_cuda.c -o mpi_cuda.o
mpi_cuda.c: В функции ‘main’:
mpi_cuda.c:148: предупреждение: недостаточно аргументов для указанного формата
nvcc -g -c pattern2d.cu -o pattern2d.o
mpicc mpi_cuda.o pattern2d.o -o mpi_cuda -lrt -lpthread -L/opt/cuda/lib64 -lcudart -lm
我该如何解决这个问题?