Questions tagged [undefined-reference]

A linker error caused by a missing definition of a symbol used elsewhere in a program

The most common causes are

  • Declaring but not defining a function, global variable or static data member
  • Not compiling or linking to an object file that contains the definition of a symbol
  • Forgetting to link to the library that provides the symbol
  • Listing a required library before the objects that depend on it (in the linker command libraries should be listed after the objects that depend on them)

There is a C++ FAQ question about undefined references in C++ and how to solve them.

1243 questions
-1
votes
1 answer

Undefined reference to 'explain_setsocket'

socket() function used in my code returns -1. Inorder to know more about it example_socket() is added and add headerfile #include While compiling -lexplain is also added. But i have below error undefined reference to…
student
  • 39
  • 1
  • 3
-1
votes
1 answer

undefined reference C file

I use on libnfc project on github: when i try to compile this file https://github.com/nfc-tools/libnfc/blob/master/examples/pn53x-diagnose.c i got error of undefined reference to pn53x_transceive' on line 106+117 why? on line 53 it do #include…
-1
votes
2 answers

gcc compile errors when c++ code is sound

My last question on here had issues that apperently were gcc not the code(code errors were solved and then I noticed issues with gcc ). I have since whipped up a short hello world program that I know is sound to test this: #include using…
Josh
  • 23
  • 1
  • 7
-1
votes
2 answers

Compiler gives error about undefined reference to a function

Following is my code compiler says undefined reference to function . please elaborate what to do. Why does it give an error about undefined reference to the function isPalindrome() which is boolean? int main() { cout << "Please…
Muhammad Shahid
  • 81
  • 2
  • 12
-1
votes
1 answer

What is wrong with my code within my merge sort.h file that is causing a undefined reference?

The error that I keep receiving is g++ -Wall -std=c++11 -o assign8 assign8.o assign8.o: In function void mergeSort(std::vector >&, bool (*)(int const&, int…
THE ONE
  • 1
  • 8
-1
votes
1 answer

C++ Undefined Reference to overloaded operator

Having a problem with my overloaded << operator, cygwin is returning 2 errors, DeckOfCardsDemo.o:DeckOfCardsDemo.cpp:(.text+0xd3): undefined reference to `samuel::operator<<(std::ostream&, samuel::DeckOfCards const&)' …
Riggy
  • 7
  • 1
  • 7
-1
votes
1 answer

Why is a function in a C header file available in main.c, but errors as undefined at compile time?

I have a C project in Eclipse (Neon) on Ubuntu 15.10. I have downloaded the OpenSSL library. I have included openssl/bn.h in my preprocessor directives. In my main.c file, I can refer to BN_new(), a function in bn.h: However, when I try to…
learningtofly
  • 353
  • 1
  • 2
  • 13
-1
votes
1 answer

C programming error: [undefined reference to: 'show_record']

I took code from online http://www.codewithc.com/quiz-game-mini-project-in-c/ and I was getting errors in the code, so I cut down the code. I am getting an error [undefined reference to: 'show_record'] I cannot solve. Any help or suggestions on how…
user1049876
  • 117
  • 1
  • 3
  • 18
-1
votes
1 answer

Undefined reference to hash function

I'm trying to run a program in Code::Blocks, and in my program I have used the hash functions, such as hsearch and hcreate, but Code::Blocks seems to not allow them. I have the header: #include included already, but errors such as…
Boku
  • 63
  • 9
-1
votes
1 answer

C++ : A program compiled and run on CodeBlocks works but from Terminal it gives error statement

I'm having some issues with the Virtual Machine I was supposed to work with to make a C++ project, it regularly compiles both on DevC++ and CodeBlocks (Eureka!), runs and does exactly what it is meant for. Anyway, I tried to start the execution from…
-1
votes
1 answer

Undefined reference to 'function' yet the header is included

I am playing around with the ci20 and flowcloud. I have downloaded their c library/sdk and have included the header. The program is simply: #include #include #include int main (int argc, char*argv[]) { …
uhsl_m
  • 322
  • 3
  • 11
-1
votes
1 answer

Inheritance Linking throws 'undefined reference to...' C++

I've writing a "big" Indexs project in C++, that is difficult for me meanwhile... While i was trying to create an inheritance between 2 clases: ZonalPermutant wich inherit from Permutant i got the following error: error: g++ -Wall -std=c++0x…
-1
votes
1 answer

Compiler doesn't see my main function ( Undefined reference to main)

I have 2 cpp and 3 header files in my project. When I compile them in VS it works smoothly and I get no error message. But when I try to compile it on SSH network by this line: g++ -o program.cpp lineoperations.cpp customer.h transaction.h…
K.Yazoglu
  • 207
  • 3
  • 13
-1
votes
1 answer

Operator Overloading &reference (undefined reference error)

I was practising the operator overloading and references. I copied a Money program but there was error when compilation. I couldnt understand what is the error mean and i not sure where is it.…
m1031
  • 15
  • 1
  • 5
-1
votes
2 answers

Udefined reference to 'printpos'

I am trying to print the position of the file pointer(via the printpos() function) showing its position in the child and parent. Upon compiling my code I am left with these errors: xxxxxx@ubuntu:~/USP_ASG2$ gcc -o q1 q1.c /tmp/cc4zpABN.o: In…
Andrew Ricci
  • 475
  • 5
  • 21