Archived

This topic is now archived and is closed to further replies.

WildWest

Converting to Dev-Cpp drives me crazy

Recommended Posts

Hello everybody! I am trying to convert my directx game engine from M$ VC++6 to Dev-C++. Everything works fine with my engine-dll, it compiled without errors. When i am now trying to write a game using this engine i got linking errors, even though I definitely link to my lib file. The crazy thing is that these linker errors appear only for SOME member functions of my classes. Any ideas? I have been sitting for 5 hours now to solve this problem .... The Wild Wild West - Desperado!

Share this post


Link to post
Share on other sites
make sure that your .lib is converted to .a (Dev-C++ format)
also i remember when i first did DirectX on Dev-C++ i had to put -fthunks -vtable in the compiler options. do anyone know if you still have to do that?

Share this post


Link to post
Share on other sites
the problem is not creating and linking my engine dll (and lib file) with all the directx stuff it it (this problem i solved three hours before ;-)

The problem is now creating the game itself where i have to link to my own engine lib file. (everything worked fine under vc).


The Wild Wild West - Desperado!

Share this post


Link to post
Share on other sites
I _definitely_ link to the library!! I know this because when i do not link to it I get about 120 errors, when I link to it I only get 18. ;-)

My error is a [linker error] undefined reference to SomeClass::SomeMemberFuntion.

The problem is why only to a few member function out of a class. E.g. i have an input class with about 20 member function, but the linker error only appears for __1__ member function.

Any ideas?


The Wild Wild West - Desperado!

[edited by - Wildwest on May 20, 2004 3:51:58 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
OK, this must be a compiler error. I have _exactly_ the same problem: engine library compiles but the compiling the tests gives linker errors. I am definitely linking to my lib (that''s not the problem), but the linker says that my INPUT:: and TIMER:: methods are undefined. Everything else links away just fine. The funny thing is that these classes use exactly the same things as the others (the don''t rely on anything different than the VIDEO:: methods for example, but the latter works when the former don''t).
I''ll try downloading the CVS version to see if it works. I''ll post here sometime later my results.

PS: (WildWest) If you can get it to work, please post here!

Share this post


Link to post
Share on other sites
Rule number 1 when asking a question:
Include any possibly errors, exactly as they appear in your post. Don''t just say the linker gave me some error, or the linker gave me some error that tells blbalb, where blbalb is your own interpretion of the error.

Rule number 2:
Include any relevant code in your post.

Share this post


Link to post
Share on other sites
quote:
Original post by fredizzimo
Rule number 1 when asking a question:
Include any possibly errors, exactly as they appear in your post. Don''t just say the linker gave me some error, or the linker gave me some error that tells blbalb, where blbalb is your own interpretion of the error.

Rule number 2:
Include any relevant code in your post.


It would not help you any more.
I (and maybe Anonymous ) need more general advice.
It would not be good to post over 20 files of code with about 200 lines each ;-)
I got 17 linker errors (as i described above)
with
[linker error]: undefined reference to function MyNameSpace::SomeClass::Somememberfunction().

And this occurs although I definetely link to the .lib-file created while creating my dll.


The Wild Wild West - Desperado!

Share this post


Link to post
Share on other sites
quote:
Original post by WildWest
quote:
Original post by fredizzimo
Rule number 1 when asking a question:
Include any possibly errors, exactly as they appear in your post. Don''t just say the linker gave me some error, or the linker gave me some error that tells blbalb, where blbalb is your own interpretion of the error.

Rule number 2:
Include any relevant code in your post.


It would not help you any more.
I (and maybe Anonymous ) need more general advice.
It would not be good to post over 20 files of code with about 200 lines each ;-)
I got 17 linker errors (as i described above)
with
[linker error]: undefined reference to function MyNameSpace::SomeClass::Somememberfunction().

And this occurs although I definetely link to the .lib-file created while creating my dll.


The Wild Wild West - Desperado!


You don''t need to post all the code, just the relevant. Post the header containing the problematic member function. And the exact linker error message. It''s probably either a static or private/protected function that cause problems. A thing that would have been immeadetly spotted, with the exact error message and the code.

Share this post


Link to post
Share on other sites
Without seeing the compiler output it''s really hard to say but I''ll make a few stabs in the dark.

Are the functions inline? Are they const member functions? Do they include ASM? Do the linking errors occur for every function you link to or do some link successfully?

Share this post


Link to post
Share on other sites
Show us the code, or at least some of it. For example, it might be very useful to see which functions exhibit the problem and which do not.

[ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
With gcc 3.2, the error reads like this (I believe that WildWest receives the same errors):

[Linker error] undefined reference to `WARP2::INPUT_TASK::INPUT_TASK()''

D:\programming\C&C++\Warp_engine2\test\Makefile.win
[Build Error] [test1.exe] Error 1

which refers to the following line (commenting it out allows the file to compile succesfully):
SM_POINTER<INPUT_TASK> input_task = new INPUT_TASK();

The SM_POINTER<...> is a smart pointer class as defined in the Enginuity articles. INPUT_TASK is defined as follows:

class INPUT_TASK : public TASK
{
public:
INPUT_TASK();
virtual ~INPUT_TASK();

bool start();
void update();
void stop();

... (several other functions of no consequence)
};

where TASK is defined as:

class TASK : virtual public MM_OBJECT
{
public:
TASK()
{
can_kill = false;
priority = 5000;
}
virtual bool start()=0;
virtual void on_suspend() {};
virtual void update()=0;
virtual void on_resume() {};
virtual void stop()=0;

bool can_kill;
long priority;
};
(just lays down the interface)

The INPUT_TASK constructor is empty (but has been declared and defined as such).

The strange thing is that the VIDEO_TASK class is defined in exactly the same way, but the:
SM_POINTER<VIDEO_UPDATE> video_task = new VIDEO_TASK();
works correctly!

I can include more code if you need (but please tell me how to use code tags

Please, give your thoughts on this.

Share this post


Link to post
Share on other sites
The forum FAQ will tell you how to use code tags.

Why are you using virtual inheritance?

Where is the INPUT_TASK() constructor defined, and in which file?

[ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]

Share this post


Link to post
Share on other sites
Ok. Here are my first three errors and the corresponding code:

[Linker error] undefined reference to `Angela::CInput::EnumDevices()''
[Linker error] undefined reference to `Angela::CTimer::Update()''
[Linker error] undefined reference to `Angela::CInput::KeyPressed(int) const''


////////////////////////////////////////////////////////////////

inline void CInput::EnumDevices()
{
m_pDI->EnumDevices(DI8DEVCLASS_ALL, EnumDevicesCallback , (void *)this, DIEDFL_ATTACHEDONLY);
}


//////////////////////////////////////////////////////////////

inline void CTimer::Update()
{
QueryPerformanceCounter(&m_liTimerCur);

double dTimeOld = m_dTime;
m_dTime = (double)((double)(m_liTimerCur.QuadPart - m_liTimerStart.QuadPart) / (double)m_liTimerFreq.QuadPart);
m_dDeltaTime = m_dTime - dTimeOld;

//update fps every second

m_dFPSUpdate += m_dDeltaTime;
if(m_dFPSUpdate >= 1.0)
{
m_dFPSUpdate = 0.0;
m_dFPS = m_dFrameCount;
m_dFrameCount = 0.0;
}
else
m_dFrameCount++;

//update total time and total frame count

m_dTotalTime += m_dDeltaTime;
m_uiTotalFrames++;
}


////////////////////////////////////////////////////////////////

inline BYTE CInput::KeyPressed(int nKey) const
{
return (m_aKeys[nKey] & 0x80);
}


I think, that it is not the reason that they are all inline funtions, because i have a lot of other inline functions too, where this error does not occur.

The Wild Wild West - Desperado!

Share this post


Link to post
Share on other sites
You think... but have you tried removing the ''inline'' and seeing what happens? Try it to be sure. Otherwise that little extract of code doesn''t help. The content of the function is meaningless when dealing with linkage issues. It''s the declaration and the file that it''s in which are important. And in this case there seems to be a namespace involved too.

[ MSVC Fixes | STL Docs | SDL | Game AI | Sockets | C++ Faq Lite | Boost
Asking Questions | Organising code files | My stuff | Tiny XML | STLPort]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Did you enter the namespace before defining the functions? You need either Angela::CInput::blah or namespace Angela { ... } around the entire file.

Share this post


Link to post
Share on other sites
Making all the functions not inline helped to remove the linker error !!!!!

Thanks, but i really do not understand why?
Can anybody explain?


btw, now i have an access violation while starting my game :-((

The Wild Wild West - Desperado!

Share this post


Link to post
Share on other sites