g++和gcc的区别
g++和gcc的区别
这个问题已经在这里有了答案: g++和gcc有什么区别?
我有一个简单的c主程序和一个类,VoronoiDiagramGenerator.cpp
和VoronoiDiagramGenerator.h
是类定义,在main
函数中调用类方法。为什么我使用gcc
和g++
会有不同的输出呢?使用gcc
会出现一些错误,但使用g++却可以。
jack@ubuntu:~/dev/practice$ gcc main.cpp VoronoiDiagramGenerator.cpp -o main /tmp/ccbaXM5L.o:(.eh_frame+0x6b): undefined reference to `__gxx_personality_v0' /tmp/ccCeOqcL.o: In function `VoronoiDiagramGenerator::VoronoiDiagramGenerator()': VoronoiDiagramGenerator.cpp:(.text+0x22): undefined reference to `operator new(unsigned int)' /tmp/ccCeOqcL.o: In function `VoronoiDiagramGenerator::reset()': VoronoiDiagramGenerator.cpp:(.text+0x168): undefined reference to `operator delete(void*)' /tmp/ccCeOqcL.o: In function `VoronoiDiagramGenerator::geominit()': VoronoiDiagramGenerator.cpp:(.text+0xc3d): undefined reference to `sqrt' /tmp/ccCeOqcL.o: In function `VoronoiDiagramGenerator::dist(Site*, Site*)': VoronoiDiagramGenerator.cpp:(.text+0x1318): undefined reference to `sqrt' /tmp/ccCeOqcL.o: In function `VoronoiDiagramGenerator::getfree(Freelist*)': VoronoiDiagramGenerator.cpp:(.text+0x17aa): undefined reference to `operator new(unsigned int)' /tmp/ccCeOqcL.o: In function `VoronoiDiagramGenerator::cleanup()': VoronoiDiagramGenerator.cpp:(.text+0x18cd): undefined reference to `operator delete(void*)' VoronoiDiagramGenerator.cpp:(.text+0x1917): undefined reference to `operator delete(void*)' VoronoiDiagramGenerator.cpp:(.text+0x1923): undefined reference to `operator new(unsigned int)' /tmp/ccCeOqcL.o: In function `VoronoiDiagramGenerator::cleanupEdges()': VoronoiDiagramGenerator.cpp:(.text+0x19e4): undefined reference to `operator delete(void*)' VoronoiDiagramGenerator.cpp:(.text+0x1a3f): undefined reference to `operator delete(void*)' /tmp/ccCeOqcL.o: In function `VoronoiDiagramGenerator::pushGraphEdge(float, float, float, float)': VoronoiDiagramGenerator.cpp:(.text+0x1a8b): undefined reference to `operator new(unsigned int)' /tmp/ccCeOqcL.o: In function `VoronoiDiagramGenerator::pushDelaunayGraphEdge(float, float, float, float)': VoronoiDiagramGenerator.cpp:(.text+0x1afa): undefined reference to `sqrt' VoronoiDiagramGenerator.cpp:(.text+0x1b1a): undefined reference to `operator new(unsigned int)' /tmp/ccCeOqcL.o: In function `VoronoiDiagramGenerator::clip_line(Edge*)': VoronoiDiagramGenerator.cpp:(.text+0x1e50): undefined reference to `sqrt' /tmp/ccCeOqcL.o: In function `VoronoiDiagramGenerator::generateVertexLinks()': VoronoiDiagramGenerator.cpp:(.text+0x33f4): undefined reference to `operator delete[](void*)' VoronoiDiagramGenerator.cpp:(.text+0x3413): undefined reference to `operator delete[](void*)' collect2: ld 返回 1
但是使用g++
,一切都正常
jack@ubuntu:~/dev/practice$ g++ main.cpp VoronoiDiagramGenerator.cpp -o main jack@ubuntu:~/dev/practice$
admin 更改状态以发布 2023年5月19日