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

@rdb maybe you can help?

i’ll try this, thank you for help!

One more thought, try to run project generation and build it via command line. IDEs sometimes behave strangely.

It compiled to .o successfully after using

gcc -c main.cpp -o main.o -I C:\Panda3D-1.10.13-x64\include 

But after trying to create exe using

gcc main.o -o main -L C:\Panda3D-1.10.13-x64\lib -lp3framework -lpanda -lpandafx -lpandaexpress -lp3dtoolconfig -lp3dtool -lp3direct 

im getting this

c:/users/ione/gcc/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: main.o:main.cpp:(.text+0x22): undefined reference to `std::basic_ostream<char, std::c
har_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
c:/users/ione/gcc/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: main.o:main.cpp:(.text+0x34): undefined reference to `std::ostream::operator<<(std::o
stream& (*)(std::ostream&))'
c:/users/ione/gcc/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: main.o:main.cpp:(.text+0x56): undefined reference to `std::ios_base::Init::~Init()'
c:/users/ione/gcc/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: main.o:main.cpp:(.text+0x91): undefined reference to `std::ios_base::Init::Init()'   
c:/users/ione/gcc/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: main.o:main.cpp:(.text+0xaa): undefined reference to `BitMask<unsigned int, 32>::lowe
r_on(int)'
c:/users/ione/gcc/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: main.o:main.cpp:(.text+0xba): undefined reference to `BitMask<unsigned int, 32>::bit(
int)'
c:/users/ione/gcc/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: main.o:main.cpp:(.rdata$.refptr._ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0
_ES6_[.refptr._ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_]+0x0): undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits
<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
c:/users/ione/gcc/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: main.o:main.cpp:(.rdata$.refptr._ZSt4cout[.refptr._ZSt4cout]+0x0): undefined referenc
e to `std::cout'
c:/users/ione/gcc/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: main.o:main.cpp:(.rdata$.refptr.panda_version_1_10[.refptr.panda_version_1_10]+0x0): 
undefined reference to `panda_version_1_10'
collect2.exe: error: ld returned 1 exit status

basically it’s just the same error like it was

I remember you were told to use the compiler from Microsoft, it comes from Visual Studio. Panda3D is built only with it.

How to use VS compiler in console?

I summarized everything, maybe you’ll see an real error there?

VS compiler:


My CMake:
My CPP:

Error:

====================[ Build | untitled1 | Debug ]===============================
"F:\Clion\CLion 2023.1.3\bin\cmake\win\x64\bin\cmake.exe" --build C:\Users\IonE\CLionProjects\untitled1\cmake-build-debug --target untitled1 -- config Debug
Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for the .NET Framework
(C) Microsoft Corporation. All rights reserved.

  main.cpp

C:\Panda3D-1.10.13-x64\include\Eigen\src/Core/Functors.h(973,28): error C2039: "binder2nd": is not a member of "std". [C:\Users\IonE\CLionProjects\untitled1\cmake-build-debug\untitled1.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include\functional(31): message : see declaration "std" [C:\Users\IonE\CLionProjects\untitled1 \cmake-build-debug\untitled1.vcxproj]
C:\Panda3D-1.10.13-x64\include\Eigen\src/Core/Functors.h(973,1): error C2065: binder2nd: undeclared identifier [C:\Users\IonE\CLionProjects\untitled1\cmake-build -debug\untitled1.vcxproj]
C:\Panda3D-1.10.13-x64\include\Eigen\src/Core/Functors.h(973,1): error C2974: Eigen::internal::functor_traits: invalid template argument for "T", requires type [ C:\Users\IonE\CLionProjects\untitled1\cmake-build-debug\untitled1.vcxproj]
C:\Panda3D-1.10.13-x64\include\Eigen\src/Core/util/XprHelper.h(90): message : see declaration "Eigen::internal::functor_traits" [C:\Users\IonE\ CLionProjects\untitled1\cmake-build-debug\untitled1.vcxproj]
C:\Panda3D-1.10.13-x64\include\Eigen\src/Core/Functors.h(973,41): error C2988: unrecognized template declaration or definition [C:\Users\IonE\CLionProjects\untitled1\cmake- build-debug\untitled1.vcxproj]
C:\Panda3D-1.10.13-x64\include\Eigen\src/Core/Functors.h(973,41): error C2143: syntax error: missing ";" before ">" [C:\Users\IonE\CLionProjects\untitled1\cmake-build-debug\untitled1.vcxproj]
C:\Panda3D-1.10.13-x64\include\Eigen\src/Core/Functors.h(974,1): error C2143: syntax error: missing ";" before "{" [C:\Users\IonE\CLionProjects\untitled1\cmake-build-debug\untitled1.vcxproj]
C:\Panda3D-1.10.13-x64\include\Eigen\src/Core/Functors.h(974,1): error C2447: {: missing function header (perhaps using formal list of old type) [C:\Users \IonE\CLionProjects\untitled1\cmake-build-debug\untitled1.vcxproj]
C:\Panda3D-1.10.13-x64\include\Eigen\src/Core/Functors.h(977,28): error C2039: "binder1st": is not a member of "std". [C:\Users\IonE\CLionProjects\untitled1\cmake-build-debug\untitled1.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\include\functional(31): message : see declaration "std" [C:\Users\IonE\CLionProjects\untitled1 \cmake-build-debug\untitled1.vcxproj]
C:\Panda3D-1.10.13-x64\include\Eigen\src/Core/Functors.h(977,1): error C2065: binder1st: undeclared identifier [C:\Users\IonE\CLionProjects\untitled1\cmake-build -debug\untitled1.vcxproj]
C:\Panda3D-1.10.13-x64\include\Eigen\src/Core/Functors.h(977,1): error C2974: Eigen::internal::functor_traits: invalid template argument for "T", requires type [ C:\Users\IonE\CLionProjects\untitled1\cmake-build-debug\untitled1.vcxproj]
C:\Panda3D-1.10.13-x64\include\Eigen\src/Core/util/XprHelper.h(90): message : see declaration "Eigen::internal::functor_traits" [C:\Users\IonE\ CLionProjects\untitled1\cmake-build-debug\untitled1.vcxproj]
C:\Panda3D-1.10.13-x64\include\Eigen\src/Core/Functors.h(977,41): error C2988: unrecognized template declaration or definition [C:\Users\IonE\CLionProjects\untitled1\cmake- build-debug\untitled1.vcxproj]
C:\Panda3D-1.10.13-x64\include\Eigen\src/Core/Functors.h(977,41): error C2143: syntax error: missing ";" before ">" [C:\Users\IonE\CLionProjects\untitled1\cmake-build-debug\untitled1.vcxproj]
C:\Panda3D-1.10.13-x64\include\Eigen\src/Core/Functors.h(977,41): error C2059: syntax error: > [C:\Users\IonE\CLionProjects\untitled1\cmake-build -debug\untitled1.vcxproj]
C:\Panda3D-1.10.13-x64\include\Eigen\src/Core/Functors.h(978,1): error C2143: syntax error: missing ";" before "{" [C:\Users\IonE\CLionProjects\untitled1\cmake-build-debug\untitled1.vcxproj]
C:\Panda3D-1.10.13-x64\include\Eigen\src/Core/Functors.h(978,1): error C2447: {: missing function header (perhaps using formal list of old type) [C:\Users \IonE\CLionProjects\untitled1\cmake-build-debug\untitled1.vcxproj]

You need a Release mode

cmake --build . --target Game --config Release

With this command, I built the above-mentioned “Game” project.

unfortunately, command is

"F:\Clion\CLion 2023.1.3\bin\cmake\win\x64\bin\cmake.exe" --build C:\Users\IonE\CLionProjects\untitled1\cmake-build-release --target untitled1 --config Release

(changed to release mode)

but it returns still same error

I checked this line causes an error.

set(CMAKE_CXX_STANDARD 17)

1 Like

YES IT IS, finally thank you!!!

1 Like