Skip to main content

Ruby and SWIG errors and solutions

While working on my GDK for Ruby I had to use SWIG to create a C++ extension to rub. The following are the errors encountered and their solutions: Error: /usr/local/lib/site_ruby/1.8/i486-linux/calvarygdk.so: /usr/local/lib/site_ruby/1.8/i486-linux/calvarygdk.so: undefined symbol: _ZTV6Vector - /usr/local/lib/site_ruby/1.8/i486-linux/calvarygdk.so (LoadError) from test.rb:1 Solution: I did not have the Vector.cpp file in the same folder as the .i file. Error: test.rb:9: uninitialized constant Calvarygdk::Quaternion (NameError) Solution: I forgot to put a % instead of # at the beginning of the line here in the .i file: ============================== /* File : example.i */ %module calvarygdk %{ #include "Vector.h" #include "Quaternion.h" %} /* Let's just grab the original header file here */ %include "Vector.h" %include "Quaternion.h" /* <--------------------------- Right here was the problem, I had # instead of % */ ============================== Error: gcc -shared -L"/usr/lib" -o calvarygdk.so calvarygdk_wrap.o Vector.o Quaternion.o DefaultTriMeshData.o -lruby1.8 -lsupc++ -lpthread -ldl -lcrypt -lm -lc gcc: DefaultTriMeshData.o: No such file or directory make: *** [calvarygdk.so] Error 1 Solution Changed the object line to point to a real .o file. In this case a previously generated .o file for DefaultTriMeshData ===========Makefile========== OBJS = calvarygdk_wrap.o Vector.o Quaternion.o graphics/DefaultTriMeshData.o ============================= Error: g++ -fPIC -Wall -g -O2 -fPIC -I. -I/usr/lib/ruby/1.8/i486-linux -I/usr/lib/ruby/1.8/i486-linux -I../ -I/home/jtarquino/irrlicht-1.0/include -I"/usr/X11R6/include" -L"/usr/X11R6/lib" -L"/home/jtarquino/irrlicht-1.0/lib/Linux" -lIrrlicht -lGL -lGLU -lXxf86vm -lXext -lX11 -c ../Quaternion.cpp g++: -lIrrlicht: linker input file unused because linking not done g++: -lGL: linker input file unused because linking not done g++: -lGLU: linker input file unused because linking not done g++: -lXxf86vm: linker input file unused because linking not done g++: -lXext: linker input file unused because linking not done g++: -lX11: linker input file unused because linking not done gcc -shared -L"/usr/lib" -o calvarygdk.so calvarygdk_wrap.o Vector.o Quaternion.o DefaultTriMeshData.o -lruby1.8 -lsupc++ -lpthread -ldl -lcrypt -lm -lc gcc: DefaultTriMeshData.o: No such file or directory make: *** [calvarygdk.so] Error 1 Solutions": The lib problem with gcc was solved by setting the lib path of the makefile and the libs as: ========Makefile============= LIBPATH = -L"$(libdir)" -L"/usr/X11R6/lib" -L"/home/jtarquino/irrlicht-1.0/lib/Linux" LIBS = $(LIBRUBYARG_SHARED) -lsupc++ -lpthread -ldl -lcrypt -lm -lc -lIrrlicht -lGL -lGLU -lXxf86vm -lXext -lX11 ============================= Also, I had to put the DefaultTriMeshData in the folder manually, I don't know why. Th object was in /home/jtarquino/cjptgames/.objs/calvaryfx/src/graphics. Error: g++ -fPIC -g -O2 -lpthread -I. -I/usr/lib/ruby/1.8/i486-linux -I/usr/lib/ruby/1.8/i486-linux -I../ -I/home/jtarquino/irrlicht-1.0/include -I"/usr/X11R6/include" -c calvarygdk_wrap.cxx calvarygdk_wrap.cxx: In function `VALUE _wrap_TriMeshData_setIndices(int, VALUE*, long unsigned int)': calvarygdk_wrap.cxx:3731: warning: converting to non-pointer type `int' from NULL calvarygdk_wrap.cxx:3736: error: invalid conversion from `int' to `void*' calvarygdk_wrap.cxx:3741: error: invalid conversion from `int' to `void*' calvarygdk_wrap.cxx: In function `VALUE _wrap_new_DefaultTriMeshData__SWIG_1(int, VALUE*, long unsigned int)': calvarygdk_wrap.cxx:3922: warning: converting to non-pointer type `int' from NULL calvarygdk_wrap.cxx:3948: error: invalid conversion from `int' to `void*' calvarygdk_wrap.cxx:3953: error: invalid conversion from `int' to `void*' calvarygdk_wrap.cxx: In function `VALUE _wrap_DefaultTriMeshData_setIndices(int, VALUE*, long unsigned int)': calvarygdk_wrap.cxx:4060: warning: converting to non-pointer type `int' from NULL calvarygdk_wrap.cxx:4065: error: invalid conversion from `int' to `void*' calvarygdk_wrap.cxx:4070: error: invalid conversion from `int' to `void*' make: *** [calvarygdk_wrap.o] Error 1 Solution: When I looked at the generated code at line with the error I saw an invalid pointer conversion. In the .i file I was freeing the object as and int instead of a int*: =============.i file============== %typemap(freearg) int * { free((int*) $1); /* This was (int) $1 before } ================================== Error: ../irr/GraphicBoundingBoxIrr.h:12: Error: Nothing known about namespace 'irr' ../irr/GraphicBoundingBoxIrr.h:13: Error: Nothing known about namespace 'irr::scene' ../irr/GraphicBoundingBoxIrr.h:14: Error: Nothing known about namespace 'irr::video' ../irr/GraphicIrr.h:13: Error: Nothing known about namespace 'irr' ../irr/GraphicIrr.h:14: Error: Nothing known about namespace 'irr::scene' ../irr/GraphicIrr.h:15: Error: Nothing known about namespace 'irr::video' ../irr/AnimatedGraphicIrr.h:13: Error: Nothing known about namespace 'irr' ../irr/AnimatedGraphicIrr.h:14: Error: Nothing known about namespace 'irr::scene' ../irr/AnimatedGraphicIrr.h:15: Error: Nothing known about namespace 'irr::video' ../irr/GraphicsEngineIrr.h:11: Error: Nothing known about namespace 'irr' ../irr/GraphicsEngineIrr.h:12: Error: Nothing known about namespace 'irr::scene' ../irr/GraphicsEngineIrr.h:13: Error: Nothing known about namespace 'irr::video' ../irr/GraphicsFactoryIrr.h:14: Error: Nothing known about namespace 'irr' ../irr/GraphicsFactoryIrr.h:15: Error: Nothing known about namespace 'irr::scene' ../irr/GraphicsFactoryIrr.h:16: Error: Nothing known about namespace 'irr::video' ../irr/UtilIrr.h:11: Error: Nothing known about namespace 'irr' ../irr/UtilIrr.h:12: Error: Nothing known about namespace 'irr::scene' ../irr/UtilIrr.h:13: Error: Nothing known about namespace 'irr::core' ../irr/ResourceIrr.h:11: Error: Nothing known about namespace 'irr' ../irr/ResourceIrr.h:12: Error: Nothing known about namespace 'irr::scene' ../irr/ResourceIrr.h:13: Error: Nothing known about namespace 'irr::video' ../irr/GraphicsEngineIrr.h:19: Warning(401): Nothing known about base class 'IEventReceiver'. Ignored. Solution: I included in the .i file the Irrlicht.h file that was being included in every file. ========================================================================================= test.rb:14:in `initialize': in method 'initialize', argument 1 of type 'PhyFactoryOde *' (ObjectPreviouslyDeleted) from test.rb:14:in `run_game' from test.rb:55 Solution: avoided the name initialized for the phy factory. Also for the phy engine, which was being started by the factory inside the initialize method.

Comments

Popular posts from this blog

Mail labels and letter templates for jasperreports

The following are free (MIT license) mailing labels and letter templates for jasperreports that you can download and use in jasperserver and/or ireport: Update 3/15/2011 : I moved the Mail templates zip file here . Please consider making a small donation if the templates are of help to you, Thank you! If you need more information on how to use those templates please leave a comment in the blog.

How to create online multiplayer HTML5 games in Contruct2

  Construct2 can use websockets to send and receive messages between games. By using socket-io , we can use a Node.js script as the server and my modification to the socket-io plugin for Construct2 to allow the games to synchronize data between them in real-time. There are two parts to this design: the Node.js server and the Construct2 clients (the games playing). The main part of building an online multiplayer HTML5 game is to plan: how the clients will communicate how often and what to communicate how much of the logic will go into the server and how much to the client. In my sample game, I chose to have each client own a player and have the server just relay messages: Use string messages in the form TypeOfMessage, Parameter1, Paremeter2, Parater3, etc to communicate. Have the clients send their player position about 16 times a second. Whenever their player shoots, the client needs to send a message immediately. Almost all of the game logic will...

Send Email from C# using Outlook's COM late binding

The following sample code shows how to send emails from Outlook and Exchange using C#. This code works with any version of Outlook because it uses Late Binding to automate Outlook. Parts of the code where taken from other websites. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Reflection; using System.Threading; namespace LateBindingTest { class OutlookEmailerLateBinding { private object oApp; private object oNameSpace; private object oOutboxFolder; public OutlookEmailerLateBinding() { Type outlook_app_type; object[] parameter = new object[1]; //Get the excel object outlook_app_type = Type.GetTypeFromProgID("Outlook.Application"); //Create instance of excel oApp = Activator.CreateInstance(outlook_app_type); //Set the parameter which u want to set parameter[0] = "MAPI...