Can't build dlib with -DDLIB_ISO_CPP_ONLY=ON
Expected Behavior
Build dlib with only ISO CPP code
Current Behavior
Build failed.
-- Using CMake version: 3.10.2 -- Compiling dlib version: 19.19.0 -- C++11 activated. -- Configuring done -- Generating done -- Build files have been written to: /home/dcurtis/dlib/dlib-19.19/build dcurtis@LAPTOP-70MENJH8:~/dlib/dlib-19.19/build$ sudo cmake --build . --config Release --target install Scanning dependencies of target dlib [ 5%] Building CXX object dlib/CMakeFiles/dlib.dir/base64/base64_kernel_1.cpp.o [ 11%] Building CXX object dlib/CMakeFiles/dlib.dir/bigint/bigint_kernel_1.cpp.o [ 16%] Building CXX object dlib/CMakeFiles/dlib.dir/bigint/bigint_kernel_2.cpp.o [ 22%] Building CXX object dlib/CMakeFiles/dlib.dir/bit_stream/bit_stream_kernel_1.cpp.o [ 27%] Building CXX object dlib/CMakeFiles/dlib.dir/entropy_decoder/entropy_decoder_kernel_1.cpp.o [ 33%] Building CXX object dlib/CMakeFiles/dlib.dir/entropy_decoder/entropy_decoder_kernel_2.cpp.o [ 38%] Building CXX object dlib/CMakeFiles/dlib.dir/entropy_encoder/entropy_encoder_kernel_1.cpp.o [ 44%] Building CXX object dlib/CMakeFiles/dlib.dir/entropy_encoder/entropy_encoder_kernel_2.cpp.o [ 50%] Building CXX object dlib/CMakeFiles/dlib.dir/md5/md5_kernel_1.cpp.o [ 55%] Building CXX object dlib/CMakeFiles/dlib.dir/tokenizer/tokenizer_kernel_1.cpp.o [ 61%] Building CXX object dlib/CMakeFiles/dlib.dir/unicode/unicode.cpp.o [ 66%] Building CXX object dlib/CMakeFiles/dlib.dir/data_io/image_dataset_metadata.cpp.o In file included from /home/dcurtis/dlib/dlib-19.19/dlib/data_io/../geometry/../matrix/../threads/posix.h:4:0, from /home/dcurtis/dlib/dlib-19.19/dlib/data_io/../geometry/../matrix/../threads/threads_kernel.h:13, from /home/dcurtis/dlib/dlib-19.19/dlib/data_io/../geometry/../matrix/../threads.h:11, from /home/dcurtis/dlib/dlib-19.19/dlib/data_io/../geometry/../matrix/matrix_la.h:25, from /home/dcurtis/dlib/dlib-19.19/dlib/data_io/../geometry/../matrix.h:11, from /home/dcurtis/dlib/dlib-19.19/dlib/data_io/../geometry/point_transforms.h:9, from /home/dcurtis/dlib/dlib-19.19/dlib/data_io/../geometry.h:10, from /home/dcurtis/dlib/dlib-19.19/dlib/data_io/image_dataset_metadata.h:8, from /home/dcurtis/dlib/dlib-19.19/dlib/data_io/image_dataset_metadata.cpp:6: /home/dcurtis/dlib/dlib-19.19/dlib/data_io/../geometry/../matrix/../threads/threads_kernel_2.h:7:2: error: #error "DLIB_ISO_CPP_ONLY is defined so you can't use this OS dependent code. Turn DLIB_ISO_CPP_ONLY off if you want to use it." #error "DLIB_ISO_CPP_ONLY is defined so you can't use this OS dependent code. Turn DLIB_ISO_CPP_ONLY off if you want to use it." ^~~~~ dlib/CMakeFiles/dlib.dir/build.make:326: recipe for target 'dlib/CMakeFiles/dlib.dir/data_io/image_dataset_metadata.cpp.o' failed make[2]: *** [dlib/CMakeFiles/dlib.dir/data_io/image_dataset_metadata.cpp.o] Error 1 CMakeFiles/Makefile2:85: recipe for target 'dlib/CMakeFiles/dlib.dir/all' failed make[1]: *** [dlib/CMakeFiles/dlib.dir/all] Error 2 Makefile:151: recipe for target 'all' failed make: *** [all] Error 2
Steps to Reproduce
mkdir build cd build cmake .. -DDLIB_USE_BLAS=OFF -DDLIB_USE_LAPACK=OFF -DDLIB_ISO_CPP_ONLY=ON
I think the problem is that source.cpp has this: #include "../data_io/image_dataset_metadata.cpp" after #endif // DLIB_ISO_CPP_ONLY
what I am trying to do is see whether I can build DLIB without relying on pthread
- Version: 19.19
- Where did you get dlib: Downloaded zip and unzipped it
- Platform: Ubuntu for Windows 10
- Compiler: gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)
Thanks. I just pushed the fix. Although I don't think DLIB_ISO_CPP_ONLY mode is particularly useful anymore for dlib users.
Hi.
Thanks. I was trying to avoid using the pthread library but it turns out that it seems to be pretty standard so in the end it doesn't seem to matter. Previously i just included the header I needed but with the newest version of dlib I find I have to link source.cpp, as well. Anyhow, I seem to have got it working thanks.
Best wishes
- Dave
Sent from Outlook Mobilehttps://aka.ms/blhgte
From: Davis E. King [email protected] Sent: Tuesday, April 14, 2020 12:50:34 PM To: davisking/dlib [email protected] Cc: Curtis, David [email protected]; Author [email protected] Subject: Re: [davisking/dlib] Can't build dlib with -DDLIB_ISO_CPP_ONLY=ON (#2056)
Thanks. I just pushed the fix. Although I don't think DLIB_ISO_CPP_ONLY mode is particularly useful anymore for dlib users.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/davisking/dlib/issues/2056#issuecomment-613395275, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACLM3WJH5F5MUCDE3YPA6QLRMREYVANCNFSM4MG4CZRQ.
You may well be able to just #include the header you want still. This can be done by blanking out the dlib/test_for_odr_violations.h file, which is there to catch users doing silly things with their build setup. It has the unfortunate side effect of making header only builds not work though. But for years I got wave after wave of questions from people violating C++ ODR (in a way that has nothing to do with dlib, they just used their build tools wrong) and then emailing me about it. That header drastically reduces such incidences.
Hi.
Thanks. I thought about cheating one way or another but it turned out that using source.cpp doesn't seem to be a problem so I'm behaving.
Best wishes
- Dave
Sent from Outlook Mobilehttps://aka.ms/blhgte
From: Davis E. King [email protected] Sent: Wednesday, April 15, 2020 12:36:56 PM To: davisking/dlib [email protected] Cc: Curtis, David [email protected]; Author [email protected] Subject: Re: [davisking/dlib] Can't build dlib with -DDLIB_ISO_CPP_ONLY=ON (#2056)
You may well be able to just #include the header you want still. This can be done by blanking out the dlib/test_for_odr_violations.h file, which is there to catch users doing silly things with their build setup. It has the unfortunate side effect of making header only builds not work though. But for years I got wave after wave of questions from people violating C++ ODR (in a way that has nothing to do with dlib, they just used their build tools wrong) and then emailing me about it. That header drastically reduces such incidences.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/davisking/dlib/issues/2056#issuecomment-613985405, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACLM3WJYZBCMPATE3MBPAR3RMWL5RANCNFSM4MG4CZRQ.
Warning: this issue has been inactive for 35 days and will be automatically closed on 2020-05-30 if there is no further activity.
If you are waiting for a response but haven't received one it's possible your question is somehow inappropriate. E.g. it is off topic, you didn't follow the issue submission instructions, or your question is easily answerable by reading the FAQ, dlib's official compilation instructions, dlib's API documentation, or a Google search.
Warning: this issue has been inactive for 42 days and will be automatically closed on 2020-05-30 if there is no further activity.
If you are waiting for a response but haven't received one it's possible your question is somehow inappropriate. E.g. it is off topic, you didn't follow the issue submission instructions, or your question is easily answerable by reading the FAQ, dlib's official compilation instructions, dlib's API documentation, or a Google search.
Notice: this issue has been closed because it has been inactive for 45 days. You may reopen this issue if it has been closed in error.