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 subroutine from module Fortran90

I'm relatively new to fortran90 that I need for a project. I have three scripts, 2 modules and the main program with the following structure: script 1: program main use module1 implicit none .. call sub_from_mod1 end program main script…
Sp_z
  • 1
-1
votes
1 answer

odr-use of `static const int` data member succeeds WITHOUT definition in call taking `const int &`

This is a frustratingly difficult question to ask. I'm asking you to guess what code or conditions in my build system might allow the following to build and run correctly, when the obvious expectation is that it should result in a linker undefined…
MikeW
  • 89
  • 1
  • 4
-1
votes
1 answer

Undefined reference to linker error when using namespaces in headers in c++

I've read through all similar "Undefined reference to" threads I could find but couldn't find a solution. Most of the other threads also involved classes which I don't plan to use for this. The program compiles executes normally if I define the…
xgreenmanx
  • 11
  • 5
-1
votes
1 answer

Javascript Password Generator - Broken Code

Hey guys I have been working on a student project which is build a random password generator I have completed the code to the best of my ability doing lots of looking into youtube videos and with teachers' notes I can not seem to get it to print the…
-1
votes
1 answer

undefined reference to function but my function is a part of a library that I link in cmake with the command target_link_libraries

I have a project which need CVB so I link the CVB libraries in my Cmake and the headers with some include in my main.hpp. Nevertheless functions of CVB which are in these libraries are undefined and I don't understand why. If someone may help me,…
-1
votes
2 answers

linking static class member function throws undefined reference error c++

I've gone through many similar threads on this kind of question but I'm still unable to resolve this error. Any help would be appreciated. /*samp.h header file*/ #include using namespace std; class test { private: test(); public: static…
virmis_007
  • 173
  • 1
  • 4
  • 17
-1
votes
2 answers

Defined functions inside a class are not recognized as defined when I use them

I have this code, but when I try to use the re-defined str function it doesn´t print anything and, more important, the defined function named "cuadrant" doesn´t work as it´s not defined according to python, but it is: class Point: def…
JMarcos87
  • 183
  • 3
  • 11
-1
votes
2 answers

Undefined reference to functions included by a lib

I have one lib which contains a file (called Util.c down here), and i'm trying to use some funtions defined in this file to compile a little prog. I'm already using others functions from the lib, but the ones of this particular file always give me…
Ablia
  • 191
  • 2
  • 10
-1
votes
1 answer

Undefined reference to all my functions C++ I think it may be because of my makefile

I have a header file cerealmanager.h and a main file called cerealmanager.cpp and a file called project2.cpp, which just has catch 2 tests. Whenever I run my code with the makefile it says that all of my functions are undefined (undefined reference…
-1
votes
1 answer

Undefined reference to extern function - C

I'm currently working on a C project, but I'm stuck on what seems to be a simple problem... My files are main.c, main.h, fun1.c, fun2.c and fun3.c. main.h is included in main.c, fun1, fun2 and fun3 (respectively in fun1.C, fun2.c and fun3.c files)…
Windea
  • 23
  • 5
-1
votes
1 answer

difference between static constexpr tuple inside and outside a class

I'm using gcc 4.8.5 with C++11 and I'm trying to understand if the following behavior is normal or if it is a C++11 limitation / compiler bug. Basically I get an undefined reference error to a constexpr tuple if I define it inside a class but not…
-1
votes
6 answers

Problem with using functions in 1 cpp file in another

I have 1 cpp file with main(). It relies on structs and functions in another (say, header.hpp). The structs are defined in header.hpp, along with function prototypes. The functions are implemented in header.cpp. When I try to compile, I get an error…
K-RAN
  • 896
  • 1
  • 13
  • 26
-1
votes
1 answer

Getting the undefined reference error while using gotoxy() function in c in dev-cpp

This is the full error that I get when trying to compile: C:\Users\avrlsngh\AppData\Local\Temp\ccGLqeDo.o gotoxy.c:(.text+0x18): undefined reference to `gotoxy'
avrlsngh
  • 1
  • 2
-1
votes
1 answer

errors on compiler id returned 1 exit status

so im new to c and im trying to write a function that finds the median of an array then display it. I am getting error that say id returned 1 exit status and undefined reference to display median. I tried to look them up but none of the post applied…
-1
votes
1 answer

Solving 'undefined reference' in a static lib with a redirect

Hy, I am having the following structure: lib1.a U f1 00000000 T f2 lib2.a 00000000 T f3 main.c: #define f1(a, b) f3(a, b) int main(){ f2(a, b); } Note that f2 uses f1. Is there a way to compile this that will solve the…
dFroze
  • 41
  • 8