Menu

Struggling to get up an running with CLR and dlib

Help
Dane
2016-09-05
2021-01-05
  • Dane

    Dane - 2016-09-05

    I have a c++ windows form application that I would like to use dlib with. I have opencv working fine, capturing video, etc. I have installed the latest dlib off github and added the library directories to properties in the project in VS 2015. Simply adding dlib source.cpp to my project generates errors about <condition_variable>, <future>, <mutex> and <thread> not being supported in /clr or /clr:pure. If I turn off /clr support for source.cpp, my project will again compile but immediately crashes with excpetions in ntdll.dll - access violations. Removing source.cpp returns the project to a happy working state. Anyone have experience with mixing CLR and dlib as I haven't run into this problem with opencv and I've struggled to find anything super clear/relevant on google. Thanks so much in advance for any help/guidance.

    Cheers!

     
    • Davis

      Davis - 2016-09-05

      dlib is just C++ code. There isn't anything special in it that would
      prevent it from working in a C++ compiler. So are you sure you are
      compiling all the .cpp files with the same compiler settings? Generally
      speaking, in C++, you have to compile all the .cpp files in the same mode
      or you get what are called one definition rule errors. This isn't a dlib
      thing but is a core C++ language thing.

       
    • aero dactyl

      aero dactyl - 2020-12-23

      Hey Davis,
      Even I am getting the same error,. I have used openCV and it's working fine, but when ever I am using the dlib in my header file and getting same error as mentioned by Dane :

      "about <conditionvariable>, <future>, <mutex> and <thread> not being supported in /clr or /clr:pure."</thread></mutex></future></conditionvariable>
      Can you please suggest some way to get rid of these errors :)

      @davisking
      
       
  • Dane

    Dane - 2016-09-06

    Thanks for the speedy reply. This was my understanding as well. In past projects, simply setting the file to not include /clr support was sufficient - the project would compile correctly and run correctly. What I can't understand is that I'm not even using any dlib calls yet, just including them via source.cpp in the project. And compiling and linking completes correctly when disabling /clr for the file, but upon launching the application I get an immeidate crash/exception - ntdll.dll from utility.cpp. I was hoping maybe someone in the community has some experience getting dlib to work within managed c++ / clr application / mixed enironment. I'm definitely not a compiler/linker expert, but currently something feels incompatible.

     
    • Davis

      Davis - 2016-09-06

      No idea. My experience with managed C++ is that it is a nightmare of
      incompatibilities with ISO standard C++. In the past I have used swig to
      create C# interfaces to C++ and that works well since you can use a real
      C++ compiler to compile the C++ code into a dll, which is then used in C#.

       
  • aero dactyl

    aero dactyl - 2021-01-05

    Hi Davis,
    I have used the PInvoke method , and i wanted to get the image_window to be accessed in the c# project or is there any way to get all the data related to
    (
    std::vector<dlib::rectangle> dets = detector(img);
    std::vector<full_object_detection> shapes;
    ) to c# project?</full_object_detection></dlib::rectangle>

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.