Results 1 to 5 of 5

Thread: C library help please

  1. #1
    Join Date
    Nov 2012
    Location
    Kentucky, USA
    Posts
    46
    Thanks
    21
    Qt products
    Qt4
    Platforms
    Windows

    Default C library help please

    Ok, I don't know C and I am a newbie to C++/Qt, so here is my problem.
    I have a Qt program which works fine, until I try to link to a C library.

    I put the required lines into the .pro file and the library appears to link just fine. No errors on compile/link.
    Yes, I included the required C library .h files.
    Now, how to properly call a function in the C library? This should be easy for you experts

    In the C library header, we have: int (*rig_init) (RIG * rig); And the correct value for my rig is 32.
    So in my mainwindow.h I put: int* rig;
    Then in mainwindow.cpp I put: rig = rig_init(32);

    And when I try to build, I get: mainwindow.cpp:238: error: cannot convert 'RIG*' to 'int*' in assignment

    So, please help me out here and tell a newbie what I am doing wrong, and thanks!

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: C library help please

    The function declaration you tell us about expects an argument of type pointer-to-RIG and returns an int. You are not using this AFAICT.

    The function you are calling expects an int argument and returns a pointer-to-RIG. You are giving it an int argument and trying to force the RIG* into an int*.

    Functions are from hamlib?

  3. The following user says thank you to ChrisW67 for this useful post:

    K4ELO (16th November 2012)

  4. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: C library help please

    In other words it should probably be:

    Qt Code:
    1. RIG rig;
    2. int ok = rig_init(&rig);
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. The following user says thank you to wysota for this useful post:

    K4ELO (16th November 2012)

  6. #4
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: C library help please

    more like
    Qt Code:
    1. RIG rig;
    2. int ok = (*rig_init)(&rig);
    To copy to clipboard, switch view to plain text mode 
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  7. The following user says thank you to amleto for this useful post:

    K4ELO (16th November 2012)

  8. #5
    Join Date
    Nov 2012
    Location
    Kentucky, USA
    Posts
    46
    Thanks
    21
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: C library help please

    Thanks guys - I'll work on it. Yes Chris, the library is hamlib. Good docs on using the executables but I'm not finding any on using the library. I'm trying to use it with the logging program I wrote in Qt so I can support more than just my Flex radio.

Similar Threads

  1. How do I point to a C++ library (non Qt library)
    By ChrisL1234 in forum Newbie
    Replies: 5
    Last Post: 7th June 2012, 23:51
  2. Dynamic library on Mac, Library not loaded
    By grayfox in forum Newbie
    Replies: 2
    Last Post: 2nd July 2011, 02:42
  3. Replies: 2
    Last Post: 19th February 2011, 11:26
  4. Replies: 4
    Last Post: 18th December 2009, 18:55
  5. Replies: 1
    Last Post: 13th August 2009, 16:32

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.