简体   繁体   English

我有链接或编译错误

[英]I'm having linking or compilation errors

I am using Netbeans for my C++ project. 我正在为我的C ++项目使用Netbeans。 I compiled my program using make and ran into this error: 我使用make编译程序,并遇到以下错误:

collect2: error: ld terminated with signal 11 [Segmentation fault], core dumped
Makefile:4: recipe for target 'barn' failed
make: *** [barn] Error 1

Whereas, when I compiled it in a linux environment(Ubuntu to be precise), it compiled fine. 而当我在linux环境(准确地说是Ubuntu)中编译它时,它编译良好。 What could have possibly gone wrong? 可能出了什么问题?

This is what I got when I typed make -n: 这是我输入make -n时得到的:

g++ -c main.cc
g++ -c Animal.cc
g++ -c Bird.cc
g++ -c Chicken.cc
g++ -c Cat.cc
g++ -c Pig.cc
g++ -o barn main.o Animal.o Bird.o Chicken.o Cat.o Pig.o Random.o

PS I prefer using Netbeans PS我更喜欢使用Netbeans

A segment fault in the linker suggests a bug with that. 链接器中的段故障表明存在此错误。 This is what I would try if I were to run into this problem. 如果遇到这个问题,这就是我要尝试的方法。

At the command line do 在命令行上

g++ -o barn main.cc Animal.cc Bird.cc Chicken.cc Cat.cc Pig.cc Random.cc

If that does not work, try variations like: 如果这样不起作用,请尝试以下变体:

g++ -o barn main.cc Pig.cc Random.cc Animal.cc Bird.cc Chicken.cc Cat.cc 

The order should not matter. 顺序不重要。 This is just the kind of thing I would try with a mystery-meat problem like this. 这就是我将尝试解决此类神秘肉问题的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Tilera交叉编译-链接错误 - Tilera cross compilation - linking errors M1 MacBook Pro 和 cmake 的编译错误 - Compilation errors with M1 MacBook Pro and cmake 我正在尝试调用一个函数。 这些愚蠢的编译错误的原因是什么? - I'm trying to call a function. What is the cause of these silly compilation errors? clang 和 gcc 之间的 static 和 constexpr 的不同编译 + 链接错误 - Different compilation + linking errors for static and constexpr between clang and gcc 我的冒泡排序程序出现了几个错误,它显示了最大值、最小值和平均值 (C++) - I'm having a couple of errors on my bubble sorting program which displays the maximum, minimun and average (C++) 我有四个错误来自关于未定义结构中的数组的三行 - I'm having four errors coming from three lines about my arrays in a struct not being defined 链接到已链接到我已经链接到的库的库 - Linking to a library that links to a lib I'm already linking to 我在这里遇到链接错误,为什么? - I'm getting a linking error here, why is that? glDrawRangeElements遇到的问题 - Problems I'm having with glDrawRangeElements 为什么我在这段代码中遇到编译错误? - Why am I getting compilation errors in this code?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM