Results 1 to 4 of 4

Thread: dll loading trouble

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: dll loading trouble

    see comments in code:

    Qt Code:
    1. ushort *graydata = NULL; //[10*10]; no need to initialize since detecFaces allocates the memory.
    2. QLibrary mylib("\\fdlib.dll");
    3. bool okLoad = mylib.load();
    4. //You should really check for errors!
    5. if(!okLoad){
    6. //handle error
    7. return;
    8. }
    9. bool loaded = mylib.isLoaded();
    10. if(!loaded){
    11. //TDOD: handle error
    12. return;
    13. }
    14. typedef void (*FdetectFace)(ushort*,int,int,int);
    15. FdetectFace detectFace = (FdetectFace)mylib.resolve("fdlib_detectfaces");
    16. if(detectFace ){
    17. //app crashes here
    18. detectFace(graydata,10,10,0);
    19. }
    20.  
    21. //at some point you should release the data allocted in detectFace:
    22. if(graydata)
    23. delete graydata;
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. unsafe public static extern void fdlib_detectfaces(ushort*data,int w,int h,int threshold);
    2.  
    3. unsafe
    4. {
    5. UInt16[] image = new ushort[10 * 10];
    6. fixed (ushort* ptr = &image[0])
    7. {
    8. //app works fine here
    9. fdlib_detectfaces(ptr, 10, 10, 0); //this calls recursively - does nothing, and never ends!! which is probably why it crashes.
    10. }
    11. }
    To copy to clipboard, switch view to plain text mode 
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  2. The following user says thank you to high_flyer for this useful post:

    ldynasa (23rd February 2011)

Similar Threads

  1. QGLWidget trouble again
    By John82 in forum Qt Programming
    Replies: 1
    Last Post: 4th August 2009, 10:58
  2. QGLWidget trouble
    By John82 in forum Qt Programming
    Replies: 9
    Last Post: 31st July 2009, 01:03
  3. SQL trouble
    By xmeister in forum Newbie
    Replies: 2
    Last Post: 25th March 2009, 11:53
  4. trouble with Qt-4 with kubuntu 8.04
    By impeteperry in forum Installation and Deployment
    Replies: 2
    Last Post: 25th July 2008, 16:21
  5. New to QT..need help guys..sorry for the trouble
    By neomax in forum General Discussion
    Replies: 2
    Last Post: 17th November 2006, 16:20

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.