Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile Error - Subdirectories not handled #4

Open
zauberparacelsus opened this issue Aug 8, 2016 · 8 comments
Open

Compile Error - Subdirectories not handled #4

zauberparacelsus opened this issue Aug 8, 2016 · 8 comments

Comments

@zauberparacelsus
Copy link

I attempted to use P3DModuleBuilder with a C++ library that implements the Cubical Marching Squares algorithm, and ran into a compiler error:

Process error:

  *** Error in ./cubical-marching-squares/include/vec3.h near line 31, column
  16:

  syntax error, unexpected KW_STATIC

  Error parsing file: './cubical-marching-squares/include/cell.h'

I'll note that the CMS library compiles normally on its own. Would it be possible to 'trick' P3DModuleBuilder by copying over the compiled libCMS.a file?

The library in question is at: https://bitbucket.org/GRassovsky/cubical-marching-squares

@rdb
Copy link
Collaborator

rdb commented Aug 8, 2016

This is a bug in interrogate. I'll look into it, but in the meantime, you can edit the vec3.h file referenced in the error message and change "const static" to "static const" on line 31.

You can also put #ifndef CPPPARSER around the includes to the CMS library, which might work as well.

@zauberparacelsus
Copy link
Author

Thanks. That got me past the configure phase, but then I got a fatal error about a file missing. Apparently, the error was due to this library having the header files stored in a separate directory.

So, I did a make clean (IE: deleted the build folder) and then moved the header files into the same directory as the source files. It got a tiny bit further, but now it is complaining about another file that doesn't exist, despite it existing:

[  5%] Building CXX object CMakeFiles/CMS.dir/source/interrogate_module.cpp.o
[ 10%] Building CXX object CMakeFiles/CMS.dir/source/cubical-marching-squares/src/cell.cpp.o
[ 15%] Building CXX object CMakeFiles/CMS.dir/source/interrogate_wrapper.cpp.o
[ 21%] Building CXX object CMakeFiles/CMS.dir/source/cubical-marching-squares/src/vec3.cpp.o
[ 26%] Building CXX object CMakeFiles/CMS.dir/source/config_module.cpp.o
[ 31%] Building CXX object CMakeFiles/CMS.dir/source/cubical-marching-squares/src/address.cpp.o
[ 36%] Building CXX object CMakeFiles/CMS.dir/source/cubical-marching-squares/src/octree.cpp.o
/home/zauber/Paracosm/pyParacosm/cpp/P3DModuleBuilder/source/interrogate_wrapper.cpp:38:21: fatal error: address.h: No such file or directory
compilation terminated.
CMakeFiles/CMS.dir/build.make:62: recipe for target 'CMakeFiles/CMS.dir/source/interrogate_wrapper.cpp.o' failed
make[2]: *** [CMakeFiles/CMS.dir/source/interrogate_wrapper.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/CMS.dir/all' failed
make[1]: *** [CMakeFiles/CMS.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

@zauberparacelsus
Copy link
Author

zauberparacelsus commented Aug 8, 2016

I managed to get it to build. The source files were all in a subfolder, like so:

P3DModuleBuilder
  \_source
    \_cubical-marching-squares
      \_src

Moving the contents of the src directory two levels up to the source directory fixed the issue.

And that probably exposes another issue in Interrogate: that it has trouble picking up on headers stored in subdirectories.

@rdb
Copy link
Collaborator

rdb commented Aug 8, 2016

Hmm, seems more like a missing argument to reference the directory on the interrogate command-line. To be honest I'm not really familiar with how the modulebuilder handles additional include directories.

For what it's worth, I checked in a fix for the interrogate parser issue to panda3d/panda3d@db97747 .

@zauberparacelsus zauberparacelsus changed the title Compile Error Compile Error - Subdirectories not handled Aug 9, 2016
@zauberparacelsus
Copy link
Author

Okay, it compiled, but when I actually tried using it, I found that it did not include anything from the library's namespace, despite the correct files having shown up in the compile output.

If I run dir(CMS), I just see the following:

['Dtool_PyNativeInterface', '__doc__', '__file__', '__name__', '__package__']

Trying to run "from CMS import ..." on any of the known classes, such as cell, octree, or array3d just returns an ImportError.

@tobspr
Copy link
Owner

tobspr commented Aug 9, 2016

Right now the CMake script only adds the panda include directory to the include path, and the root directory of the source/ folder. One would have to modify scripts/interrogate.py to recursively collect all headers (I think modifying find_sources(base_dir) should probably already be enough).

The classes are not exposed because the PUBLISHED: keyword is not used. You should replace the public:keyword with PUBLISHED: in every class you want to expose.

@rdb
Copy link
Collaborator

rdb commented Aug 9, 2016

If you want to expose the classes without modifying the headers, you can run interrogate in -promiscuous mode, or you can create a .N file containing instructions like "forcetype SomeClass". See the .N files in the Panda source code base for examples.

@zauberparacelsus
Copy link
Author

I tried changing the public: keyword to published:, but it resulted in compile errors. I also tried tweaking the interrogate wrapper script to include the promiscuous flag. It compiled, but I get an import error now:

>>> from panda3d.core import *
>>> import CMS
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: ./CMS.so: undefined symbol: Dtool_NotifyCategoryProxy_NotifyCategoryGetCategory_mymodule

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants