Hello, very new user here. So, I decided to code in C++ instead of Python. I also used Clang, CMake, and Ninja for the project instead of Visual Studio 2022. I installed and followed the instructions for installing Panda3D on Windows, and it was successful. The problem arose when I started building my project. The error, specifically a linker error, that was thrown is:
PS ~\Projects\C++\HelloPanda3D\build> cmake --build .
[2/2] Linking CXX executable game.exe
FAILED: game.exe
C:\WINDOWS\system32\cmd.exe /C "cd . && C:\msys64\ucrt64\bin\clang++.exe -fPIC -O2 CMakeFiles/game.dir/main.cpp.obj -o game.exe -Wl,--out-implib,libgame.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -LC:/Panda3D-1.10.14-x64/lib -lp3framework -lpanda -lpandafx -lpandaexpress -lp3dtoolconfig -lp3dtool -lp3direct -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
C:/msys64/ucrt64/bin/ld: CMakeFiles/game.dir/main.cpp.obj:main.cpp:(.text+0x31): undefined reference to `PandaFramework::PandaFramework()'
C:/msys64/ucrt64/bin/ld: CMakeFiles/game.dir/main.cpp.obj:main.cpp:(.text+0x47): undefined reference to `PandaFramework::open_framework(int&, char**&)'
C:/msys64/ucrt64/bin/ld: CMakeFiles/game.dir/main.cpp.obj:main.cpp:(.text+0xd5): undefined reference to `PandaFramework::open_window()'
C:/msys64/ucrt64/bin/ld: CMakeFiles/game.dir/main.cpp.obj:main.cpp:(.text+0xde): undefined reference to `PandaFramework::main_loop()'
C:/msys64/ucrt64/bin/ld: CMakeFiles/game.dir/main.cpp.obj:main.cpp:(.text+0xe7): undefined reference to `PandaFramework::close_framework()'
C:/msys64/ucrt64/bin/ld: CMakeFiles/game.dir/main.cpp.obj:main.cpp:(.text+0xf0): undefined reference to `PandaFramework::~PandaFramework()'
C:/msys64/ucrt64/bin/ld: CMakeFiles/game.dir/main.cpp.obj:main.cpp:(.text+0x123): undefined reference to `PandaFramework::~PandaFramework()'
C:/msys64/ucrt64/bin/ld: CMakeFiles/game.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'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
This was puzzling, because Panda3Dās path is in the System Environment Variable. The directories are also proper. Here is my CMakeLists.txt:
cmake_minimum_required(VERSION 3.13)
project(HelloPanda3D)
# Set the Panda3D include and library directories
set(PANDA3D_INCLUDE_DIR "C:/Panda3D-1.10.14-x64/include")
set(PANDA3D_LIB_DIR "C:/Panda3D-1.10.14-x64/lib")
# Specify the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Compiler flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -O2")
# Include directories
include_directories(${PANDA3D_INCLUDE_DIR})
# Link directories
link_directories(${PANDA3D_LIB_DIR})
# Add the executable
add_executable(game main.cpp)
# Link Panda3D libraries
target_link_libraries(game
p3framework
panda
pandafx
pandaexpress
p3dtoolconfig
p3dtool
p3direct
)
Iām not sure if the library names are correct, though (I tried, for example, libp3framework
, but it still didnāt work anyway). Thanks in advance.