I still have a problem with this. It seems that I will need to replicate the code within each DLL that uses it. Or else, if I want to centralize the dlib functions within a single DLL, I should write my own wrapper functions (with my own header files that don't include dlib header files) which call the dlib functions. Otherwise, I get the same link error.
Also, the dlib don't look like they respect declspec decorations, no?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I would recommend statically compiling dlib into your dlls.
Right, I haven't put any declspec annotations anywhere in dlib and in
general making shared libraries from C++ code is quite problematic.
Especially with visual studio and it's various different runtimes. See
also http://dlib.net/howto_contribute.html#9.
So I would really just statically compile it in. If you really care
about binary size you can include the individual cpp files from dlib
(rather than dlib/all/source.cpp which includes everything) and that
will cut down on the size.
Cheers,
Davis
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, i’m having a similar issue with svm_threaded but adding dlib/all/source.cpp to my project source files results in lots of linker errors (this happen with mingw). But on visual studio it doesn't change anything, though I won't say I totally understand what you mean by adding the source.cpp to my application, please I'll need your help in this regard.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have a similar problem. I'm using dlib with my dll library. Specifically, the dlib is static library and the dlib is linked with my dll library. I just want to link my dll library when I want to use dlib. So, I made new project and I linked my dll library which has static dlib. But it made an error like this:
unresolved external symbol USER_ERRORmissing_dlib_all_source_cpp_fileOR__inconsistent_use_of_DEBUG_or_ENABLE_ASSERTS_preprocessor_directives_
can I fix this error?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It means you aren't consistently #defining DEBUG or ENABLE_ASSERTS in your
code. Some .cpp files are compiled with one or both of those preprocessor
macros defined while others are not, resulting in a violation of C++'s one
definition rule (see http://en.wikipedia.org/wiki/One_Definition_Rule).
Moreover, you should probably read this article that talks about the
difficulties of using C++ inside dlls: http://siomsystems.com/mixing-visual-studio-versions/. The short summary
is don't use dlls.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am working on dlib from past 2 weeks.I want to step into cpp file of function (Means I want to see the source code) as i was doing in opencv.Can you please help me to find?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, I thought to try out dlib's thread wrapper. I created a program like below:
This gives me the below error. Any idea what is happening? This is dlib 18.7 with MSVC 9.
Thanks!
Greg
1>dlib_thread_test.obj : error LNK2019: unresolved external symbol _USER_ERRORviolation_of_one_definition_rule_detectedinconsistent_use_of_DEBUG_or_ENABLE_ASSERTS_preprocessor_directives referenced in function _dlib_check_consistent_assert_usage
1>C:\gcs6\build\vs2008\plastimatch-3.20.1-dcmtk\Release\dlib_thread_test.exe : fatal error LNK1120: 1 unresolved externals
Last edit: Gregory Sharp 2014-06-24
You probably forgot to add dlib/all/source.cpp into your application.
Cheers,
Davis
Just figured that out! I'm so used to using dlib as header only. Thanks Davis!
No problem :)
Cheers,
Davis
Just figured that out! I'm so used to using dlib as header only. Thanks Davis!
I still have a problem with this. It seems that I will need to replicate the code within each DLL that uses it. Or else, if I want to centralize the dlib functions within a single DLL, I should write my own wrapper functions (with my own header files that don't include dlib header files) which call the dlib functions. Otherwise, I get the same link error.
Also, the dlib don't look like they respect declspec decorations, no?
I would recommend statically compiling dlib into your dlls.
Right, I haven't put any declspec annotations anywhere in dlib and in
general making shared libraries from C++ code is quite problematic.
Especially with visual studio and it's various different runtimes. See
also http://dlib.net/howto_contribute.html#9.
So I would really just statically compile it in. If you really care
about binary size you can include the individual cpp files from dlib
(rather than dlib/all/source.cpp which includes everything) and that
will cut down on the size.
Cheers,
Davis
OK, I understand. Thanks!
No problem :)
Hi, i’m having a similar issue with svm_threaded but adding dlib/all/source.cpp to my project source files results in lots of linker errors (this happen with mingw). But on visual studio it doesn't change anything, though I won't say I totally understand what you mean by adding the source.cpp to my application, please I'll need your help in this regard.
How exactly are you compiling it and what are the errors?
Cheers,
Davis
I have a similar problem. I'm using dlib with my dll library. Specifically, the dlib is static library and the dlib is linked with my dll library. I just want to link my dll library when I want to use dlib. So, I made new project and I linked my dll library which has static dlib. But it made an error like this:
unresolved external symbol USER_ERRORmissing_dlib_all_source_cpp_fileOR__inconsistent_use_of_DEBUG_or_ENABLE_ASSERTS_preprocessor_directives_
can I fix this error?
It means you aren't consistently #defining DEBUG or ENABLE_ASSERTS in your
code. Some .cpp files are compiled with one or both of those preprocessor
macros defined while others are not, resulting in a violation of C++'s one
definition rule (see http://en.wikipedia.org/wiki/One_Definition_Rule).
Moreover, you should probably read this article that talks about the
difficulties of using C++ inside dlls:
http://siomsystems.com/mixing-visual-studio-versions/. The short summary
is don't use dlls.
Hi,
I am working on dlib from past 2 weeks.I want to step into cpp file of function (Means I want to see the source code) as i was doing in opencv.Can you please help me to find?