gpt4 book ai didi

c - GCC错误: Could not find or load main class com. intellij.idea.Main编译C

转载 作者:太空宇宙 更新时间:2023-11-04 12:19:13 29 4
gpt4 key购买 nike

无论我做什么,GCC 都会给出这个错误。我已经卸载了 gcc 和所有库,重新安装并重新启动。 gcc 昨晚还在工作,今天当我打开我的笔记本电脑时,它会尝试寻找 intellij 文件。

这是我在运行 make 时遇到的错误。注意:我尝试编译的每个源文件都会发生这种情况。今天才开始。它昨天还在工作。

gcc -c war.c 
Error: Could not find or load main class com.intellij.idea.Main

https://github.com/ahester57/WAR

which gcc 给我 /usr/bin/gcc

which as 给我 /usr/bin/as

我已经尝试过 /usr/bin/gcc -c war.c 并且它给出了保存错误(与 intellij 有关)。我什至没有安装 intellij。

只是寻找任何见解,如果没有其他人遇到此问题,可能会重新安装操作系统。在 Ubuntu 17.04 上使用 vim 和 bash。 17.10 就在拐角处。

$ gcc -v -Wall -g ptr.c -o ptr
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 6.3.0-12ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-6 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 6.3.0 20170406 (Ubuntu 6.3.0-12ubuntu2)
COLLECT_GCC_OPTIONS='-v' '-Wall' '-g' '-o' 'ptr' '-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-linux-gnu/6/cc1 -quiet -v -imultiarch x86_64-linux-gnu ptr.c -quiet -dumpbase ptr.c -mtune=generic -march=x86-64 -auxbase ptr -g -Wall -version -fstack-protector-strong -Wformat-security -o /tmp/ccjR19rz.s
GNU C11 (Ubuntu 6.3.0-12ubuntu2) version 6.3.0 20170406 (x86_64-linux-gnu)
compiled by GNU C version 6.3.0 20170406, GMP version 6.1.2, MPFR version 3.1.5, MPC version 1.0.3, isl version 0.15
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/6/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/x86_64-linux-gnu/6/include
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/6/include-fixed
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
GNU C11 (Ubuntu 6.3.0-12ubuntu2) version 6.3.0 20170406 (x86_64-linux-gnu)
compiled by GNU C version 6.3.0 20170406, GMP version 6.1.2, MPFR version 3.1.5, MPC version 1.0.3, isl version 0.15
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 5a80a4e17a9c5c8f646e6b274db1ec27
COLLECT_GCC_OPTIONS='-v' '-Wall' '-g' '-o' 'ptr' '-mtune=generic' '-march=x86-64'
as -v --64 -o /tmp/cc267OI7.o /tmp/ccjR19rz.s
Error: Could not find or load main class com.intellij.idea.Main

感谢 Basile,让 gcc 再次工作。

解决方法:

apt-get reinstall gcc gcc-multilib
apt-get reinstall binutils

最佳答案

键入 which gccwhich as(我不会惊讶输出会很奇怪,应该是 /usr/bin/gcc/usr/bin/as) 然后 gcc -vgcc --version;更正(可能在 ~/.bashrc 中)你的 $PATH 的设置(所以使用 echo $PATH 来找出它是什么)并在你的 Makefile 中使用 $(CC)。顺便说一句,你不需要 Makefile 中带有 gcc 的行,因为 make 有内置规则(类型 make - p 找到它们)

如果这还不够(应该是)添加一个显式的

CC= /usr/bin/gcc

在您的 Makefile 中,这是非常有问题的。

花时间阅读 documentation of make ,然后完全重写您的 Makefile

参见 thisthat答案(它们包含相关示例)

您应该使用所有警告和调试信息进行编译,可能需要

CFLAGS+= -Wall -Wextra -g

另请阅读 documentation of GCC .您可能不需要 -w 并且您使用的 -c 不正确(它跳过了 linking 步骤,只是编译)。

顺便说一句,gcc 的参数顺序很重要(而且你弄错了)。

I have uninstalled gcc and all libraries, done a reinstall and reboot. gcc was working last night, and when I open my laptop today it tries looking for intellij files.

附言。也许你的 /usr/bin/gcc 被破坏了(或者你的 asgcc 使用,尝试重新安装 binutils包)并且可能您的系统已损坏,您需要先修复它才能编辑一个简单的helloworld.c 程序然后执行(在新鲜 运行 shell 的终端,例如 bashzsh) a gcc -v -Wall -g helloworld.c -o helloworldprogram 然后运行 ​​./helloworldprogram。一旦一切顺利,请阅读 documentation of make , documentation of GCC并重新开始您的项目。

附录

在您提到的评论中 https://github.com/ahester57/WAR这是提交 7ed7133e09c7bb2af 的更好的 Makefile :

 # Makefile improved by Basile Starynkevitch

CC= gcc
CFLAGS= -Wall -g
LDLIBS= -lm
SOURCES= cards.c war.c
# or perhaps SOURCES= $(wildcard *.c)

OBJECTS= $(patsubst %.c,%.o,$(SOURCES))

.PHONY: all clean

all: war

war: $(OBJECTS)

$(OBJECTS): cards.h

clean:
$(RM) $(OBJECTS) war *~

关于c - GCC错误: Could not find or load main class com. intellij.idea.Main编译C,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46499832/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com