[SOLVED] Issue with Linking Panda classes with Interrogate

Excellent,it now works ! Many thanks rdb and Tobias.

So I decided to sum up some complement of information to Tobias’ tutorial (originally for Panda 1.8.1 / Visual Studio 2008 – see [Guide] Interrogate in 8 steps) for the following configuration:

  • Panda x64 1.9.0/1.9.1 (official build)
  • Visual studio 2015 (VS)
  • Windows 7/x64

Warning: as said by rdb in this thread, latest versions of Panda SDK have a more robust Interrogate interface. So this short memo is only intended for those who want to use Interrogate with the aforementioned configuration.

EDIT : Tobias made a tool that performs Step 1 / Step 3 of this memo in a complete automated way - see
https://discourse.panda3d.org/viewtopic.php?t=18420
However, should you run 1.9.0 or 1.9.1,you still need to perform Step 2 (generation of core.lib- see below) and Step 3.A in order to make it work.

  1. Step 1: Perform first steps from Tobias’ tutorial- Interrogate without integration with P3D classes
    Follow the steps 1 to 7. Make sure you obtain the appropriate ‘Hello World’: if not, go back to the previous steps.

[i]Note #1
Interrogate will work only if the solution/project have been correctly setup in the VS 2015 context. This is described in the following manual page: panda3d.org/manual/index.ph … nguage=cxx
As a reminder, the key points to check:

  • Solution in Release version and x64
  • “Platform Toolset” in the “General” tab to “Visual Studio 2015 - Windows XP (v140_xp)”
  • NDEBUG to be removed from preprocessor
  • Libraries to link:

libp3framework.lib
libpanda.lib
libpandaexpress.lib
libp3dtool.lib
libp3dtoolconfig.lib
libp3direct.lib
[/i]

[i]Note #2
Interrogate seems to be sensitive (at least for the 1.9.0 version) so you’ll need to:

  • Remove the #pragma once directives that VS will have created automatically in stdafx.h – see panda3d.org/forums/viewtopic … 12&t=16162
  • Comment out completely dllmain.cpp
  • Check the generated code (the .cxx), at least to control that the methods you want to bind with Python have been taken into account
  • Put the ‘-v’ flag (verbose mode) on the interrogate command line at step 3 (should you have any need to see what happens).
    [/i]
  1. Step 2: Generate core.lib – specific to 1.9.0 / 1.9.1

If you decided to continue and perform Tobias’ tutorial step 8 (Integrate with Panda3D), you would have found out that there is a systematic error with the linker, since no Panda classes can be found. In 1.9.0, the specific library ‘core.lib’ should be linked with your program in order the code to be successfully compiled.

Unfortunately, this lib is not ‘directly’ included in 1.9.0: there is however a workaround. It consists in using the ‘core.pyd’ (located in the “panda3d” directory of your P3D install directory) and transform it into a readable lib for the VS linker.

Rdb suggested this tutorial which perfectly works – see wiki.videolan.org/GenerateLibFromDll.

Steps to perform:

2.A. Copy the ‘core.pyd’ to the directory where you want to perform the steps of the wiki.videolan tutorial, use the Visual Studio Tools and change (cd) to this directory

2.B. Follow the different steps described in the tutorial with 2 important modifications to do in the step ‘Generate the .lib’

  • Set ‘/machine:x64’ instead of ‘/machine:x86’
    -Add the ‘/name:core.pyd’ to the command line. If not added, it will be not possible to import your module into the python code

You should now have a file ‘core.lib’ that is ready to be linked with your Interrogate code.

[i]Note #1
During the step ‘Extract Symbols’, if you choose the manual edit of the core.def file, you only need to:

  • Add EXPORTS (capital letter AND plural!) at the first line
  • Remove all columns except the last one (Excel can be used to do it quickly)

The beginning of the ‘core.def’ file should look like:
EXPORTS
??4?$Extension@V?$ConstPointerToArray@E@@@@QEAAAEAV0@AEBV0@@Z
??4?$Extension@V?$ConstPointerToArray@G@@@@QEAAAEAV0@AEBV0@@Z
??4?$Extension@V?$ConstPointerToArray@H@@@@QEAAAEAV0@AEBV0@@Z
??4?$Extension@V?$ConstPointerToArray@M@@@@QEAAAEAV0@AEBV0@@Z
??4?$Extension@V?$ConstPointerToArray@N@@@@QEAAAEAV0@AEBV0@@Z
??4?$Extension@V?$ConstPointerToArray@VLMatrix3d@@@@@@QEAAAEAV0@AEBV0@@Z
??4?$Extension@V?$ConstPointerToArray@VLMatrix3f@@@@@@QEAAAEAV0@AEBV0@@Z

[/i]
3. Step 3: Move core.lib and compile Panda classes – specific to 1.9.0 / 1.9.1

Perform the following steps:

3.A. Put the “core.lib” into the ‘lib’ directory of your P3D install

3.B. Add ‘core.lib’ in the VS linker libraries. You should now have:
[list]
libp3framework.lib
libpanda.lib
libpandaexpress.lib
libp3dtool.lib
libp3dtoolconfig.lib
libp3direct.lib
core.lib

3.C. Perform Step 8 of Tobias’s tutorial and ensure the output is correct.[/list:u]

Done: start developing more complex code!