linker-errors

Q_OBJECT throwing 'undefined reference to vtable' error [duplicate]

守給你的承諾、 提交于 2019-11-26 04:40:16
问题 This question already has answers here : Qt Linker Error: “undefined reference to vtable” [duplicate] (9 answers) Closed 6 years ago . I\'m using Qt Creator 2.0.1 with Qt 4.7.0 (32 bit) on Windows 7 Ultimate 32 bit. Consider the following code, which is a minimum to produce the error: class T : public QObject, public QGraphicsItem { Q_OBJECT public: T() {} QRectF boundingRect() const {return QRectF();} void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {} }

Error when compiling some simple c++ code

旧城冷巷雨未停 提交于 2019-11-26 04:24:34
问题 I try to compile this cpp code on osx lion but I get an error. #include <iostream> using namespace std; int main (int argc, char *argv[]) { for(int i = 0; i < 10; i++) { cout << \"hi\"; cout << endl; } return 0; } To compile: cc main.cpp Error: Undefined symbols for architecture x86_64: \"std::cout\", referenced from: _main in ccBdbc76.o \"std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const

Why am I getting “undefined reference to sqrt” error even though I include math.h header? [duplicate]

对着背影说爱祢 提交于 2019-11-26 03:35:47
问题 This question already has an answer here: undefined reference to sqrt (or other mathematical functions) 5 answers I\'m very new to C and I have this code: #include <stdio.h> #include <math.h> int main(void) { double x = 0.5; double result = sqrt(x); printf(\"The square root of %lf is %lf\\n\", x, result); return 0; } But when I compile this with: gcc test.c -o test I get an error like this: /tmp/cc58XvyX.o: In function `main\': test.c:(.text+0x2f): undefined reference to `sqrt\' collect2: ld

Undefined reference to `sin` [duplicate]

不想你离开。 提交于 2019-11-26 02:33:47
问题 This question already has answers here : undefined reference to sqrt (or other mathematical functions) (5 answers) Closed last year . I have the following code (stripped down to the bare basics for this question): #include<stdio.h> #include<math.h> double f1(double x) { double res = sin(x); return 0; } /* The main function */ int main(void) { return 0; } When compiling it with gcc test.c I get the following error, and I can\'t work out why: /tmp/ccOF5bis.o: In function `f1\': test2.c:(.text

Qt Linker Error: “undefined reference to vtable” [duplicate]

a 夏天 提交于 2019-11-26 00:38:08
问题 This question already has an answer here: Undefined reference to vtable. Trying to compile a Qt project 17 answers This is my header: #ifndef BARELYSOCKET_H #define BARELYSOCKET_H #include <QObject> //! The First Draw of the BarelySocket! class BarelySocket: public QObject { Q_OBJECT public: BarelySocket(); public slots: void sendMessage(Message aMessage); signals: void reciveMessage(Message aMessage); private: // QVector<Message> reciveMessages; }; #endif // BARELYSOCKET_H This is my class:

32-bit absolute addresses no longer allowed in x86-64 Linux?

我与影子孤独终老i 提交于 2019-11-25 22:17:33
问题 64 bit Linux uses the small memory model by default, which puts all code and static data below the 2GB address limit. This makes sure that you can use 32-bit absolute addresses. Older versions of gcc use 32-bit absolute addresses for static arrays in order to save an extra instruction for relative address calculation. However, this no longer works. If I try to make a 32-bit absolute address in assembly, I get the linker error: \"relocation R_X86_64_32S against `.data\' can not be used when

What is an undefined reference/unresolved external symbol error and how do I fix it?

此生再无相见时 提交于 2019-11-25 22:09:14
问题 What are undefined reference/unresolved external symbol errors? What are common causes and how to fix/prevent them? Feel free to edit/add your own. 回答1: Compiling a C++ program takes place in several steps, as specified by 2.2 (credits to Keith Thompson for the reference): The precedence among the syntax rules of translation is specified by the following phases [see footnote] . Physical source file characters are mapped, in an implementation-defined manner, to the basic source character set