zerochen wrote:you have to add the irrnetlite lib as well
That did not work, maybe i should be explaining this better because i dont think i was doing very well at it before.
1. I first created a
Console application in c::b
2. I went to project->build options->linker and i added the irrnetlite.lib ( this could be my problem since it is in the folder
lib/msvc and i am not using msvc
3. I click on search directories and
added everything in the include and source folder I also
added all these
under debug because that was the default it changes sometimes though.
4. Ran the default hello world code. and it works but when i added the tutorial code it dint see below.
Now if i did something wrong already you might as well stop reading because below this is when i copy the code from the tutorial cpp file.
5. selected code from the tutorial file
Code: Select all
#include <iostream>
#include <irrNet.h>
using namespace std;
using namespace irr;
class MyNetCallback : public net::INetCallback
{
public:
virtual void handlePacket(net::SInPacket& packet)
{
// irrNetLite encryption is very easy to use! Just pass
// a 16-byte (128-bit) string to encryptPacket/decryptPacket
// to encrypt/decrypt a packet respectively. Do not try to
// decrypt an un-encrypted packet or read from an encrypted
// packet without decrypting it first or bad things will happen!
packet.decryptPacket("hushthisissecret");
// irrNetLite compression is even easier! The ZLib library is used
// here, just call compressPacket/decompressPacket to
// compress/decompress a packet. Again, do not try to decompress
// an un-compressed packet or read from a compressed packet without
// decompressing it! Another thing to keep in mind is that you should
// decompress and decrypt in the correct order. If you compressed a file
// and then encrypted it when it was sent, you must decrypt it first
// before trying to decompress it, same goes for the other order.
packet.deCompressPacket();
// Extracting info from a received packet is simple. You can treat
// the packet as an input stream, the >> operator is overloaded
// and works for most built in types. The string class in irrNetLite
// is a custom implementation not unlike the std::string. You can
// also send and receive strings as "char*". Note that the "char*"
// and stringc are interchangeable, you can send a stringc and
// receive a char*, or vice-versa.
core::stringc str;
packet >> str;
// Support for a simple 3-dimensional vector class is there too. Both
// vector3df and core::stringc are borrowed from Irrlicht and included
// here for convenience.
core::vector3df vec;
packet >> vec;
// Here we are obtaining the last value from the packet. f32 is just a
// typedef for float.
f32 height;
packet >> height;
// Print the values to the console.
std::cout << "Message: " << str.c_str();
std::cout << " Position: " << vec.X << " " << vec.Y << " " << vec.Z;
std::cout << " Height: " << height << " ft";
std::cout << std::endl;
}
};
int main()
{
// Ask the user whether they want to be the server or a client.
std::cout << "Client (c) or Server (s)?";
char i;
std::cin >> i;
// If they typed 's' they are the server else they are the client.
if(i == 's')
{
// Create a server and pass in a new instance of our callback class. The default
// port that clients can connect to is set to 45000.
MyNetCallback* netCallback = new MyNetCallback();
net::INetManager* netManager = net::createIrrNetServer(netCallback);
// Setting verbose to true makes irrNetLite spit out debug information to the console.
netManager->setVerbose(true);
// While the connection is active (Not failed), we update the netManager.
// Note that since this is a server the connection will pretty much always
// be flagged as active, unless some error occured whilst creating the server.
// A value of 1000 is passed to update to make it hang for a second and wait for
// packets to arrive. (Recommended for servers, so you don't busy-loop).
while(netManager->getConnectionStatus() != net::EICS_FAILED)
netManager->update(1000);
// Don't forget to clean up!
delete netManager;
delete netCallback;
}
else
{
// Create an irrNet client, in this example we will just connect to the localhost
// address ("127.0.0.1"), which basically means we are connecting to the same
// computer the client is on. Note that we just pass a value of 0 as our
// INetCallback, because the client in this example does no need to handle any
// packets. You can safely pass a value of 0 if this is the case.
net::INetManager* netManager = net::createIrrNetClient(0, "127.0.0.1");
// Enable debug messages.
netManager->setVerbose(true);
// Here comes the fun part, while the client is connected we update the netManager
// and ask it to wait 1 second (1000 milliseconds) for new packets to arrive before
// returning. Since the client in this example doesn't actually receive any packets,
// the only purpose of the update call is to leave a 1 second interval between each
// packet we send.
while(netManager->getConnectionStatus() != net::EICS_FAILED)
{
netManager->update(1000);
// To send a packet, first you create an SOutPacket object.
net::SOutPacket packet;
// Then you can use the streaming operator << to add new data to it.
packet << "Help I am stuck on a mountain!";
// You can even chain the << operators like so, just like with ostream.
packet << core::vector3df(50.0f, 30.0f, 20.0f) << 50.0f;
// Compress the packet, not much to be said.
packet.compressPacket();
// Encrypt the packet. Note that here we are just using a simple key
// that is shared among the client and the server. In more sophisticated
// implementations you may want to generate a random key on the server for
// each client and send that using a shared key, then use the new key for
// further communication. Remember that the key should be 16 characters
// long, and obviously the client and server must share the same key.
packet.encryptPacket("hushthisissecret");
// A simple call to "sendOutPacket" will send the packet to the server.
netManager->sendOutPacket(packet);
}
// When the connection disconnects (Or fails), the loop will terminate.
// Remember to delete the netManager so that all the low level networking
// stuff is cleaned up properly.
delete netManager;
}
// And we're done, return 0 and make like a tree.
return 0;
}
6. built and got these errors
Code: Select all
obj\Debug\main.o||In function `main':|
C:\Users\user\Documents\CodeBlocksProjects\irrnet\main.cpp|71|undefined reference to `irr::net::createIrrNetServer(irr::net::INetCallback*, unsigned int, irr::net::SNetParams const&)'|
C:\Users\user\Documents\CodeBlocksProjects\irrnet\main.cpp|95|undefined reference to `irr::net::createIrrNetClient(irr::net::INetCallback*, char const*, unsigned int, irr::net::SNetParams const&)'|
C:\Users\user\Documents\CodeBlocksProjects\irrnet\main.cpp|110|undefined reference to `irr::net::SOutPacket::SOutPacket()'|
C:\Users\user\Documents\CodeBlocksProjects\irrnet\main.cpp|113|undefined reference to `irr::net::SOutPacket::operator<<(char const*)'|
C:\Users\user\Documents\CodeBlocksProjects\irrnet\main.cpp|116|undefined reference to `irr::net::SOutPacket::operator<<(irr::core::vector3d<float> const&)'|
C:\Users\user\Documents\CodeBlocksProjects\irrnet\main.cpp|116|undefined reference to `irr::net::SOutPacket::operator<<(float)'|
C:\Users\user\Documents\CodeBlocksProjects\irrnet\main.cpp|119|undefined reference to `irr::net::SOutPacket::compressPacket()'|
C:\Users\user\Documents\CodeBlocksProjects\irrnet\main.cpp|127|undefined reference to `irr::net::SOutPacket::encryptPacket(char const*)'|
obj\Debug\main.o||In function `ZN13MyNetCallback12handlePacketERN3irr3net9SInPacketE':|
C:\Users\user\Documents\CodeBlocksProjects\irrnet\main.cpp|17|undefined reference to `irr::net::SInPacket::decryptPacket(char const*)'|
C:\Users\user\Documents\CodeBlocksProjects\irrnet\main.cpp|27|undefined reference to `irr::net::SInPacket::deCompressPacket()'|
C:\Users\user\Documents\CodeBlocksProjects\irrnet\main.cpp|37|undefined reference to `irr::net::SInPacket::operator>>(irr::core::string<char, irr::core::irrAllocator<char> >&)'|
C:\Users\user\Documents\CodeBlocksProjects\irrnet\main.cpp|43|undefined reference to `irr::net::SInPacket::operator>>(irr::core::vector3d<float>&)'|
C:\Users\user\Documents\CodeBlocksProjects\irrnet\main.cpp|48|undefined reference to `irr::net::SInPacket::operator>>(float&)'|
||=== Build finished: 13 errors, 0 warnings (0 minutes, 0 seconds) ===|
7. I thought i might as well try to add the files in the source folder so i right clicked my project and clicked add files recursively selected the source folder and clicked ok, then i clicked 'select all files' in the check box which ended up adding files. clicked ok and added them all to both debug and release. I got these errors
Code: Select all
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\host.o||In function `enet_host_create':|
C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\host.c|29|multiple definition of `enet_host_create'|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\host.o:C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\host.c|29|first defined here|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\host.o||In function `enet_host_destroy':|
C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\host.c|85|multiple definition of `enet_host_destroy'|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\host.o:C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\host.c|85|first defined here|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\host.o||In function `enet_host_connect':|
C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\host.c|111|multiple definition of `enet_host_connect'|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\host.o:C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\host.c|111|first defined here|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\host.o||In function `enet_host_broadcast':|
C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\host.c|191|multiple definition of `enet_host_broadcast'|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\host.o:C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\host.c|191|first defined here|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\host.o||In function `enet_host_bandwidth_limit':|
C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\host.c|217|multiple definition of `enet_host_bandwidth_limit'|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\host.o:C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\host.c|217|first defined here|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\host.o||In function `enet_host_bandwidth_throttle':|
C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\host.c|225|multiple definition of `enet_host_bandwidth_throttle'|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\host.o:C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\host.c|225|first defined here|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\list.o||In function `enet_list_clear':|
C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\list.c|15|multiple definition of `enet_list_clear'|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\list.o:C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\list.c|15|first defined here|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\list.o||In function `enet_list_insert':|
C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\list.c|22|multiple definition of `enet_list_insert'|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\list.o:C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\list.c|22|first defined here|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\list.o||In function `enet_list_remove':|
C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\list.c|36|multiple definition of `enet_list_remove'|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\list.o:C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\list.c|36|first defined here|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\list.o||In function `enet_list_size':|
C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\list.c|45|multiple definition of `enet_list_size'|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\list.o:C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\list.c|45|first defined here|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\memory.o||In function `enet_malloc':|
C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\memory.c|11|multiple definition of `enet_malloc'|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\memory.o:C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\memory.c|11|first defined here|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\memory.o||In function `enet_realloc':|
C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\memory.c|22|multiple definition of `enet_realloc'|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\memory.o:C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\memory.c|22|first defined here|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\memory.o||In function `enet_calloc':|
C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\memory.c|34|multiple definition of `enet_calloc'|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\memory.o:C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\memory.c|34|first defined here|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\memory.o||In function `enet_free':|
C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\memory.c|45|multiple definition of `enet_free'|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\memory.o:C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\memory.c|45|first defined here|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\packet.o||In function `enet_packet_create':|
C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\packet.c|22|multiple definition of `enet_packet_create'|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\packet.o:C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\packet.c|22|first defined here|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\packet.o||In function `enet_packet_destroy':|
C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\packet.c|42|multiple definition of `enet_packet_destroy'|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\packet.o:C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\packet.c|42|first defined here|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\packet.o||In function `enet_packet_resize':|
C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\packet.c|55|multiple definition of `enet_packet_resize'|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\packet.o:C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\packet.c|55|first defined here|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\peer.o||In function `enet_peer_throttle_configure':|
C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\peer.c|44|multiple definition of `enet_peer_throttle_configure'|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\peer.o:C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\peer.c|44|first defined here|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\peer.o||In function `enet_peer_throttle':|
C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\peer.c|65|multiple definition of `enet_peer_throttle'|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\peer.o:C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\peer.c|65|first defined here|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\peer.o||In function `enet_peer_send':|
C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\peer.c|103|multiple definition of `enet_peer_send'|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\peer.o:C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\peer.c|103|first defined here|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\peer.o||In function `enet_peer_receive':|
C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\peer.c|175|multiple definition of `enet_peer_receive'|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\peer.o:C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\peer.c|175|first defined here|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\peer.o||In function `enet_peer_reset_queues':|
C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\peer.c|290|multiple definition of `enet_peer_reset_queues'|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\peer.o:C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\peer.c|290|first defined here|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\peer.o||In function `enet_peer_reset':|
C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\peer.c|325|multiple definition of `enet_peer_reset'|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\peer.o:C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\peer.c|325|first defined here|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\peer.o||In function `enet_peer_ping':|
C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\peer.c|378|multiple definition of `enet_peer_ping'|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\peer.o:C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\peer.c|378|first defined here|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\peer.o||In function `enet_peer_disconnect_now':|
C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\peer.c|400|multiple definition of `enet_peer_disconnect_now'|
obj\Debug\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\peer.o:C:\Users\user\Documents\CodeBlocksProjects\Lib\irrNetLite2.1Beta\irrNetLite\source\enet\peer.c|400|first defined here|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build finished: 50 errors, 0 warnings (0 minutes, 3 seconds) ===|
So if you need anymore info please let me know