use*_*326 2 c++ permissions ubuntu gcc g++
每次我尝试使用g ++在ubuntu中编译时,都会出现以下错误
g++ test.cpp -o test
/usr/bin/ld: 1: /usr/bin/ld: /bin: Permission denied
/usr/bin/ld: 2: /usr/bin/ld: test.cpp: not found
/usr/bin/ld: 3: /usr/bin/ld: test.cpp: not found
/usr/bin/ld: 4: /usr/bin/ld: test.cpp: not found
/usr/bin/ld: 5: /usr/bin/ld: test.cpp: not found
/usr/bin/ld: 6: /usr/bin/ld: test.cpp: not found
/usr/bin/ld: 7: /usr/bin/ld: test.cpp: not found
/usr/bin/ld: 8: /usr/bin/ld: test.cpp: not found
/usr/bin/ld: 9: /usr/bin/ld: test.cpp: not found
/usr/bin/ld: 10: /usr/bin/ld: test.cpp: not found
/usr/bin/ld: 11: /usr/bin/ld: test.cpp: not found
/usr/bin/ld: 12: /usr/bin/ld: Syntax error: "(" unexpected
Run Code Online (Sandbox Code Playgroud)
我已多次删除并重新安装g ++./ usr/bin和/ usr/bin/ld的chmod是755,奇怪的是我可以运行它g++ -c test.cpp然后我无法运行.o文件.我不完全确定是什么问题.
首先,不打算运行.o文件,它意味着与其他目标文件(.o)和库(特别是C++和C标准库)链接在一起.但是,我会从您的错误消息中猜测这可能不起作用.
从您的错误消息中,您可能会在/bin目录中运行此命令.这是不合适的.您应该在您具有写入权限的某个目录中运行它(如您的主目录).此外它告诉你它找不到你的test.cpp文件,你确定你已经cd进入了正确的目录吗?