Undefined reference to `BitMask<unsigned int, 32>::bit(int)'

I installed Panda SDK, moved lib and include to p3d/lib and p3d/include, and wrote some CMake

cmake_minimum_required(VERSION 3.25)
project(untitled)

set(CMAKE_CXX_STANDARD 20)

include_directories(p3d/include)
link_directories(p3d/lib)

set(PANDA3D_LIB -lp3framework -lpanda -lpandaexpress -lp3dtoolconfig -lp3dtool -lp3pystub -lp3direct)

add_executable(untitled main.cpp printer.cpp printer.h)

target_link_libraries(untitled ${PANDA3D_LIB})

After compilation compiler returns me this

F:\Clion\CLion 2023.1.3\bin\mingw\bin/ld.exe: CMakeFiles/untitled.dir/main.cpp.obj:C:/Users/IonE/CLionProjects/untitled/main.cpp:35: undefined reference to `PandaFramework::PandaFramework()'
F:\Clion\CLion 2023.1.3\bin\mingw\bin/ld.exe: CMakeFiles/untitled.dir/main.cpp.obj: in function `main':
C:/Users/IonE/CLionProjects/untitled/main.cpp:37: undefined reference to `PandaFramework::open_framework()'
F:\Clion\CLion 2023.1.3\bin\mingw\bin/ld.exe: C:/Users/IonE/CLionProjects/untitled/main.cpp:41: undefined reference to `PandaFramework::open_window()'
F:\Clion\CLion 2023.1.3\bin\mingw\bin/ld.exe: C:/Users/IonE/CLionProjects/untitled/main.cpp:43: undefined reference to `PandaFramework::close_framework()'
F:\Clion\CLion 2023.1.3\bin\mingw\bin/ld.exe: C:/Users/IonE/CLionProjects/untitled/main.cpp:46: undefined reference to `PandaFramework::~PandaFramework()'
F:\Clion\CLion 2023.1.3\bin\mingw\bin/ld.exe: C:/Users/IonE/CLionProjects/untitled/main.cpp:46: undefined reference to `PandaFramework::~PandaFramework()'
F:\Clion\CLion 2023.1.3\bin\mingw\bin/ld.exe: CMakeFiles/untitled.dir/main.cpp.obj:C:/Users/IonE/CLionProjects/untitled/p3d/include/collideMask.h:41: undefined reference to `BitMask<unsigned int, 32>::lower_on(int)'
F:\Clion\CLion 2023.1.3\bin\mingw\bin/ld.exe: CMakeFiles/untitled.dir/main.cpp.obj: in function `__static_initialization_and_destruction_0':
C:/Users/IonE/CLionProjects/untitled/p3d/include/collideMask.h:47: undefined reference to `BitMask<unsigned int, 32>::bit(int)'
F:\Clion\CLion 2023.1.3\bin\mingw\bin/ld.exe: CMakeFiles/untitled.dir/main.cpp.obj:main.cpp:(.rdata$.refptr.panda_version_1_10[.refptr.panda_version_1_10]+0x0): undefined reference to `panda_version_1_10'

What’s wrong??

Panda3D does not use the mingw compiler, on Windows only the compiler from Microsoft can be used.

I’m getting only more errors when switching on vs compiler

C:\Users\IonE\CLionProjects\untitled1\p3d\include\Eigen\src/Core/Functors.h(973): error C2039: "binder2nd": not a member of "std".
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include\functional(31): note: see "std" declaration
C:\Users\IonE\CLionProjects\untitled1\p3d\include\Eigen\src/Core/Functors.h(973): error C2065: binder2nd: undeclared identifier
C:\Users\IonE\CLionProjects\untitled1\p3d\include\Eigen\src/Core/Functors.h(973): error C2974: Eigen::internal::functor_traits: invalid template argument for 'T', type required
C:\Users\IonE\CLionProjects\untitled1\p3d\include\Eigen\src/Core/util/XprHelper.h(90): note: see declaration "Eigen::internal::functor_traits"
C:\Users\IonE\CLionProjects\untitled1\p3d\include\Eigen\src/Core/Functors.h(973): error C2988: Unrecognized template declaration or definition
C:\Users\IonE\CLionProjects\untitled1\p3d\include\Eigen\src/Core/Functors.h(973): error C2143: syntax error: missing ";" before ">"
C:\Users\IonE\CLionProjects\untitled1\p3d\include\Eigen\src/Core/Functors.h(973): error C2059: syntax error: >
C:\Users\IonE\CLionProjects\untitled1\p3d\include\Eigen\src/Core/Functors.h(974): error C2143: syntax error: missing ";" before "{"
C:\Users\IonE\CLionProjects\untitled1\p3d\include\Eigen\src/Core/Functors.h(974): error C2447: {: missing function title (probably using a formal old type list)
C:\Users\IonE\CLionProjects\untitled1\p3d\include\Eigen\src/Core/Functors.h(977): error C2039: "binder1st": not a member of "std".
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include\functional(31): note: see "std" declaration
C:\Users\IonE\CLionProjects\untitled1\p3d\include\Eigen\src/Core/Functors.h(977): error C2065: binder1st: undeclared identifier
C:\Users\IonE\CLionProjects\untitled1\p3d\include\Eigen\src/Core/Functors.h(977): error C2974: Eigen::internal::functor_traits: invalid template argument for 'T', type required
C:\Users\IonE\CLionProjects\untitled1\p3d\include\Eigen\src/Core/util/XprHelper.h(90): note: see declaration "Eigen::internal::functor_traits"
C:\Users\IonE\CLionProjects\untitled1\p3d\include\Eigen\src/Core/Functors.h(977): error C2988: unrecognized template declaration or definition
C:\Users\IonE\CLionProjects\untitled1\p3d\include\Eigen\src/Core/Functors.h(977): error C2143: syntax error: missing ";" before ">"
C:\Users\IonE\CLionProjects\untitled1\p3d\include\Eigen\src/Core/Functors.h(977): error C2059: syntax error: >
C:\Users\IonE\CLionProjects\untitled1\p3d\include\Eigen\src/Core/Functors.h(978): error C2143: syntax error: missing ";" before "{"
C:\Users\IonE\CLionProjects\untitled1\p3d\include\Eigen\src/Core/Functors.h(978): error C2447: {: missing function title (probably using a formal list of the old type)
ninja: build stopped: subcommand failed.

You forgot to download thirdparty libraries and specify the folder for cmake where they are located. Details on github.

There is actually no details for CMake at all, but I already have thirdparty, how should I link them? As lib/include?

Sorry, I forgot that this option is only available when building panda3D from source. I think you forgot to add the relevant dependency like libs. I’m not at my computer right now, so I can’t say for sure.

Updated CMake:

cmake_minimum_required(VERSION 3.25)
project(untitled1)

set(CMAKE_CXX_STANDARD 17)

include_directories(p3d/include)

add_executable(untitled1 main.cpp)

file(GLOB P3DL p3d/lib/*.lib) # Getting all .lib files from libs folder.

link_directories(p3d/lib)

target_link_libraries(untitled1 PRIVATE ${P3DL})

And still don’t work. Honestly i’m trying to just install the engine like for 2 days.

set(PANDA3D_LIB -lp3framework -lpanda -lpandaexpress -lp3dtoolconfig -lp3dtool -lp3pystub -lp3direct)

I meant that this list should be expanded.

What should I add there?

I am not fully familiar with the features of Cmake, but I can only assume that libraries should be specified with an extension. In my old project, it looked something like this.

target_link_libraries(engine ${dir_pandaSDK}/lib/libpanda.lib)
target_link_libraries(engine ${dir_pandaSDK}/lib/libpandaexpress.lib)
target_link_libraries(engine ${dir_pandaSDK}/lib/libp3dtool.lib)
target_link_libraries(engine ${dir_pandaSDK}/lib/libp3dtoolconfig.lib)

I think it would be nice if you provide your code main.cpp file.

But there is about 20+ lib files and I should add them manually, is this should make it work?

I didn’t say that, I was talking about expansion. I must say it worked for me. Four was enough for me.

I checked, the dependency search style you specified does not work properly.
My file has been successfully built:

main.cxx

#include "pandaFramework.h"
#include "pandaSystem.h"

int main(int argc, char *argv[]) {
  // Open a new window framework
  PandaFramework framework;
  framework.open_framework(argc, argv);

  // Set the window title and open the window
  framework.set_window_title("My Panda3D Window");
  WindowFramework *window = framework.open_window();

  // Here is room for your own code

  // Do the main loop, equal to run() in python
  framework.main_loop();
  framework.close_framework();
  return (0);
}
cmake_minimum_required(VERSION 3.22)

# The name of the project.
project(Game VERSION 1.0)

# Directory where the Panda3D SDK is installed.
set(PandaSDK D:/Panda3D-1.10.13-x64)

# Name of the executive file.
add_executable(Game main.cxx)

# Set the dependency for the Game execution file.
target_link_libraries(Game ${PandaSDK}/lib/libp3framework.lib)
target_link_libraries(Game ${PandaSDK}/lib/libpanda.lib)
target_link_libraries(Game ${PandaSDK}/lib/libpandaexpress.lib)
target_link_libraries(Game ${PandaSDK}/lib/libp3dtool.lib)
target_link_libraries(Game ${PandaSDK}/lib/libp3dtoolconfig.lib)

# Specify where to look for Panda3D headers.
include_directories(${PandaSDK}/include)
cmake_minimum_required(VERSION 3.25)
project(untitled1)

set(CMAKE_CXX_STANDARD 17)

set(P3DSDK C:/Panda3D-1.10.13-x64)

add_executable(untitled1 main.cpp)

target_link_libraries(untitled1 ${P3DSDK}/lib/libp3framework.lib)
target_link_libraries(untitled1 ${P3DSDK}/lib/libpanda.lib)
target_link_libraries(untitled1 ${P3DSDK}/lib/libpandaexpress.lib)
target_link_libraries(untitled1 ${P3DSDK}/lib/libp3dtool.lib)
target_link_libraries(untitled1 ${P3DSDK}/lib/libp3dtoolconfig.lib)

include_directories(${P3DSDK}/include)
#include <iostream>
#include "pandaFramework.h" // also red line

int main() {
    std::cout << "Hello, World!" << std::endl;
    return 0;
}

The same error, nothing changes

I have only one thought, when you installed the Panda3D SDK, did you choose to support C++? Maybe the libs folder is just missing.

sdk/include/


sdk/lib/

I don’t see the required libraries, you need to reinstall Panda3D and select the C++ support option in the installer.

there is actually more of them, and libs like libpanda are there, they are at the bottom

there are dlls with names libpanda and others, maybe i should connect them somehow?

You should be using the Visual Studio project generator, not something else. I have no more thoughts.