Issues on importing C++

BlitzMax Forums/BlitzMax Programming/Issues on importing C++

beanage(Posted 2009) [#1]
Hey,

I'm just about importing ODE into my project.
Already considered using jvODE, but it wont work for me due to dll platform dependency.

So straight forward, just to test it, i added
 Import "ode.cpp" 
.
Yes, I didn't actually tell it to use something from that file.

So of course i got stuck right away..
Build Error: failed to compile K:/Ode/ode.cpp

This thread cleared up the reasons:
- Propable Presence of C++-Strings instead of char*
- Need to use extern "C"{} due to identifier mangling in c++.

My questions:
#0 Are there more reasons?
#1 Is there already a working bmax wrapper.bmx for ODE? If so, just post a link and forget about the following 3 questions ;). If not, of course mine will become a free module!.
#2 Will I only need to extern"C"{}-wrap the functions in ode.cpp i want to extern..endextern in bmax? Then why could this be a problem in my test, as i didnt extern..endextern anything in bmax?
#3 A quick search through the ode.cpp tells me none of the functions i wanna use utilizes the cpp string type. Would i have the the string problem too, if <string unused_hidden_ode_helper_function( string param )> uilized it? (no idea whether it does).
#4 Mmmh.. naive bmax user's/ c++ newbie's idea:
Create a c++ file "MyOdeWrapper.cpp" where i just have some
#include "ode.cpp" //does this need to be "ode.h"?
extern "C"{
  Required function pointers..
}

Would this work?

I know thats a wall of questions :/
Any answers welcome ..


Jesse(Posted 2009) [#2]
http://jv-ode.devcode.co.uk/


joncom2000(Posted 2009) [#3]
Jesse he already said "Already considered using jvODE, but it wont work for me due to dll platform dependency."

So linking to the site dont help him much does it ;)


Jesse(Posted 2009) [#4]
ups!


beanage(Posted 2009) [#5]
No ideas? I'm constantly reading about a module mark once created, but where to get it? I really need this :/


Brucey(Posted 2009) [#6]
No ideas?

Plenty actually :-p

Do you intend to build the library straight into your app, or via a module?
I would choose the latter, as there are more/better compile options available to you (why? well, that's probably my fault for focussing bmk enhancements on module building... oh well ;-)

You'll need to import the headers, for starters.
I find building a C-style interface is easier than integrating a Type/C++ class style, which some might go for (well, there have been posts about it, so it's not unlikely).

Your best course of action might be to look at pre-existing code and get ideas from those. There are probably a few wrapped libraries about that you can use as a reference :-)


markcw(Posted 2009) [#7]
My idea is this: get Brucey to do it for you. :D


beanage(Posted 2009) [#8]
Oh, haha, thank you, finally a helpful answer brucey ;)

Seriously!, i didnt even consider importing the "ode.h" could be easier than the "ode.cpp" file (admitting i wasnt even aware of its presence, the c++ newb speaking for himself, lol^^) ..

So a quick search thruogh the ODE SDK and i found it!!
A quick scroll through the headers and I found all necessary functions perfectly included into extern "C" {} blocks!! Thats what i wanted!

Its 12 pm here in ger, so i'm not gonna make a quick test build for now, but I assume its just as easy as
Import "Ode/ode.h"
Extern "C"
  Function dODEFunctionXYZ:Int( x:Int,y:Int,z:Int )
End Extern
, isnt it? Thats gonna be my challenge for tomorrow :)

Hmm.. how can i pass those #ifdef pragma values to obtain my desired build?