danomatika / swig-openframeworks

a SWIG interface for openFrameworks with included Makefile, submodule this in your language wrapper addons
Other
39 stars 11 forks source link

order of defines in openframeworks.py #19

Closed sphaero closed 3 years ago

sphaero commented 5 years ago

When I import openframeworks I get errors which imply somethings are not yet defined but already referenced:

[ error ] error importing openframeworks
Traceback (most recent call last):
  File "./openframeworks.py", line 134, in <module>
    ofPoint = ofVec3f
NameError: name 'ofVec3f' is not defined

Commenting that line:

Traceback (most recent call last):
  File "./openframeworks.py", line 137, in <module>
    ofLog = log
NameError: name 'log' is not defined

commenting that line:

Traceback (most recent call last):
  File "./openframeworks.py", line 1532, in <module>
    def ofMesh_plane(width, height, columns=2, rows=2, mode=OF_PRIMITIVE_TRIANGLE_STRIP):
NameError: name 'OF_PRIMITIVE_TRIANGLE_STRIP' is not defined

OF_PRIMITIVE_TRIANGLE_STRIP gets defined at line 3346

danomatika commented 5 years ago

It could be an include order. In general, I've had to either include dummy structs so SWIG has something before doing the %include later on or simply %including certain headers earlier. You can see the early stuff listed in main.i. You could try commenting out the %ignore ofDefaultVec2; lines to see if that helps.

One useful approach to deep stuff like this is to examine the generated C code and do some manual experimentation there to get it to build, then see if you can get SWIG to generate similar code.

I use swig-openframeworks to generate the Lua bindings for ofxLua, so I'm not very much help outside of general SWIG usage. The best person to loop in would be @chaosct who worked on ofxPython some years ago.

danomatika commented 5 years ago

Also, try make openFrameworks-symbols or make glm-symbols to generate a text file with the wrapped classes & symbol names. This is helpful in finding out if SWIG is finding everything or not.

sphaero commented 5 years ago

Thanks for all suggestions. I'm quite new to swig so bare with me. I'll see what I can find out where I find time. For now; the make openFrameworks-symbols errors:

make openFrameworks-symbols
swig -c++ -lua -O -small -debug-lsymbols  -I../../openframeworks/libs/openFrameworks -DMODULE_NAME=of -DOF_SWIG_RENAME openFrameworks.i > of_lua_symbols.txt
../../openframeworks/libs/openFrameworks/utils/ofXml.h:148: Warning 509: Overloaded method ofXml::removeAttribute(ofXml::Attribute &&) effectively ignored,
../../openframeworks/libs/openFrameworks/utils/ofXml.h:147: Warning 509: as it is shadowed by ofXml::removeAttribute(ofXml::Attribute const &).
rm -f *.cxx
if [ lua == "python" ]; then rm -f *.py; fi
/bin/sh: 1: [: lua: unexpected operator

Not sure what platform you're targetting but on my the commands are issued by /bin/sh which doesn't support '=='. For me replacing them with '=' fixes it.

sphaero commented 5 years ago

just opened #20 which fixes it for me

danomatika commented 3 years ago

Fixed via #20.