Questions tagged [linker-errors]

An error received when combining individually compiled object files into executable code.

A is introduced to allow separate compilation of source code into object files and libraries. The linker then pulls the data from each of these files together matching definitions to their implementations in order to create an executable file. Because the linker necessarily requires references to data in other files to be exact name matches, the most common type of linker error is an .

3923 questions
1782
votes
39 answers

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

What are undefined reference/unresolved external symbol errors? What are common causes, and how do I fix and prevent these errors?
165
votes
5 answers

Why am I getting "undefined reference to sqrt" error even though I include math.h header?

I'm very new to C and I have this code: #include #include 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…
Ant's
  • 13,545
  • 27
  • 98
  • 148
148
votes
16 answers

Unable to compile Rust hello world on Windows: linker link.exe not found

I have installed Rust on windows from Rust installation page. After installation I tried running the "hello world" program but got the following error. >cargo run Error Compiling helloworld v0.1.0 (C:\Users\DELL\helloworld) error: linker…
Zobia Kanwal
  • 4,085
  • 4
  • 15
  • 38
140
votes
32 answers

Duplicate Symbols for Architecture arm64

When I try running my Xcode Project it fails with an error stating that I have duplicate symbols. I looked online where the find these duplicates but have had no luck: Any ideas how to fix this?
user1445205
127
votes
7 answers

What does "collect2: error: ld returned 1 exit status" mean?

I see the error collect2: error: ld returned 1 exit status very often. For example, I was trying to build the following snippet of code: void main() { char i; printf("ENTER i"); scanf("%c", &i); clrscr(); switch(i) { default: …
user3682120
  • 1,273
  • 2
  • 9
  • 4
125
votes
4 answers

Undefined reference to `sin`

I have the following code (stripped down to the bare basics for this question): #include #include double f1(double x) { double res = sin(x); return 0; } /* The main function */ int main(void) { return 0; } When…
robintw
  • 27,571
  • 51
  • 138
  • 205
108
votes
6 answers

C error: undefined reference to function, but it IS defined

Just a simple program, but I keep getting this compiler error. I'm using MinGW for the compiler. Here's the header file, point.h: //type for a Cartesian point typedef struct { double x; double y; } Point; Point create(double x, double y); Point…
upswimsdn
  • 1,194
  • 2
  • 8
  • 10
94
votes
4 answers

Trying to include a library, but keep getting 'undefined reference to' messages

I am attempting to use the libtommath library. I'm using the NetBeans IDE for my project on Ubuntu linux. I have downloaded and built the library, I have done a 'make install' to put the resulting .a file into /usr/lib/ and the .h files into…
KU1
  • 941
  • 1
  • 7
  • 4
88
votes
5 answers

Undefined reference to sqrt (or other mathematical functions)

I have this simple code: max = (int) sqrt (number); and in the header I have: #include But application still says undefined reference to sqrt. Do you see any problem here? It looks like everything should be okay.
Waypoint
  • 17,283
  • 39
  • 116
  • 170
84
votes
4 answers

Symbol not found: kUTTypeImage

I copied some bits of code from apple's documentation- and I got these 2 errors: Undefined symbols for architecture i386: "_kUTTypeImage", referenced from: -[ImagePicker imagePickerController:didFinishPickingMediaWithInfo:] in…
Lior Pollak
  • 3,362
  • 5
  • 27
  • 48
80
votes
3 answers

Multiple definition of ... linker error

I defined a special file: config.h My project also has files: t.c, t.h pp.c, pp.h b.c b.h l.cpp and #includes: in t.c: #include "t.h" #include "b.h" #include "pp.h" #include "config.h" in b.c: #include "b.h" #include…
mazix
  • 2,540
  • 8
  • 39
  • 56
80
votes
11 answers

file was built for archive which is not the architecture being linked (i386)

I got to build static library. I want to use in my iPhone and ipad app. When I try to run the simulator I get linking errrors. I am new to iOS development. kindly help; ld: warning: ignoring file …
yarlg
  • 3,481
  • 3
  • 20
  • 20
73
votes
5 answers

Q_OBJECT throwing 'undefined reference to vtable' error

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 …
Donotalo
  • 12,748
  • 25
  • 83
  • 121
71
votes
9 answers

Qt Linker Error: "undefined reference to vtable"

This is my header: #ifndef BARELYSOCKET_H #define BARELYSOCKET_H #include //! The First Draw of the BarelySocket! class BarelySocket: public QObject { Q_OBJECT public: BarelySocket(); public slots: void sendMessage(Message…
Thomas
  • 1,545
  • 3
  • 14
  • 25
65
votes
2 answers

Penalty of the MSVS compiler flag /bigobj

The basic Google search bigobj issue shows that a lot of people are experiencing the Fatal Error C1128: "number of sections exceeded object file format limit : compile with /bigobj". The error has more chance to occur if one heavily uses a library…
lrineau
  • 6,036
  • 3
  • 34
  • 47
1
2 3
99 100