Skip to main content
gamedev.net
🔒 Locked

Problem with makefiles

Started by King of Men 4 replies 650+ views
Original Post
King of Men
King of Men
I have two packages; call them Main and Support. I would like to make Main use a class that is defined in Support. To that end, my Main.cc file has these lines in it :

#include "Support/SupportClass.hh"

(...)

SupportClass* mySupport = new SupportClass();
Now, I can compile this, but when I try to link I get the error Main.cc:lineNumber: undefined reference to SupportClass::SupportClass() Well, the argumentless constructor is certainly defined, in SupportClass.cc. What can I do (at the makefile level, I think) to so that make becomes aware of it? There is probably something trivially simple that I've forgotten, but I've been banging my head at this for two hours and am no longer seeing the trees; the bark is getting in the way.
To win one hundred victories in one hundred battles is not the acme of skill. To subdue the enemy without fighting is the acme of skill.
CrazyCdn
CrazyCdn
What compiler are you using?
"Those who would give up essential liberty to purchase a little temporary safety deserve neither liberty nor safety." --Benjamin Franklin
smart_idiot
smart_idiot
If you're writing the makefile yourself, you should probably post it, and if it's automatically generated, you should probably tell us what program is generating it (such as your IDE).
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other
haegarr
haegarr
Quote:
Original post by King of Men
Main.cc:lineNumber: undefined reference to SupportClass::SupportClass()

Well, the argumentless constructor is certainly defined, in SupportClass.cc. What can I do (at the makefile level, I think) to so that make becomes aware of it? There is probably something trivially simple that I've forgotten, but I've been banging my head at this for two hours and am no longer seeing the trees; the bark is getting in the way.

In principal, the makefile seems to link the Main.cc's object file without having the SupportClass.cc's object file at hand. Either the latter one isn't compiled correctly (so that the compiler hasn't created the object file, but then the makefile should fail _before_ linking), or it isn't listed as a file to be linked.

(As Mike2343 and smart_idiot already stated correctly, give us more information.)
bubu LV
bubu LV
Either you are not linking with SupportClass.o file or SupportClass constructor has not public visibility.
King of Men
King of Men
Hmm, you're right, I haven't given you enough information. But unfortunately, I can't give you a lot more, due to some proprietary issues. I guess I'll have to solve it myself. :(
To win one hundred victories in one hundred battles is not the acme of skill. To subdue the enemy without fighting is the acme of skill.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.