如何在make之后运行.o文件 我一直试图从运行C++程序

如何在make之后运行.o文件 我一直试图从运行C++程序,c++,c,makefile,C++,C,Makefile,按照自述文件中的规定我已运行以下命令 make make test make demo 现在,我的目录中有以下文件 zakirhussain@zakirhussain-K52F:~/Simple-Homomorphic-Encryption$ ls circuit.cpp demo_vote_counter.cpp fully_homomorphic.cpp main.o security_settings.h test_

按照
自述文件中的规定
我已运行以下命令

make

make test

make demo
现在,我的目录中有以下文件

zakirhussain@zakirhussain-K52F:~/Simple-Homomorphic-Encryption$ ls
circuit.cpp             demo_vote_counter.cpp  fully_homomorphic.cpp  main.o                 security_settings.h     test_suite.o  utilities.o
circuit.h               demo_vote_counter.h    fully_homomorphic.h    makefile               security_settings.o     type_defs.h
circuit.o               demo_vote_counter.o    fully_homomorphic.o    README                 test_fully_homomorphic  utilities.c
demo_fully_homomorphic  fully_homomorphic      main.cpp               security_settings.cpp  test_suite.cpp          utilities.h

有人能帮我运行
demo\u vote\u counter.o
文件吗?

您不能运行
.o
文件。这是一个目标文件,必须链接到最终可执行文件中。
.o
文件通常缺少在链接阶段添加的附加库


查看您的输出,我会假设
demo\u fully\u homomorphic
test\u fully\u homorphic
fully\u homorphic
中的一个是您可以运行的可执行文件。

对象文件(
.o
)是不可执行的。您希望运行
/demo\u完全\u同态的
(例如,没有扩展名的文件)。请确保您具有执行权限(
chmod a+x demo\u fully\u homomorphic
)。

您无法运行该对象文件。必须首先链接它才能生成可执行文件


正如我看到的,在您的目录中有一个“demo\u fully\u homophymorphic”、“fully\u homophymorphic”和一个“test\u fully\u homophymorphic”。这些是链接的可执行文件,您可以使用。/[可执行文件名称]

执行它们。在这种情况下,可执行文件称为
demo\u fully\u同态
,请重试

./demo_fully_homomorphic

正如在其他几个答案中已经提到的,您可以执行二进制文件,而不是对象文件。但是,为了以防万一,如果您希望以可读格式显示对象文件的内容

$>objdump -d object_filename.o 

我想我迟到了,但我想下面的代码可能对某些人有帮助

在包含c/c++文件的文件夹中使用cd,然后编译它

gcc my_test.c -o my_test
将生成符合要求的文件。然后仍然在同一个文件夹中。运行命令

./my_test

您不会“运行”一个
.o
文件。这是一个对象文件,用于构建可执行文件。从上面的列表中,看起来您想要运行
/demo\u fully\u homomorphic
/fully\u homomorphic
,或者
/test\u fully\u homomorphic
。执行
ls-F
并查找星号。这些是可执行文件。是的,“编译文件”