Linker Error Undefined Reference To Constructor
Contents |
here for a quick overview of the site Help Center Detailed undefined reference to constructor and destructor c++ answers to any questions you might have Meta Discuss the
Undefined Reference To Default Constructor
workings and policies of this site About Us Learn more about Stack Overflow the company
Undefined Reference To Constructor Template
Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the
Undefined Reference To Class C++
Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Undefined reference to class constructor, including .cpp file fixes up vote 14 down vote favorite 1 The problem I am having is c++ undefined reference to class function that, when I call a constructor for a class I have created I get the following error. main.cpp:20: undefined reference to `StaticObject::StaticObject(Graphics*, sf::String, sf::Vector2)' This problem can be 'fixed' adding an include for the .cpp file in main.cpp like so. ... #include "GameObjects/StaticObject.cpp" ... Although this solves the problem, this seems like a poor solution and goes against what I have been previously told. Is there any other way to solve this problem? I'm using Netbeans 7.3 with g++ to code/compile this program. Below is the relevant code. main.cpp ... #include
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting c++ undefined reference to constructor inheritance ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join c++ class undefined reference to constructor the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a c++ undefined reference to superclass constructor minute: Sign up Linker error: “undefined reference to class constructor” up vote 0 down vote favorite I'm trying to build my program. My program uses a class and creates instances of it. while building my program I get linker error "undefined http://stackoverflow.com/questions/15579172/undefined-reference-to-class-constructor-including-cpp-file-fixes reference to class constructor". However the component in which the constructor definition is present has been included as a static library dependency and it is even present in "/usr/lib/" folder. The static library even contains the required symbols. But I'm still not able to resolve the "undefined reference" error linker share|improve this question asked Feb 19 '13 at 6:09 user1124236 81110 Q: What language? C++? Q: Are you #includ'ing the correct header(s)? Q: Are you sure it's a "linker" error http://stackoverflow.com/questions/14950959/linker-error-undefined-reference-to-class-constructor (and not a compile error)? Q: Could you cut/paste the exact error text? –paulsm4 Feb 19 '13 at 6:11 Language is C++. It is a linker error. the error looks like this. undefined reference to `classname::classname(classname const&)' . It is able to locate the header as it compiles successfully, it is not able to find the definition, though I have given the library which which it is present –user1124236 Feb 19 '13 at 6:12 how do you pass the static library? remember the order is important –LeleDumbo Feb 19 '13 at 6:18 I tried re-ordering the libs. But couldnt resolve the issue –user1124236 Feb 19 '13 at 8:02 add a comment| 1 Answer 1 active oldest votes up vote 0 down vote I guess, you've a cpp file with implementation of your <%classname%>. If so, I think you've missed to register this cpp-file in your build system. When linker tries to resolve referencies on your <%classname%>'s member function(s) and constructor(s) it may issue a error if it won't find related implementation( here I mean compiled assembly-code routine ), because it wasn't compiled. share|improve this answer answered Feb 17 '15 at 7:14 Victor L 1 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest Name Email discard By post
std::allocator
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
//strSet.h #ifndef _STRSET_ undefined reference #define _STRSET_ #include
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// strSet.cpp #include
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// setcalc.cpp #include