Undefined reference to vtable SFML Android - c++

I am compiling a program that uses SFML on android. It compiles normally when I compile it with g++. When I run ndk-build in the android project directory I get the following error:
/home/engineer/Desktop/android_ndk/android-ndk-r11c/toolchains/arm- linux-androideabi-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld: the vtable symbol may be undefined because the class is missing its key function (see go/missingkeymethod)
/home/engineer/Desktop/android/jni/SandJar.hpp:16: error: undefined reference to 'vtable for SandJar'
I have an abstract class jar and 2 class sandyJar and sandjar that both inherit it. However, I don't understand why it compiles for g++ but doesnt for the ndk-build command.
Here are some of the source files stripped down(it compiles from main):
Main.cpp:
int main(int argc, char *argv[])
{
sf::RenderWindow window(sf::VideoMode::getDesktopMode(), "");
int WIDTH = window.getSize().x;
int HEIGHT = window.getSize().y;
vector<Jar*> jars;
SandJar SJAR(5,5,5,WIDTH, HEIGHT);
CandyJar CJAR(5,5,5,WIDTH, HEIGHT);
CJAR.add();
CJAR.move(120, 0);
jars.push_back(&CJAR);
jars.push_back(&SJAR);
etc.
}
Jar.hpp
class Jar
{
public:
virtual void add() = 0;
virtual void draw(sf::RenderWindow&) = 0;
virtual void update() = 0;
virtual void move(int,int) = 0;
virtual void setScale(float) = 0;
virtual void incAnim() = 0;
virtual void decAnim() = 0;
};
SandJar.hpp
class SandJar : public Jar
{
public:
//initializer
SandJar(const int, const int, const int, const int, const int);
SandJar(const int);
//function for adding candy
void add();
void update();
void draw(sf::RenderWindow&);
void incAnim();
void decAnim();
void move(int, int);
void setScale(float);
private:
//vars
};
SandJar.cpp
SandJar::SandJar(int Capacity){
}
SandJar::SandJar(int Width, int Height, int Capacity, int WindowW, int WindowH){
}
void SandJar::init() {
}
void SandJar::incAnim() {
}
void SandJar::decAnim() {
}
void SandJar::move(int x, int y)
{
}
void SandJar::setScale(float scl)
{
}
void SandJar::update() {
}
void SandJar::add() {
}
void SandJar::draw(sf::RenderWindow& window) {
}

As it turns out there was no problem with any of the code. The problem was the Android.mk file used for the project. I appended the hpp and cpp files to LOCAL_SRC_FILES and it built correctly. It says not to include "includes" in LOCAL_SRC_FILES but once added it compiled correctly. There may be a better fix.

Related

Undefined reference to Class even though I compiled all cpp files

first of all I am kind of new to coding, so it might be that I just missed something really obvious. Still I would appreciate any help.
I created some header and some code files in one directory, namely "main.cpp","elements.cpp","queue.cpp", "elements.hpp" and "queue.hpp". In "main.cpp" I included both .hpp files.
Then I compiled: g++ main.cpp elements.cpp queue.cppto get an executable file with all three .cpp files linked.
Still I get the following error message /usr/bin/ld: /tmp/ccUjQcqj.o: in function main': main.cpp:(.text+0x33): undefined reference to Queue::Queue()'.
Queue is a class declared in "queue.hpp".
Here is the code for "queue.hpp":
#include "elements.hpp"
class Queue{
Element Q[10];
int start;
int count;
void print(bool dir,int count);
public:
Queue(); //Standard Konstruktor Deklaration
void push(Element e);
void pop();
Element& top();
void print(bool dir=true);
int size();
};
Here is the code for "queue.cpp":
#include "elements.hpp"
#include <iostream>
class Queue{
Element Q[10];
int start;
int count;
void print(bool dir,int count){
if(count>0 && dir==0){
Q[count-1].print();
print(dir,count-1);
}
if(count>0 && dir==1){
print(dir,count-1);
Q[count-1].print();
}
}
public:
Queue():start(0),count(0){}
void push(Element e){
if (count==10){
for(int i=0;i<9;i++){
Q[i]=Q[i+1];
}
Q[9]=e;
}
else{Q[start+count]=e;
count++;
}}
void pop(){
for(int i=0;i<9;i++){
Q[i]=Q[i+1];
}
count--;
}
Element& top(){
return Q[0];
}
void print(bool dir=true){
print(dir,count);
}
int size(){
return count;
}
};
I do not understand why there is an undefined reference here, since I included "queue.hpp" in main and the constructor in "queue.cpp" is also not missing.
Thank you for your help!

Why is my c++ singleton not working on Clion?

I want to have a singleton in my project but some errors occur
this is my codes in three separate files.:
//---------------My main.cpp code
#include <iostream>
#include "Sports/BBVB.h"
int main() {
bbvb;
return 0;
}
// ---------------------------my BBVB.h code
#ifndef SAMAVAR_BBVB_H
#define SAMAVAR_BBVB_H
typedef struct VBResult{
int set1=-1;
int set2=-1;
int set3=-1;
int set4=-1;
int set5=-1;
}VBResult;
#include "Sport.h"
#include "../TournamentStuf/Tournament.h"
class BBVB: public Sport {
protected:
vector<Tournament<VBResult>> tours;
public:
static BBVB& getInstance(){
static BBVB b;
return b;
}
private:
BBVB(){}
public:
BBVB(BBVB const&)=delete;
void operator=(BBVB const&) = delete;
//-------------Setter------------
//------------Getter-------------
vector<Tournament<VBResult>> getTours() const;
Tournament<VBResult> getTourById(int id) const;
//----------Others---------------
void addTour(Tournament<VBResult> v);
};
BBVB &bbvb=BBVB::getInstance();
#endif //SAMAVAR_BBVB_H
//------------------my Store and restore code
#ifndef SAMAVAR_STOREANDRESTORE_H
#define SAMAVAR_STOREANDRESTORE_H
#include "../Sports/BBVB.h"
#include "../Sports/PingPong.h"
#include "../Sports/Wrestling.h"
void Start(BBVB &b);
void Update(const BBVB &b);
void Start(PingPong &p);
void Update(const PingPong &p);
void Start(Wrestling &w);
void Update(const Wrestling &w);
#endif //SAMAVAR_STOREANDRESTORE_H
I have a bbvb instance of BBVB but it says you have multiple definitions of it.
I'm new to Clion and I don't have enough information about somethings like cmake and I feel the problem is because of it.
I want to have something like cout and cin in iostream.so by including my BBVB I can access this object.
Clion shows error below:
CMakeFiles\Samavar.dir/objects.a(BBVB.cpp.obj):BBVB.cpp:(.bss+0x0): multiple definition of `bbvb'
CMakeFiles\Samavar.dir/objects.a(main.cpp.obj):main.cpp:(.bss+0x0): first defined here
CMakeFiles\Samavar.dir/objects.a(StoreAndRestore.cpp.obj):StoreAndRestore.cpp:(.bss+0x0): multiple definition of `bbvb'
CMakeFiles\Samavar.dir/objects.a(main.cpp.obj):Samavar-master/Sports/BBVB.h:24: first defined here
collect2.exe: error: ld returned 1 exit status

Compiler shows undefined structure error while declaring a class

Error message:
Link to full program
class AddressBook
{
private:
char firstname[20];
char lastname[20];
char no[15];
class adrs
{
public:
char postal[100];
char pincode[7];
friend void say();
friend void Add();
friend void Edit();
friend void View(int);
}address;
char dob[11];
char email[50];
public:
friend void say();
void sort(AddressBook []);
void NumberSort(AddressBook []);
void Add(void);
void Delete(AddressBook [], int pos);
void Edit();
void LinearSearch(AddressBook [], char a[]);
friend void ViewAll();
void View(int);
void FetchContact();
};
This is the declaration of a class for a contact-book program.
void sort(AddressBook []);
void NumberSort(AddressBook []);
void Delete(AddressBook [], int pos);
void LinearSearch(AddressBook [], char a[]);
These lines in the above declaration shows up as an error in TurboC++ compiler. Can anyone tell me why?
In C++ when an array is passed as an argument, its initial address is passed to formal parameter. With the help of this technique the code can be written as follows
void sort(AddressBook*);
void NumberSort(AddressBook*);
void Delete(AddressBook*, int pos);
void LinearSearch(AddressBook*, char a[]);
I have implemented the same thing for my problem and it just worked.
As you were not able to produce minimal example, I did it for you:
class AddressBook
{
void sort(AddressBook[]);
};
This declaration compiles fine on a modern compiler but not on Turbo C++.
You can call this a compiler bug.
There are two options:
you rethink your program and write it another way
you use a modern C++ compiler
Changing school would be another valuable option.

Arduino C++ file - class instantiation fails when setting a private member variable in the constructor

I'm using the Arduino IDE 1.0.5-r2 and trying to create a class with two member variables, _pinA and _pinB. When I call the constructor from my Arduino sketch, I get this error:
RotaryEncoderReader.cpp:6: error: request for member '_pinB' in 'this', which is of non-class type 'RotaryEncoderReader* const'
The constructor can be called from a regular C++ files compiled using GCC, and there are no errors. Am I missing something about how to use a class constructor with an Arduino?
Here is the class header:
#ifndef RotaryEncoderReader_h
#define RotaryEncoderReader_h
#include "Arduino.h"
class RotaryEncoderReader {
private:
int _pinA;
int _pinB;
volatile long encoderPos;
public:
RotaryEncoderReader( int newPinA, int newPinB );
void doEncoderA();
void doEncoderB();
long getPosition();
};
#endif
Here's the implementation:
#include "RotaryEncoderReader.h"
RotaryEncoderReader::RotaryEncoderReader( int newPinA, int newPinB )
: _pinA(newPinA),
_pinB(newPinB),
encoderPos(0)
{
}
void RotaryEncoderReader::doEncoderA()
{
//Irrelevant
}
void RotaryEncoderReader::doEncoderB()
{
//Irrelevant
}
long RotaryEncoderReader::getPosition()
{
return _pinA + _pinB;
}
And here's the Arduino sketch:
#include <RotaryEncoderReader.h>
int pinA = 2;
int pinB = 3;
RotaryEncoderReader reader(pinA, pinB);
void setup()
{
}
void loop()
{
}

C#.Net Calling a C++ DLL

I got a DLL(without the sourcecode) which exports like this:
?ReceiveCoreDataPtr##YAXPAX#Z
?xenoAddRigidBodyAngularImpulse##YAXHMMM#Z
?xenoAddRigidBodyForce##YAXHMMM#Z
?xenoAddRigidBodyForce##YAXHMMMMMM#Z
?xenoAddRigidBodyLinearImpulse##YAXHMMM#Z
?xenoAddRigidBodyPointImpulse##YAXHMMMMMM#Z
?xenoAddRigidBodyTorque##YAXHMMM#Z
?xenoCharacterControllerCrouch##YAXH#Z
?xenoCharacterControllerJump##YAXH#Z
?xenoCharacterDisable##YAXH#Z
?xenoCharacterEnable##YAXH#Z
?xenoDeleteRigidBody##YAXH#Z
?xenoEnd##YAXXZ
?xenoGetCameraFOV##YAKH#Z
?xenoGetCameraPointX##YAKH#Z
?xenoGetCameraPointY##YAKH#Z
?xenoGetCameraPointZ##YAKH#Z
?xenoGetCameraPositionX##YAKH#Z
?xenoGetCameraPositionY##YAKH#Z
?xenoGetCameraPositionZ##YAKH#Z
?xenoGetCharacterControllerHeadPosition##YAKH#Z
?xenoGetCharacterControllerPositionX##YAKH#Z
?xenoGetCharacterControllerPositionY##YAKH#Z
?xenoGetCharacterControllerPositionZ##YAKH#Z
?xenoGetCharacterControllerRotation##YAKH#Z
?xenoGetRigidBodyAllowedPenetrationDepth##YAKH#Z
?xenoGetRigidBodyAngularDamping##YAKH#Z
?xenoGetRigidBodyAngularVelocityX##YAKH#Z
?xenoGetRigidBodyAngularVelocityY##YAKH#Z
?xenoGetRigidBodyAngularVelocityZ##YAKH#Z
?xenoGetRigidBodyFriction##YAKH#Z
?xenoGetRigidBodyGravityFactor##YAKH#Z
?xenoGetRigidBodyLinearDamping##YAKH#Z
?xenoGetRigidBodyLinearVelocityX##YAKH#Z
?xenoGetRigidBodyLinearVelocityY##YAKH#Z
?xenoGetRigidBodyLinearVelocityZ##YAKH#Z
?xenoGetRigidBodyMass##YAKH#Z
?xenoGetRigidBodyMaxAngularVelocity##YAKH#Z
?xenoGetRigidBodyMaxLinearVelocity##YAKH#Z
?xenoGetRigidBodyPointVelocityX##YAKHMMM#Z
?xenoGetRigidBodyPointVelocityY##YAKHMMM#Z
?xenoGetRigidBodyPointVelocityZ##YAKHMMM#Z
?xenoGetRigidBodyRestitution##YAKH#Z
?xenoIsRigidBodyALadder##YAHH#Z
?xenoMakeCamera##YAXHH#Z
?xenoMakeCharacterController##YAXHMM#Z
?xenoMakeCharacterController##YAXHMMM#Z
?xenoMakeCharacterController##YAXHMMMM#Z
?xenoMakeCharacterController##YAXHMMMMM#Z
?xenoMakeCharacterController##YAXHMMMMMM#Z
?xenoMakeCharacterController##YAXHMMMMMMM#Z
?xenoMakeRigidBodyDynamicBox##YAXH#Z
?xenoMakeRigidBodyDynamicBox##YAXHM#Z
?xenoMakeRigidBodyDynamicCapsule##YAXH#Z
?xenoMakeRigidBodyDynamicCapsule##YAXHM#Z
?xenoMakeRigidBodyDynamicCylinder##YAXH#Z
?xenoMakeRigidBodyDynamicCylinder##YAXHM#Z
?xenoMakeRigidBodyDynamicSphere##YAXH#Z
?xenoMakeRigidBodyDynamicSphere##YAXHM#Z
?xenoMakeRigidBodyStaticBox##YAXH#Z
?xenoMakeRigidBodyStaticCapsule##YAXH#Z
?xenoMakeRigidBodyStaticCylinder##YAXH#Z
?xenoMakeRigidBodyStaticSphere##YAXH#Z
?xenoMakeRigidBodyStaticTriangleMesh##YAXH#Z
?xenoMakeVehicle##YAXHH#Z
?xenoMoveCharacterControllerBackward##YAXH#Z
?xenoMoveCharacterControllerForward##YAXH#Z
?xenoMoveCharacterControllerLeft##YAXH#Z
?xenoMoveCharacterControllerRight##YAXH#Z
?xenoSetCharacterControllerPosition##YAXHMMM#Z
?xenoSetCharacterControllerRotation##YAXHM#Z
?xenoSetGravity##YAXM#Z
?xenoSetGravity##YAXMMM#Z
?xenoSetRigidBodyAllowedPenetrationDepth##YAXHM#Z
?xenoSetRigidBodyAngularDamping##YAXHM#Z
?xenoSetRigidBodyAngularVelocity##YAXHMMM#Z
?xenoSetRigidBodyAsLadder##YAXHH#Z
?xenoSetRigidBodyFriction##YAXHM#Z
?xenoSetRigidBodyGravityFactor##YAXHM#Z
?xenoSetRigidBodyLinearDamping##YAXHM#Z
?xenoSetRigidBodyLinearVelocity##YAXHMMM#Z
?xenoSetRigidBodyMass##YAXHM#Z
?xenoSetRigidBodyMaxAngularVelocity##YAXHM#Z
?xenoSetRigidBodyMaxLinearVelocity##YAXHM#Z
?xenoSetRigidBodyPosition##YAXHMMM#Z
?xenoSetRigidBodyRestitution##YAXHM#Z
?xenoSetRigidBodyRotation##YAXHMMM#Z
?xenoSetTimeStep##YAXM#Z
?xenoStart##YAXH#Z
?xenoStart##YAXHM#Z
?xenoStart##YAXHMH#Z
?xenoStart##YAXXZ
?xenoUpdate##YAXXZ
?xenoVehicleAccelerate##YAXHM#Z
?xenoVehicleHandbrake##YAXH#Z
?xenoVehicleReverse##YAXH#Z
?xenoVehicleTurn##YAXHM#Z
When I try to use it in another C++ App like this
#include <windows.h>
class XenoPhysics
{
private:
typedef void (*FunctionFunc)(void);
typedef void (*FunctionFuncFloat)(float);
typedef void (*FunctionFuncInt)(int);
typedef void (*FunctionIntFloatFloatFloat)(int,float,float,float);
HMODULE libInstance;
public:
void LoadLib()
{
this->libInstance = LoadLibrary(L"F:\\xenophysics.dll");
}
void UnloadLib()
{
FreeLibrary(libInstance);
}
void xStart()
{
FunctionFunc curFunc;
curFunc = (FunctionFunc)GetProcAddress(this->libInstance, "?xenoStart##YAXXZ");
curFunc();
}
void xEnd()
{
FunctionFunc curFunc;
curFunc = (FunctionFunc)GetProcAddress(libInstance, "xenoEnd");
curFunc();
}
void xUpdate()
{
FunctionFunc curFunc;
curFunc = (FunctionFunc)GetProcAddress(libInstance, "xenoUpdate");
curFunc();
}
void xMakeRigidBodyStaticBox(int objid)
{
FunctionFuncInt curFunc;
curFunc = (FunctionFuncInt)GetProcAddress(libInstance, "xenoMakeRigidBodyStaticBox");
curFunc(objid);
}
void xMakeRigidBodyDynamicBox(int objid)
{
FunctionFuncInt curFunc;
curFunc = (FunctionFuncInt)GetProcAddress(libInstance, "xenoMakeRigidBodyDynamicBox");
curFunc(objid);
}
void xSetRigidBodyPosition(int objid, float x, float y, float z)
{
FunctionIntFloatFloatFloat curFunc;
curFunc = (FunctionIntFloatFloatFloat)GetProcAddress(libInstance, "xenoSetRigidBodyPosition");
curFunc(objid, x, y, z);
}
void xSetGravity(float grav)
{
FunctionFuncFloat curFunc;
curFunc = (FunctionFuncFloat)GetProcAddress(libInstance, "xenoSetGravity");
curFunc(grav);
}
};
This is the "wrapper"(or whatever you would call it) class.. To call the functions I'm doing
XenoPhysics * d = new XenoPhysics();
d->LoadLib();
d->xStart();
It then throws the following error at me(Note that it passes the LoadLib() without any errors)
Unhandled exception at 0x50261bc9 in Xeno Test.exe: 0xC0000005: Access violation reading location 0x00000064.
And yes; I've checked that the "curFunc" gets the address, not just a NULL pointer(atleast I think I've checked that)..
Anyone who can help out?
Edit: Forgot the C#.Net code, how stupid of me :3
Here is the C++ CLR DLL "wrapper" I tried to make:
#include <windows.h>
// The following ifdef block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the XENOWRAPPERWIN32_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see
// XENOWRAPPERWIN32_API functions as being imported from a DLL, whereas this DLL sees symbols
// defined with this macro as being exported.
#ifdef XENOWRAPPERWIN32_EXPORTS
#define XENOWRAPPERWIN32_API __declspec(dllexport)
#else
#define XENOWRAPPERWIN32_API __declspec(dllimport)
#endif
typedef void (*FunctionFunc)();
typedef void (*FunctionFuncFloat)(float);
typedef void (*FunctionFuncInt)(int);
typedef void (*FunctionIntFloatFloatFloat)(int,float,float,float);
// This class is exported from the xeno wrapper win32.dll
class XENOWRAPPERWIN32_API Cxenowrapperwin32 {
public:
Cxenowrapperwin32(void);
HINSTANCE libInstance;
// FunctionFunc curFunc;
// Library base functions
void LoadLib()
{
libInstance = LoadLibrary(L"F:\\xenophysics.dll");
}
void UnloadLib()
{
FreeLibrary(libInstance);
}
// Function calls to the xeno physics
void xStart()
{
FunctionFunc curFunc;
curFunc = (FunctionFunc)GetProcAddress(libInstance, "?xenoStart##YAXXZ");
curFunc();
}
void xEnd()
{
FunctionFunc curFunc;
curFunc = (FunctionFunc)GetProcAddress(libInstance, "?xenoEnd##YAXXZ");
curFunc();
}
void xUpdate()
{
FunctionFunc curFunc;
curFunc = (FunctionFunc)GetProcAddress(libInstance, "?xenoUpdate##YAXXZ");
curFunc();
}
void xMakeRigidBodyStaticBox(int objid)
{
FunctionFuncInt curFunc;
curFunc = (FunctionFuncInt)GetProcAddress(libInstance, "?xenoMakeRigidBodyStaticBox##YAXH#Z");
curFunc(objid);
}
void xMakeRigidBodyDynamicBox(int objid)
{
FunctionFuncInt curFunc;
curFunc = (FunctionFuncInt)GetProcAddress(libInstance, "?xenoMakeRigidBodyDynamicBox##YAXH#Z");
curFunc(objid);
}
void xSetRigidBodyPosition(int objid, float x, float y, float z)
{
FunctionIntFloatFloatFloat curFunc;
curFunc = (FunctionIntFloatFloatFloat)GetProcAddress(libInstance, "?xenoSetRigidBodyPosition##YAXHMMM#Z");
curFunc(objid, x, y, z);
}
void xSetGravity(float grav)
{
FunctionFuncFloat curFunc;
curFunc = (FunctionFuncFloat)GetProcAddress(libInstance, "?xenoSetGravity##YAXM#Z");
curFunc(grav);
}
};
extern XENOWRAPPERWIN32_API int nxenowrapperwin32;
XENOWRAPPERWIN32_API int fnxenowrapperwin32(void);
and here is how I use it in C#.Net
class xeno
{
[DllImport("C:\\Users\\hayer\\Documents\\Visual Studio 2008\\Projects\\xeno wrapper win32\\Debug\\xeno wrapper win32.dll", EntryPoint = "?LoadLib#Cxenowrapperwin32##QAEXXZ")]
public static extern void xLoadLib();
public void LoadLib()
{
xLoadLib();
}
[DllImport("C:\\Users\\hayer\\Documents\\Visual Studio 2008\\Projects\\xeno wrapper win32\\Debug\\xeno wrapper win32.dll", EntryPoint = "?UnloadLib#Cxenowrapperwin32##QAEXXZ")]
public static extern void xUnloadLib();
public void UnloadLib()
{
xUnloadLib();
}
[DllImport("C:\\Users\\hayer\\Documents\\Visual Studio 2008\\Projects\\xeno wrapper win32\\Debug\\xeno wrapper win32.dll", EntryPoint = "?xStart#Cxenowrapperwin32##QAEXXZ")]
public static extern void xStart();
public void Start()
{
xStart();
}
[DllImport("C:\\Users\\hayer\\Documents\\Visual Studio 2008\\Projects\\xeno wrapper win32\\Debug\\xeno wrapper win32.dll", EntryPoint = "?xUpdate#Cxenowrapperwin32##QAEXXZ")]
public static extern void xUpdate();
public void Update()
{
xUpdate();
}
[DllImport("C:\\Users\\hayer\\Documents\\Visual Studio 2008\\Projects\\xeno wrapper win32\\Debug\\xeno wrapper win32.dll", EntryPoint = "?xEnd#Cxenowrapperwin32##QAEXXZ")]
public static extern void xEnd();
public void End()
{
xEnd();
}
[DllImport("C:\\Users\\hayer\\Documents\\Visual Studio 2008\\Projects\\xeno wrapper win32\\Debug\\xeno wrapper win32.dll", EntryPoint = "?xMakeRigidBodyDynamicBox#Cxenowrapperwin32##QAEXH#Z")]
public static extern void xMakeRigidBodyDynamicBox(int objid);
public void MakeRigidBodyDynamicBox(int id)
{
xMakeRigidBodyDynamicBox(id);
}
[DllImport("C:\\Users\\hayer\\Documents\\Visual Studio 2008\\Projects\\xeno wrapper win32\\Debug\\xeno wrapper win32.dll", EntryPoint = "?xMakeRigidBodyStaticBox#Cxenowrapperwin32##QAEXH#Z")]
public static extern void xMakeRigidBodyStaticBox(int objid);
public void MakeRigidBodyStaticBox(int id)
{
xMakeRigidBodyStaticBox(id);
}
[DllImport("C:\\Users\\hayer\\Documents\\Visual Studio 2008\\Projects\\xeno wrapper win32\\Debug\\xeno wrapper win32.dll", EntryPoint = "?xSetGravity#Cxenowrapperwin32##QAEXM#Z")]
public static extern void xSetGravity(float grav);
public void SetGravity(float g)
{
xSetGravity(g);
}
[DllImport("C:\\Users\\hayer\\Documents\\Visual Studio 2008\\Projects\\xeno wrapper win32\\Debug\\xeno wrapper win32.dll", EntryPoint = "?xSetRigidBodyPosition#Cxenowrapperwin32##QAEXHMMM#Z")]
public static extern void xSetRigidBodyPosition(int obj, float x, float y, float z);
public void SetRigidBodyPosition(int id, float q, float w, float e)
{
xSetRigidBodyPosition(id, q, w, e);
}
}
And in the main C#.Net program I do
xeno tx = new xeno();
tx.Start();
tx.SetGravity(-1);
tx.MakeRigidBodyStaticBox(ground.Id);
tx.MakeRigidBodyDynamicBox(cube.Id);
tx.SetRigidBodyPosition(cube.Id, 0, 50, 0);
You must use proper calling conversion and parameters.