命令(Linux终端)的路径设置
问题描述:
我的缓存模拟器工作,而执行我收到以下错误。 我正在使用Ubuntu终端来执行程序。 我,因为我都映射到主程序的其他文件不理解,错误的问题。命令(Linux终端)的路径设置
我是否需要为程序设置路径的任何目录下执行呢?
起初给了权限,我执行下面的命令,这样我不会得到“权限错误”
enter code here
chmodx +x ./csim.c
然后,我对最后的执行程序中执行以下命令
enter code here
./csim.c [-hv] -s 5 -E 1 -b 5 -t traces/long.trace
在
错误输出端子
./csim.c: line 1: /bin: Is a directory
./csim.c: line 2: cachelab.c: command not found
./csim.c: line 3: cachelab.c: command not found
./csim.c: line 4: cachelab.c: command not found
./csim.c: line 5: cachelab.c: command not found
./csim.c: line 6: cachelab.c: command not found
./csim.c: line 7: cachelab.c: command not found
./csim.c: line 8: cachelab.c: command not found
./csim.c: line 9: cachelab.c: command not found
./csim.c: line 10: cachelab.c: command not found
./csim.c: line 11: traces/: Is a directory
我该如何解决这个问题?
答
您正试图执行C源代码文件,因为你给它的“可执行”模式下的外壳将其解释为shell脚本。
要做的第一件事是编译C文件,例如
cc csim.c -o csim
...然后运行生成的可执行程序。
./csim [-hv] -s 5 -E 1 -b 5 -t traces/long.trace
我没编译,但我以不同的方式得到错误,我已经加入math.h中在头文件战俘和所有必要的信息,但是在功能'主: (+的.text 0x601 ):对'pow'的未定义引用 (.text + 0x89a):对'printSummary'的未定义引用 collect2:错误:ld返回1退出状态 – Dvlop 2014-10-07 00:08:41
即使包含正确的头文件,编译器也无法识别pow和printsummary (.text + 0x601):未定义的引用pow'(.text + 0x89a):未定义引用到'printSummary'collect2:错误:ld返回1退出状态 – Dvlop 2014-10-07 00:15:02
您需要链接包含函数的源文件。正如你所看到的,你可以用'-lm'标志编译链接到'pow()'。您还需要编译并链接包含'printSummary()'的'.c'文件。 – Simon 2014-10-07 01:25:58