Compiling a Redistributable: Trouble with "ifstream"

In order to test a segfault, I’m attempting to compile a version of Panda’s redistributable form with debug symbols present.

Note that I’m attempting to build Panda 1.10 (as downloaded from GitHub), in order to match the version that I’m otherwise working from.

So far, I’ve gotten past my first hurdle: “'iostream' file not found

(This thanks to a post on Ask Ubuntu that indicated that my version of Ubuntu introduced “some mess with clang”, and that it could be solved by installing g++-12.)

The build now gets further–but eventually hits the following error:

In file included from direct/src/plugin/plugin_common_composite1.cxx:2:
direct/src/plugin/fileSpec.cxx:329:3: error: unknown type name 'ifstream'; did you mean 'istream'?

(Which then causes further errors.)
(Full output at the end of this message.)

Looking at Panda’s source, it looks like “ifstream” is defined–although I haven’t traced through the #includes to see whether it’s actually being imported into the file referenced above.

My build command-line looks like this:
python3 makepanda/makepanda.py --everything --runtime --no-egl --no-gles2 --no-opencv --optimize 2 --distributor Thaumaturge-Art

I’m running this on Ubuntu 22.04.4 (64-bit).

Does anyone know what might be going wrong…?

And finally, the full output of my most-recent build attempt:

Version: 1.0.4
Core API Version: 1.0.4.2
Platform: linux-x86_64
Target OS: linux
Target arch: x86_64
Generating dependencies...
[  0%] Building C++ object built_Thaumaturge-Art_rt/tmp/p3dtoolbase_composite1.o
[  2%] Building C++ object built_Thaumaturge-Art_rt/tmp/p3dtoolbase_composite2.o
[  4%] Building C object built_Thaumaturge-Art_rt/tmp/p3dtoolbase_lookup3.o
[  6%] Building C++ object built_Thaumaturge-Art_rt/tmp/p3dtoolbase_indent.o
[  8%] Building C++ object built_Thaumaturge-Art_rt/tmp/p3dtoolutil_composite1.o
[ 10%] Building C++ object built_Thaumaturge-Art_rt/tmp/p3dtoolutil_composite2.o
[ 13%] Building C++ object built_Thaumaturge-Art_rt/tmp/p3dtool_dtool.o
[ 15%] Linking static library built_Thaumaturge-Art_rt/lib/libp3dtool.a
ar: `u' modifier ignored since `D' is the default (see `U')
[ 17%] Building C++ object built_Thaumaturge-Art_rt/tmp/p3prc_composite1.o
[ 19%] Building C++ object built_Thaumaturge-Art_rt/tmp/p3prc_composite2.o
[ 21%] Building C++ object built_Thaumaturge-Art_rt/tmp/p3dtoolconfig_dtoolconfig.o
[ 23%] Linking static library built_Thaumaturge-Art_rt/lib/libp3dtoolconfig.a
ar: `u' modifier ignored since `D' is the default (see `U')
[ 26%] Building C++ object built_Thaumaturge-Art_rt/tmp/p3interrogatedb_composite1.o
[ 28%] Building C++ object built_Thaumaturge-Art_rt/tmp/p3interrogatedb_composite2.o
[ 30%] Linking static library built_Thaumaturge-Art_rt/lib/libp3interrogatedb.a
ar: `u' modifier ignored since `D' is the default (see `U')
[ 32%] Building Interrogate database built_Thaumaturge-Art_rt/pandac/input/libp3dtoolbase.in
[ 34%] Building Interrogate database built_Thaumaturge-Art_rt/pandac/input/libp3dtoolutil.in
[ 36%] Building Interrogate database built_Thaumaturge-Art_rt/pandac/input/libp3prc.in
[ 39%] Building C++ object built_Thaumaturge-Art_rt/tmp/p3pandabase_pandabase.o
[ 41%] Building C++ object built_Thaumaturge-Art_rt/tmp/p3express_composite1.o
In file included from panda/src/express/p3express_composite1.cxx:15:
panda/src/express/hashVal.cxx:206:3: warning: 'MD5_Init' is deprecated [-Wdeprecated-declarations]
  MD5_Init(&ctx);
  ^
/usr/include/openssl/md5.h:49:1: note: 'MD5_Init' has been explicitly marked deprecated here
OSSL_DEPRECATEDIN_3_0 int MD5_Init(MD5_CTX *c);
^
/usr/include/openssl/macros.h:182:49: note: expanded from macro 'OSSL_DEPRECATEDIN_3_0'
#   define OSSL_DEPRECATEDIN_3_0                OSSL_DEPRECATED(3.0)
                                                ^
/usr/include/openssl/macros.h:62:52: note: expanded from macro 'OSSL_DEPRECATED'
#     define OSSL_DEPRECATED(since) __attribute__((deprecated))
                                                   ^
In file included from panda/src/express/p3express_composite1.cxx:15:
panda/src/express/hashVal.cxx:217:5: warning: 'MD5_Update' is deprecated [-Wdeprecated-declarations]
    MD5_Update(&ctx, buffer, count);
    ^
/usr/include/openssl/md5.h:50:1: note: 'MD5_Update' has been explicitly marked deprecated here
OSSL_DEPRECATEDIN_3_0 int MD5_Update(MD5_CTX *c, const void *data, size_t len);
^
/usr/include/openssl/macros.h:182:49: note: expanded from macro 'OSSL_DEPRECATEDIN_3_0'
#   define OSSL_DEPRECATEDIN_3_0                OSSL_DEPRECATED(3.0)
                                                ^
/usr/include/openssl/macros.h:62:52: note: expanded from macro 'OSSL_DEPRECATED'
#     define OSSL_DEPRECATED(since) __attribute__((deprecated))
                                                   ^
In file included from panda/src/express/p3express_composite1.cxx:15:
panda/src/express/hashVal.cxx:226:3: warning: 'MD5_Final' is deprecated [-Wdeprecated-declarations]
  MD5_Final(md, &ctx);
  ^
/usr/include/openssl/md5.h:51:1: note: 'MD5_Final' has been explicitly marked deprecated here
OSSL_DEPRECATEDIN_3_0 int MD5_Final(unsigned char *md, MD5_CTX *c);
^
/usr/include/openssl/macros.h:182:49: note: expanded from macro 'OSSL_DEPRECATEDIN_3_0'
#   define OSSL_DEPRECATEDIN_3_0                OSSL_DEPRECATED(3.0)
                                                ^
/usr/include/openssl/macros.h:62:52: note: expanded from macro 'OSSL_DEPRECATED'
#     define OSSL_DEPRECATED(since) __attribute__((deprecated))
                                                   ^
In file included from panda/src/express/p3express_composite1.cxx:15:
panda/src/express/hashVal.cxx:249:3: warning: 'MD5' is deprecated [-Wdeprecated-declarations]
  MD5((const unsigned char *)buffer, length, md);
  ^
/usr/include/openssl/md5.h:52:1: note: 'MD5' has been explicitly marked deprecated here
OSSL_DEPRECATEDIN_3_0 unsigned char *MD5(const unsigned char *d, size_t n,
^
/usr/include/openssl/macros.h:182:49: note: expanded from macro 'OSSL_DEPRECATEDIN_3_0'
#   define OSSL_DEPRECATEDIN_3_0                OSSL_DEPRECATED(3.0)
                                                ^
/usr/include/openssl/macros.h:62:52: note: expanded from macro 'OSSL_DEPRECATED'
#     define OSSL_DEPRECATED(since) __attribute__((deprecated))
                                                   ^
4 warnings generated.
[ 43%] Building C++ object built_Thaumaturge-Art_rt/tmp/p3express_composite2.o
[ 45%] Building Interrogate database built_Thaumaturge-Art_rt/pandac/input/libp3express.in
[ 47%] Building C++ object built_Thaumaturge-Art_rt/tmp/p3downloader_composite1.o
[ 50%] Building C++ object built_Thaumaturge-Art_rt/tmp/p3downloader_composite2.o
In file included from panda/src/downloader/p3downloader_composite2.cxx:7:
panda/src/downloader/httpDigestAuthorization.cxx:296:3: warning: 'MD5' is deprecated [-Wdeprecated-declarations]
  MD5((const unsigned char *)source.data(), source.length(), binary);
  ^
/usr/include/openssl/md5.h:52:1: note: 'MD5' has been explicitly marked deprecated here
OSSL_DEPRECATEDIN_3_0 unsigned char *MD5(const unsigned char *d, size_t n,
^
/usr/include/openssl/macros.h:182:49: note: expanded from macro 'OSSL_DEPRECATEDIN_3_0'
#   define OSSL_DEPRECATEDIN_3_0                OSSL_DEPRECATED(3.0)
                                                ^
/usr/include/openssl/macros.h:62:52: note: expanded from macro 'OSSL_DEPRECATED'
#     define OSSL_DEPRECATED(since) __attribute__((deprecated))
                                                   ^
1 warning generated.
[ 52%] Building Interrogate database built_Thaumaturge-Art_rt/pandac/input/libp3downloader.in
[ 54%] Building C++ object built_Thaumaturge-Art_rt/tmp/pandaexpress_pandaexpress.o
[ 56%] Linking static library built_Thaumaturge-Art_rt/lib/libpandaexpress.a
ar: `u' modifier ignored since `D' is the default (see `U')
[ 58%] Building C++ object built_Thaumaturge-Art_rt/tmp/tinyxml_composite1.o
[ 60%] Linking static library built_Thaumaturge-Art_rt/tmp/libp3tinyxml.a
ar: `u' modifier ignored since `D' is the default (see `U')
[ 63%] Building C++ object built_Thaumaturge-Art_rt/tmp/plugin_common.o
In file included from direct/src/plugin/plugin_common_composite1.cxx:1:
In file included from direct/src/plugin/load_plugin.cxx:14:
In file included from direct/src/plugin/load_plugin.h:17:
direct/src/plugin/p3d_plugin.h:233:9: warning: empty struct has size 0 in C, size 1 in C++ [-Wextern-c-compat]
typedef struct {
        ^
direct/src/plugin/p3d_plugin.h:241:9: warning: empty struct has size 0 in C, size 1 in C++ [-Wextern-c-compat]
typedef struct {
        ^
direct/src/plugin/p3d_plugin.h:249:9: warning: empty struct has size 0 in C, size 1 in C++ [-Wextern-c-compat]
typedef struct {
        ^
direct/src/plugin/p3d_plugin.h:797:9: warning: empty struct has size 0 in C, size 1 in C++ [-Wextern-c-compat]
typedef struct {
        ^
direct/src/plugin/p3d_plugin.h:826:9: warning: empty struct has size 0 in C, size 1 in C++ [-Wextern-c-compat]
typedef struct {
        ^
direct/src/plugin/p3d_plugin.h:984:9: warning: empty struct has size 0 in C, size 1 in C++ [-Wextern-c-compat]
typedef struct {
        ^
In file included from direct/src/plugin/plugin_common_composite1.cxx:2:
direct/src/plugin/fileSpec.cxx:329:3: error: unknown type name 'ifstream'; did you mean 'istream'?
  ifstream stream;
  ^~~~~~~~
  istream
direct/src/plugin/fileSpec.cxx:36:12: note: 'istream' declared here
using std::istream;
           ^
direct/src/plugin/fileSpec.cxx:329:12: error: calling a protected constructor of class 'std::basic_istream<char>'
  ifstream stream;
           ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/istream:606:7: note: declared protected here
      basic_istream()
      ^
In file included from direct/src/plugin/plugin_common_composite1.cxx:2:
direct/src/plugin/fileSpec.cxx:336:10: error: no member named 'open' in 'std::basic_istream<char>'
  stream.open(pathname.c_str(), std::ios::in | std::ios::binary);
  ~~~~~~ ^
direct/src/plugin/fileSpec.cxx:345:3: warning: 'MD5_Init' is deprecated [-Wdeprecated-declarations]
  MD5_Init(&ctx);
  ^
/usr/include/openssl/md5.h:49:1: note: 'MD5_Init' has been explicitly marked deprecated here
OSSL_DEPRECATEDIN_3_0 int MD5_Init(MD5_CTX *c);
^
/usr/include/openssl/macros.h:182:49: note: expanded from macro 'OSSL_DEPRECATEDIN_3_0'
#   define OSSL_DEPRECATEDIN_3_0                OSSL_DEPRECATED(3.0)
                                                ^
/usr/include/openssl/macros.h:62:52: note: expanded from macro 'OSSL_DEPRECATED'
#     define OSSL_DEPRECATED(since) __attribute__((deprecated))
                                                   ^
In file included from direct/src/plugin/plugin_common_composite1.cxx:2:
direct/src/plugin/fileSpec.cxx:353:5: warning: 'MD5_Update' is deprecated [-Wdeprecated-declarations]
    MD5_Update(&ctx, buffer, count);
    ^
/usr/include/openssl/md5.h:50:1: note: 'MD5_Update' has been explicitly marked deprecated here
OSSL_DEPRECATEDIN_3_0 int MD5_Update(MD5_CTX *c, const void *data, size_t len);
^
/usr/include/openssl/macros.h:182:49: note: expanded from macro 'OSSL_DEPRECATEDIN_3_0'
#   define OSSL_DEPRECATEDIN_3_0                OSSL_DEPRECATED(3.0)
                                                ^
/usr/include/openssl/macros.h:62:52: note: expanded from macro 'OSSL_DEPRECATED'
#     define OSSL_DEPRECATED(since) __attribute__((deprecated))
                                                   ^
In file included from direct/src/plugin/plugin_common_composite1.cxx:2:
direct/src/plugin/fileSpec.cxx:358:3: warning: 'MD5_Final' is deprecated [-Wdeprecated-declarations]
  MD5_Final(_hash, &ctx);
  ^
/usr/include/openssl/md5.h:51:1: note: 'MD5_Final' has been explicitly marked deprecated here
OSSL_DEPRECATEDIN_3_0 int MD5_Final(unsigned char *md, MD5_CTX *c);
^
/usr/include/openssl/macros.h:182:49: note: expanded from macro 'OSSL_DEPRECATEDIN_3_0'
#   define OSSL_DEPRECATEDIN_3_0                OSSL_DEPRECATED(3.0)
                                                ^
/usr/include/openssl/macros.h:62:52: note: expanded from macro 'OSSL_DEPRECATED'
#     define OSSL_DEPRECATED(since) __attribute__((deprecated))
                                                   ^
9 warnings and 3 errors generated.
Storing dependency cache.
Elapsed Time: 48 sec
The following command returned a non-zero value: clang++ -std=gnu++11 -ftemplate-depth-70 -fPIC -c -o built_Thaumaturge-Art_rt/tmp/plugin_common.o -Ibuilt_Thaumaturge-Art_rt/tmp -Ibuilt_Thaumaturge-Art_rt/include -DLINK_ALL_STATIC= -DHAVE_X11=1 -Idirect/src/plugin -pthread -fno-exceptions -fno-strict-aliasing -fno-unsafe-math-optimizations -O1 -D_DEBUG -Wall -Wno-unused-function -Wno-reorder -DBUILDING_P3D_PLUGIN direct/src/plugin/plugin_common_composite1.cxx
Build terminated.

It looks like your current compiler doesn’t have access to the std standard library for C++.

Hmm, it looks like you’re right.

Specifically, it looks like there’s something iffy about the std-library on this system.

As noted above, installing “g++-12” seems to fix one error–but introduces another.

Based on a post that I found online regarding a lack of the std-lib, I installed “libc++-dev”–which returns me to the original error. :/

I’ll investigate this further in the new day, I think…

Don’t build with --runtime or --rtdist; this builds the old, deprecated Panda3D Runtime. We no longer support that and it’s removed in 1.11.

EDIT: Sorry, noticed this post is several months old. Not sure why Discourse decided to bring it to my attention!

1 Like

Still useful information!

I honestly don’t remember what segfault I was trying to test, but if I come across it again and decide to resume this testing, then the above may well help!