Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/134.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
尝试运行c+时出错+;用Netbeans编译的程序 在过去的几个小时里,我一直在尝试为NETBeCes开发的C++应用程序创建一个Cron WorksPosig。我在Windows机器上编程,并使用Ubuntu服务器作为构建主机。它将其设置为将一个文件放入分发文件夹,我假设它是我必须执行的文件。我使用以下命令行执行它: g++ program_C++_Netbeans - Fatal编程技术网

尝试运行c+时出错+;用Netbeans编译的程序 在过去的几个小时里,我一直在尝试为NETBeCes开发的C++应用程序创建一个Cron WorksPosig。我在Windows机器上编程,并使用Ubuntu服务器作为构建主机。它将其设置为将一个文件放入分发文件夹,我假设它是我必须执行的文件。我使用以下命令行执行它: g++ program

尝试运行c+时出错+;用Netbeans编译的程序 在过去的几个小时里,我一直在尝试为NETBeCes开发的C++应用程序创建一个Cron WorksPosig。我在Windows机器上编程,并使用Ubuntu服务器作为构建主机。它将其设置为将一个文件放入分发文件夹,我假设它是我必须执行的文件。我使用以下命令行执行它: g++ program,c++,netbeans,C++,Netbeans,之后会弹出以下错误: testproject: In function `_start': (.text+0x0): multiple definition of `_start' /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o:(.text+0x0): first defined here testproject: In function `_fini': (.fini+0x0): multiple defi

之后会弹出以下错误:

testproject: In function `_start':
(.text+0x0): multiple definition of `_start'
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o:(.text+0x0):
first defined here
testproject: In function `_fini':
(.fini+0x0): multiple definition of `_fini'
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crti.o:(.fini+0x0):
first defined here
testproject:(.rodata+0x0): multiple definition of `_IO_stdin_used'
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o:(.rodata.cst4
+0x0): first defined here
testproject: In function `__data_start':
(.data+0x0): multiple definition of `__data_start'
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o:(.data+0x0):
first defined here
testproject: In function `__data_start':
(.data+0x8): multiple definition of `__dso_handle'
/usr/lib/gcc/x86_64-linux-gnu/4.6/crtbegin.o:(.data+0x0): first defined here
testproject: In function `_init':
(.init+0x0): multiple definition of `_init'
/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crti.o:(.init+0x0):
first defined here
/usr/lib/gcc/x86_64-linux-gnu/4.6/crtend.o:(.dtors+0x0): multiple definition of
`__DTOR_END__'
testproject:(.dtors+0x8): first defined here
/usr/bin/ld: error in testproject(.eh_frame); no .eh_frame_hdr table will be cre
ated.
collect2: ld returned 1 exit status
但是,当我在Netbeans中单击run时,它运行得很好。我需要运行哪个命令才能使其正常工作?

g++
是一个很好的例子。它将您的源代码转换为可以直接运行的程序。这与Java不同,Java运行在一个名为a的独立程序上

因此,对于您编写的
C++
程序,您可以

g++ my_source.cpp -o my_program
./my_program
第一行将代码编译成一个可运行的程序(此步骤通常更复杂,有多个源文件和单独的程序来管理构建过程,例如)。您只需执行此步骤一次(如果您更改了程序,请再次执行)。如果您使用IDE(如NetBeans),这一部分可能会对您隐藏


第二行运行新程序(假设第一步一切顺利)。
/
只是意味着“在这个目录中运行它”(没有它,您的系统会在一些特定的地方查找程序)。

g++
不用于运行程序,只需编译即可。编译完成后,只需将其作为
程序
(或者可能是
/program
)运行即可。太棒了。成功了。我需要答案。/你能把它作为答案贴出来吗?