C++ external first steps help

freepoulite's icon

hello,

this morning i've test to make a C++ external with maxcpp ( in order to use Gecode later...)
http://code.google.com/p/maxcpp/

i've copy the maxcpp5.h in my xcode project (C++ command line tool)
i've include it to main.cpp

but when i try to compile the first exemple Xcode apparently don't find "ext.h"
that's weird because i've add MaxAPI.framework to my project...

if anyone has a hint for me it will be welcome :)

i'm not a high level developer so... be kind to me plz

Pierre

freepoulite's icon

Hello,

thank you a lot vanille

I'm os X.7.3 / Xcode 4.3.2 / Max 6.0.4

I can't compile it, i've tried some change but i'm stack on " #include " 'new' file not found...

:s

hard...

freepoulite's icon

ok i've fix the 'new' thing but there is still issues:

Undefined symbols for architecture i386:
"_common_symbols_init", referenced from:
MaxCpp5::makeMaxClass(char const*) in dummy++.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

anyone?

freepoulite's icon

I'm going mad with it...
Does anyone could send me a .xcodeproj of a simple C++ external? It would be really nice :)
I think it will be the best solution...

Pierre

freepoulite's icon

thank you vanille, i will look at commonsyms.c

freepoulite's icon

great explainations , i think it will help me
I use maxcpp with max 6 SDK , is it possible or am I suppose to use it with max 5 SDK?

Pierre

freepoulite's icon

i was finaly able to compile it, i've made a really stupid mistake (that i will keep secret) but now it works :)

just a little question:

is it possible to add methods that don't need selector?
example.mxo "doesn't understand" int or float without selector

thank you a lot for your time vanille, you are the only one who help me, i really appreciate
I have work on C external yesterday and lot of things are more clear now ( i've reread the begining of the SDK :) .... )

I really need to use Gecode that's why i'm going C++ now, i've start C only 2 weeks ago and even if i'm working hard it takes time to become "natural" and it takes even more time with C++ that's looks harder than C!!! so excuse the noobish questions plz...

have a good day

fedfed12's icon

For int and float register_method, I posted an answer here :
https://cycling74.com/forums/graham-wakefield-maxcpp-register_method-issues

I also have an open question here, https://cycling74.com/forums/jdataview-getcellvalue

Venetian's icon

you can make C++ external a different way:

1. change :
if (x = (t_simplemax *)object_alloc((t_class *) simplemax_class)) {
//add in pointer to t_class for c plus plus - only line changed!

this is in the new declaration at the bottom of the file. So you are forcing simplemax_class to be a t_class pointer. Somehow this allows you to use C++ now instead of C in your code.

2. change: simplemax.c to simplemax.cpp

3. compile!

my Xcode project is downloadable at:

www.eecs.qmul.ac.uk/~andrewr/software/simplecplusplus.zip

I've done a few things in C++ - using classes etc and never had any problems. Thanks Jeremy Bernstein for the tip.

freepoulite's icon

great,I will try that!

thank you a lot

Pierre

avperrotta's icon

Hi all,

I think I'm having the same trouble as FREEPOULITE,

I'm in OSX 10.9, Xcode 5.0.2, maxcpp6.h

I get this compile error:
Undefined symbols for architecture x86_64:
"_common_symbols_init", referenced from:
MaxCpp6::makeMaxClass(char const*) in maxcpp-test.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

anyone can help ?

thanks !

Venetian's icon

hope it's okay to reply here, but if you ever get something like:

parse error, unknown type class

it's because there's a mix and match of
myexternalobject.c

and .cpp code being added

hopefully the (t_class*) cast idea above works out for anyone doing c++ externals. you could of course use faust to do this