Sign in to follow this  

[RakNet & Dev-C++] HuffmanEncodingTree link errors

Recommended Posts

SteelGolem    398
this thread/post is more of a 'quick-fix' for anyone having problems using RakNet with Dev-C++. when i got RakNet and followed their documentation on how to build the thing, i didn't really have much idea about what they were talking about. it turns out that there's a Dev-C++ dev file right at the root of the source tree (oddly enough it was called loading that puppy up with Dev-C++ and hitting the Compile button seemed like the obvious thing to do. and great! it worked. with warnings. oh well, i had a brand-spanking new RakNet.a and i was ready to take on the world. well the next step is where the trouble begins. i took their tutorial source 1 and threw it at a new project that included the RakNet include folder in the Project Options. i also blasted libwsock32.a and the RakNet.a file the above block created at the Link Options found in the Project options, and bing! compiled. *crunch* no go! wtf??
../../../../../RakNet/RakNet.a(RakPeer.o)(.text+0x2d29):RakPeer.cpp: undefined reference to `HuffmanEncodingTree::EncodeArray(unsigned char*, int, RakNet::BitStream*)' ../../../../../RakNet/RakNet.a(RakPeer.o)(.text+0x4ab3):RakPeer.cpp: undefined reference to `HuffmanEncodingTree::HuffmanEncodingTree()' ../../../../../RakNet/RakNet.a(RakPeer.o)(.text+0x4b09):RakPeer.cpp: undefined reference to `HuffmanEncodingTree::GenerateFromFrequencyTable(unsigned int*)' ../../../../../RakNet/RakNet.a(RakPeer.o)(.text+0x4b3c):RakPeer.cpp: undefined reference to `HuffmanEncodingTree::HuffmanEncodingTree()' ../../../../../RakNet/RakNet.a(RakPeer.o)(.text+0x4ba7):RakPeer.cpp: undefined reference to `HuffmanEncodingTree::GenerateFromFrequencyTable(unsigned int*)' ../../../../../RakNet/RakNet.a(RakPeer.o)(.text+0x4c21):RakPeer.cpp: undefined reference to `HuffmanEncodingTree::~HuffmanEncodingTree()' ../../../../../RakNet/RakNet.a(RakPeer.o)(.text+0x4c64):RakPeer.cpp: undefined reference to `HuffmanEncodingTree::~HuffmanEncodingTree()' ../../../../../RakNet/RakNet.a(RakPeer.o)(.text+0x825f):RakPeer.cpp: undefined reference to `HuffmanEncodingTree::DecodeArray(unsigned char*, int, RakNet::BitStream*)'
huhwhat? well, it turns out they forgot to add one of the source files, HuffmanEncodingTree.cpp, to the dev file. odd, huh? guess what, that means we gotta do it. so we go back to the first step and load up the file - and add the cpp to the source tree. then we recompile the library file. oh teh noes~ moer er0rrs!!!11
In file included from C:/Dev-Cpp/include/c++/3.4.2/backward/Queue.h:31, from Source/HuffmanEncodingTree.cpp:47: C:/Dev-Cpp/include/c++/3.4.2/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated. Source/HuffmanEncodingTree.cpp: In member function `void HuffmanEncodingTree::FreeMemory()': Source/HuffmanEncodingTree.cpp:91: error: `Queue' is not a member of `BasicDataStructures' Source/HuffmanEncodingTree.cpp:91: error: expected primary-expression before '*' token Source/HuffmanEncodingTree.cpp:91: error: expected primary-expression before '>' token Source/HuffmanEncodingTree.cpp:91: error: `nodeQueue' undeclared (first use this function) Source/HuffmanEncodingTree.cpp:91: error: (Each undeclared identifier is reported only once for each function it appears in.)
jeez, the problems just keep hitting us upside the head! we got this far on the RakNet forums, and the workaround was to alter the source. well, thats a crap idea - the library is as clean as it gets. the problem turns out to be the order in which dev-c++ (actually mingw/gcc) looks up the stuff in the headers. what, you scream? at the top of the HuffmanEncodingTree.cpp is a line that reads:
#include "Queue.h"
well, there's a file in the old stl called queue.h - but its from old c++ and mingw/gcc doesn't want you to use it. that's what the #warning is going on about. so what's RakNet doing? well, they actually have their own Queue.h file that they were TRYING to use instead, thus the "double quotes" instead of the <pointy brackets>. my fix just involves pointing this #include at the right spot on disk, in my case:
#include "C:\RakNet\Include\Queue.h"
i've sent some pms out to the guys at the RakNet forums, and hopefully they'll get the gcc makefiles to shove the RakNet include directory ahead of the defaults, so it sees their queue.h before it looks up the stl ones. i don't even know if that can even happen or not, i don't know anything THAT complicated. anyone interested in the original posts on the RakNet forums, there you are. just follow the link and go to it. SG [edit: had some problems posting this. looks like the boards don't like lines starting with ../../ but i found a workaround. adding a bold-end html tag at the start of it makes it work.] [edit: gotta look into -Wno-depreciated for a better fix] [Edited by - SteelGolem on October 21, 2005 1:27:24 PM]

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this