Dev-C++ & IrrNet

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Muhaha
Posts: 17
Joined: Wed Feb 13, 2008 10:07 am

Dev-C++ & IrrNet

Post by Muhaha »

I try to compile example1 with devc++ but i have this errors.

Code: Select all

Compilatore: Default compiler
Building Makefile: "F:\irrlicht\irrlicht-1.4\examples\01.HelloWorld\Makefile.win"
Esecuzione di  make clean
rm -f main.o example1.o  ../../bin/Win32-gcc/01.HelloWorld.exe

g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"C:/Dev-Cpp/include/c++/3.4.2"  -I"C:/Dev-Cpp/include"  -I"../../include"  -I"F:/irrlicht/irrnet/base"  -I"F:/irrlicht/enet-1.1/include"   

g++.exe -c example1.cpp -o example1.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"C:/Dev-Cpp/include/c++/3.4.2"  -I"C:/Dev-Cpp/include"  -I"../../include"  -I"F:/irrlicht/irrnet/base"  -I"F:/irrlicht/enet-1.1/include"   

example1.cpp: In function `int main()':
example1.cpp:65: error: cannot declare variable `receiver' to be of type `MyEventReceiver'
example1.cpp:65: error:   because the following virtual functions are abstract:
../../include/IEventReceiver.h:256: error:  virtual bool irr::IEventReceiver::OnEvent(const irr::SEvent&)

example1.cpp:214: error: `swprintf_s' undeclared (first use this function)
example1.cpp:214: error: (Each undeclared identifier is reported only once for each function it appears in.)

make.exe: *** [example1.o] Error 1

Esecuzione terminata
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

The first error is due to a change in IEventReceiever, now the parameter to OnEvent should be const irr::SEvent& as shown in the error message, before it used to be just irr::SEvent i think. Basically the code you're trying to compile was written for irrlicht 1.3.1 or earlier and you're trying to compile it with 1.4 (i guess)

The second error i'm not so sure swprintf_s doesn't sound like a proper function name so it could be a typo in the code or it could be the compiler giving the name in a strange way, seeing the code on line 214 would be useful to work it out.
Image Image Image
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

swprintf_s is the "safe" variant of swprintf M$ uses in latest MSVC libraries. If this is used in user code directly it's up to the user to make sure that the C runtime supports it. If it comes from Irrlicht's replacements it could be due to wrong defines somewhere. However, example 1 does not have 214 lines, so I cannot say what's happening.
Muhaha
Posts: 17
Joined: Wed Feb 13, 2008 10:07 am

Post by Muhaha »

with irrlicht 1.3.1 i have only swprintf_s error.

my example1.cpp downloaded from http://sourceforge.net/projects/irrnet have 231 lines of code
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

As i said, if you show us what line 214 is from the example we might be able to help a bit more.
Image Image Image
Muhaha
Posts: 17
Joined: Wed Feb 13, 2008 10:07 am

Post by Muhaha »

ok , this is the code

Code: Select all

		if (lastFPS != fps)
		{
			wchar_t tmp[1024];
			swprintf_s(tmp, 1024, L"Network Test[%ls] fps: %d (Server can press Space to change Cube colour!)",
               driver->getName(), fps);
			device->setWindowCaption(tmp);
			lastFPS = fps;
		}
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Just get rid of the _s, so the function is just swprintf
Image Image Image
Muhaha
Posts: 17
Joined: Wed Feb 13, 2008 10:07 am

Post by Muhaha »

Code: Select all

		if (lastFPS != fps)
		{
			wchar_t tmp[1024];
			swprintf(tmp, 1024, L"Network Test[%ls] fps: %d (Server can press Space to change Cube colour!)", 
               driver->getName(), fps);
			device->setWindowCaption(tmp);
			lastFPS = fps;
		}

Code: Select all

Compilatore: Default compiler
Building Makefile: "F:\irrlicht\irrlicht-1.3.1\examples\01.HelloWorld\Makefile.win"
Esecuzione di  make clean
rm -f example1.o  ../../bin/Win32-gcc/01.HelloWorld.exe

g++.exe -c example1.cpp -o example1.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"C:/Dev-Cpp/include/c++/3.4.2"  -I"C:/Dev-Cpp/include"  -I"../../include"  -I"F:/irrlicht/irrnet/base"  -I"F:/irrlicht/enet-1.1/include"   

example1.cpp: In function `int main()':
example1.cpp:214: error: invalid conversion from `int' to `const wchar_t*'
example1.cpp:214: error:   initializing argument 2 of `int swprintf(wchar_t*, const wchar_t*, ...)'

make.exe: *** [example1.o] Error 1

Esecuzione terminata
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

That's an error i've come across before too for some reason, getting rid of the 1024 in the swprintf function should fix it.

There are (at least) two versions of swprintf, one lets you specify how big the wchar_t array is and the other doesn't, for some reason i'm often not allowed to use the one that specifies the length, maybe it's something to do with an include file...
Image Image Image
Muhaha
Posts: 17
Joined: Wed Feb 13, 2008 10:07 am

Post by Muhaha »

i use wprintf , but now i have this errors

Code: Select all

Compilatore: Default compiler
Building Makefile: "F:\irrlicht\irrlicht-1.3.1\examples\01.HelloWorld\Makefile.win"
Esecuzione di  make clean
rm -f example1.o  ../../bin/Win32-gcc/01.HelloWorld.exe

g++.exe -c example1.cpp -o example1.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include"  -I"C:/Dev-Cpp/include/c++/3.4.2/backward"  -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32"  -I"C:/Dev-Cpp/include/c++/3.4.2"  -I"C:/Dev-Cpp/include"  -I"../../include"  -I"F:/irrlicht/enet-1.1/include"  -I"F:/irrlicht/irrnet/base"   

g++.exe example1.o  -o "..\..\bin\Win32-gcc\01.HelloWorld.exe" -L"C:/Dev-Cpp/lib" ../../lib/Win32-gcc/libIrrlicht.a C:/Dev-Cpp/lib/libws2_32.a  

example1.o(.text+0x2c0):example1.cpp: undefined reference to `irr::net::INetManager::INetManager(irr::IrrlichtDevice*)'
example1.o(.text+0x331):example1.cpp: undefined reference to `irr::net::INetManager::setVerbose(bool)'
example1.o(.text+0x345):example1.cpp: undefined reference to `irr::net::INetManager::setUpClient()'
example1.o(.text+0x35c):example1.cpp: undefined reference to `irr::net::INetManager::setUpServer()'
example1.o(.text+0x435):example1.cpp: undefined reference to `irr::net::INetManager::addNetSphereSceneNode(float, int, irr::core::vector3d<float>, irr::core::vector3d<float>, irr::core::vector3d<float>)'
example1.o(.text+0x452):example1.cpp: undefined reference to `irr::net::INetManager::sendPositionAuto(irr::scene::ISceneNode*, unsigned int)'
example1.o(.text+0x51c):example1.cpp: undefined reference to `irr::net::INetManager::addNetSphereSceneNode(float, int, irr::core::vector3d<float>, irr::core::vector3d<float>, irr::core::vector3d<float>)'
example1.o(.text+0x53d):example1.cpp: undefined reference to `irr::net::INetManager::sendPositionAuto(irr::scene::ISceneNode*, unsigned int)'
example1.o(.text+0x87e):example1.cpp: undefined reference to `irr::net::INetManager::updateClient()'
example1.o(.text+0x8cb):example1.cpp: undefined reference to `irr::net::INetManager::sendVelocity(irr::scene::ISceneNode*, irr::core::vector3d<float>, bool)'
example1.o(.text+0x8f6):example1.cpp: undefined reference to `irr::net::INetManager::setLocalVelocity(irr::scene::ISceneNode*, irr::core::vector3d<float>)'
example1.o(.text+0x922):example1.cpp: undefined reference to `irr::net::INetManager::updateServer()'
example1.o(.text+0x957):example1.cpp: undefined reference to `irr::net::INetManager::getCustomVar(irr::scene::ISceneNode*, unsigned short)'
example1.o(.text+0x97f):example1.cpp: undefined reference to `irr::net::INetManager::sendCustomVar(irr::scene::ISceneNode*, unsigned short, unsigned int)'
example1.o(.text+0x9aa):example1.cpp: undefined reference to `irr::net::INetManager::getCustomVar(irr::scene::ISceneNode*, unsigned short)'
example1.o(.text+0x9d3):example1.cpp: undefined reference to `irr::net::INetManager::sendCustomVar(irr::scene::ISceneNode*, unsigned short, unsigned int)'
example1.o(.text+0x9fe):example1.cpp: undefined reference to `irr::net::INetManager::getCustomVar(irr::scene::ISceneNode*, unsigned short)'
example1.o(.text+0xa27):example1.cpp: undefined reference to `irr::net::INetManager::sendCustomVar(irr::scene::ISceneNode*, unsigned short, unsigned int)'
example1.o(.text+0xa4f):example1.cpp: undefined reference to `irr::net::INetManager::getCustomVar(irr::scene::ISceneNode*, unsigned short)'
example1.o(.text+0xa78):example1.cpp: undefined reference to `irr::net::INetManager::sendCustomVar(irr::scene::ISceneNode*, unsigned short, unsigned int)'
example1.o(.text+0xacd):example1.cpp: undefined reference to `irr::net::INetManager::sendVelocity(irr::scene::ISceneNode*, irr::core::vector3d<float>, bool)'
example1.o(.text+0xafa):example1.cpp: undefined reference to `irr::net::INetManager::setLocalVelocity(irr::scene::ISceneNode*, irr::core::vector3d<float>)'
example1.o(.text+0xb29):example1.cpp: undefined reference to `irr::net::INetManager::getSceneNodeFromNetId(unsigned short)'
example1.o(.text+0xb6d):example1.cpp: undefined reference to `irr::net::INetManager::getSceneNodeFromNetId(unsigned short)'
example1.o(.text+0xb9a):example1.cpp: undefined reference to `irr::net::INetManager::getSceneNodeFromNetId(unsigned short)'
example1.o(.text+0xbd6):example1.cpp: undefined reference to `irr::net::INetManager::getSceneNodeFromNetId(unsigned short)'
example1.o(.text+0xbed):example1.cpp: undefined reference to `irr::net::INetManager::getCustomVar(irr::scene::ISceneNode*, unsigned short)'
example1.o(.text+0xc24):example1.cpp: undefined reference to `irr::net::INetManager::getSceneNodeFromNetId(unsigned short)'
example1.o(.text+0xc60):example1.cpp: undefined reference to `irr::net::INetManager::getSceneNodeFromNetId(unsigned short)'
example1.o(.text+0xc77):example1.cpp: undefined reference to `irr::net::INetManager::getCustomVar(irr::scene::ISceneNode*, unsigned short)'
example1.o(.text+0xcaf):example1.cpp: undefined reference to `irr::net::INetManager::getSceneNodeFromNetId(unsigned short)'
example1.o(.text+0xceb):example1.cpp: undefined reference to `irr::net::INetManager::getSceneNodeFromNetId(unsigned short)'
example1.o(.text+0xd02):example1.cpp: undefined reference to `irr::net::INetManager::getCustomVar(irr::scene::ISceneNode*, unsigned short)'
example1.o(.text+0xd3a):example1.cpp: undefined reference to `irr::net::INetManager::getSceneNodeFromNetId(unsigned short)'
example1.o(.text+0xd76):example1.cpp: undefined reference to `irr::net::INetManager::getSceneNodeFromNetId(unsigned short)'
example1.o(.text+0xd8d):example1.cpp: undefined reference to `irr::net::INetManager::getCustomVar(irr::scene::ISceneNode*, unsigned short)'
example1.o(.text+0xdc5):example1.cpp: undefined reference to `irr::net::INetManager::getSceneNodeFromNetId(unsigned short)'
collect2: ld returned 1 exit status

make.exe: *** [../../bin/Win32-gcc/01.HelloWorld.exe] Error 1

Esecuzione terminata
Last edited by Muhaha on Wed Feb 13, 2008 11:47 am, edited 2 times in total.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Example 3 now...?

Don't use wprintf, it's a different function that does a different task.

Looks like your include path for irrnet isn't correct. It's set to F:/irrlicht/irrnet by the looks of it, is that correct?
Image Image Image
Muhaha
Posts: 17
Joined: Wed Feb 13, 2008 10:07 am

Post by Muhaha »

sorry wrong log, i edit the post.

i check the path for include
Edit : the path is right
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You don't link in the irrNet object files. Undefined reference means problems linking .o or .lib files.
And swprintf should work, including the max string length parameter. Because Irrlicht adds a define to use _snwprintf instead (which is the windows version of the function with length limitation).
Muhaha
Posts: 17
Joined: Wed Feb 13, 2008 10:07 am

Post by Muhaha »

You don't link in the irrNet object files. Undefined reference means problems linking .o or .lib files.
how can i include this files?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You don't need to include them, you have to link them. Usually your IDE will provide some dialog where you can enter these things. I can only tell you how it would work with command line and gcc. But the irrNet thread should also contain some hints about which files to add to your project.
Post Reply