davisking / dlib

A toolkit for making real world machine learning and data analysis applications in C++
http://dlib.net
Boost Software License 1.0
13.44k stars 3.37k forks source link

all/source.cpp includes files that can not be compiled with DLIB_ISO_CPP_ONLY #1478

Closed NiklasRosenstein closed 6 years ago

NiklasRosenstein commented 6 years ago

Expected Behavior

Compiling all/source.cpp with DLIB_ISO_CPP_ONLY defined to compile and not result in the error "DLIB_ISO_CPP_ONLY is defined so you can't use this OS dependent code. [...]".

Current Behavior

In file included from C:\Users\niklas\Applications\Cinema 4D R20.021\plugins\c4d-nr-toolbox\build\debug\.source-downloads\dlib-19.15\dlib-19.15\dlib\all\source.cpp:89:
In file included from C:\Users\niklas\Applications\Cinema 4D R20.021\plugins\c4d-nr-toolbox\build\debug\.source-downloads\dlib-19.15\dlib-19.15\dlib\all/../data_io/image_dataset_metadata.cpp:6:
In file included from C:\Users\niklas\Applications\Cinema 4D R20.021\plugins\c4d-nr-toolbox\build\debug\.source-downloads\dlib-19.15\dlib-19.15\dlib\all/../data_io/image_dataset_metadata.h:8:
In file included from C:\Users\niklas\Applications\Cinema 4D R20.021\plugins\c4d-nr-toolbox\build\debug\.source-downloads\dlib-19.15\dlib-19.15\dlib\all/../data_io/../geometry.h:10:
In file included from C:\Users\niklas\Applications\Cinema 4D R20.021\plugins\c4d-nr-toolbox\build\debug\.source-downloads\dlib-19.15\dlib-19.15\dlib\all/../base64/../geometry/point_transforms.h:9:
In file included from C:\Users\niklas\Applications\Cinema 4D R20.021\plugins\c4d-nr-toolbox\build\debug\.source-downloads\dlib-19.15\dlib-19.15\dlib\all/../base64/../geometry/../matrix/../optimization/../matrix.h:11:
In file included from C:\Users\niklas\Applications\Cinema 4D R20.021\plugins\c4d-nr-toolbox\build\debug\.source-downloads\dlib-19.15\dlib-19.15\dlib\all/../base64/../matrix/matrix_la.h:25:
In file included from C:\Users\niklas\Applications\Cinema 4D R20.021\plugins\c4d-nr-toolbox\build\debug\.source-downloads\dlib-19.15\dlib-19.15\dlib\all/../base64/../geometry/../matrix/../threads.h:11:
In file included from C:\Users\niklas\Applications\Cinema 4D R20.021\plugins\c4d-nr-toolbox\build\debug\.source-downloads\dlib-19.15\dlib-19.15\dlib\all/../base64/../threads/threads_kernel.h:9:
In file included from C:\Users\niklas\Applications\Cinema 4D R20.021\plugins\c4d-nr-toolbox\build\debug\.source-downloads\dlib-19.15\dlib-19.15\dlib\all/../base64/../threads/windows.h:4:
C:\Users\niklas\Applications\Cinema 4D R20.021\plugins\c4d-nr-toolbox\build\debug\.source-downloads\dlib-19.15\dlib-19.15\dlib\all/../base64/../threads/threads_kernel_1.h(7,2):  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."

Steps to Reproduce

Possible Resolution

It appears the following includes in all/source.cpp should be inside the DLIB_ISO_CPP_ONLY guard. Currently, they follow directly after the closing #endif // DLIB_ISO_CPP_ONLY.

#include "../data_io/image_dataset_metadata.cpp"
#include "../data_io/mnist.cpp"
#include "../global_optimization/global_function_search.cpp"
#include "../filtering/kalman_filter.cpp"
#include "../svm/auto.cpp"
davisking commented 6 years ago

I've somewhat given up on DLIB_ISO_CPP_ONLY as I'm not sure there is still a real use case for it. Do you need to use it? I'm likely to remove it in a future dlib release if important use cases don't surface.

NiklasRosenstein commented 6 years ago

I remember I needed it before -- with an older MSVC version if I remember correctly. I don't need it anymore.

davisking commented 6 years ago

Cool. I'm still going to sit on it a bit but I'll probably remove the feature altogether soonish.

ghost commented 5 years ago

I am currently using it (turning this "DLIB_ISO_CPP_ONLY" feature ON) during cmake compile to shaving down the size of .lib file. However, I am having the same error.

davisking commented 5 years ago

I forgot all about this issue :/

If you want to make things smaller it's probably easier to just go remove .cpp files from the CMakeLists.txt file. That's really all that flag does and there are almost certainly more you could remove.

ghost commented 5 years ago

Thanks for the feedback. That's what I was trying to do by turning on the flag "DLIB_ISO_CPP_ONLY". It supposes to turn off all these following functions based on CMakeLists.txt file in dlib folder. " sockets/sockets_kernel_1.cpp bsp/bsp.cpp dir_nav/dir_nav_kernel_1.cpp dir_nav/dir_nav_kernel_2.cpp dir_nav/dir_nav_extensions.cpp linker/linker_kernel_1.cpp logger/extra_logger_headers.cpp logger/logger_kernel_1.cpp logger/logger_config_file.cpp misc_api/misc_api_kernel_1.cpp misc_api/misc_api_kernel_2.cpp sockets/sockets_extensions.cpp sockets/sockets_kernel_2.cpp sockstreambuf/sockstreambuf.cpp sockstreambuf/sockstreambuf_unbuffered.cpp server/server_kernel.cpp server/server_iostream.cpp server/server_http.cpp threads/multithreaded_object_extension.cpp threads/threaded_object_extension.cpp threads/threads_kernel_1.cpp threads/threads_kernel_2.cpp threads/threads_kernel_shared.cpp threads/thread_pool_extension.cpp threads/async.cpp timer/timer.cpp stack_trace.cpp cuda/cpu_dlib.cpp cuda/tensor_tools.cpp " However, the build fails becuse of these follwoing lines in "threads_kernel_1.h"

ifdef DLIB_ISO_CPP_ONLY

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."

endif

Solved the problem just by commenting those lines.

Now I can build it. :)

If I don't do that "Project.sln" can't compile the .lib as it fails to compile "kalman_filter.cpp"