CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23
  1. #16
    Join Date
    Jul 2010
    Location
    Baltimore, MD, USA
    Posts
    84

    Re: Problem with adding DLL/lib file into VC++ Project

    I am still not sure what you want to kno, I am sure you are clear, but I am inexperienced. But following could be an answer to your question.
    Yes, the dll was provided by Vernier Hardware and they have a detailed documentation of each function in the dll.
    Like I mentioned in my very first post. I first used 'extern "C" __declspec(dllimport)' to get the functions. Then I used them in my program normally. But that was without including the header files.
    The header already had declarations of the functions. So, after using the headers if i used dllimport, then it gave some error of re-declaration/ function overloading. So I removed the dllimport. I just used the functions normally. like function(arg1,arg2);
    I hope this answers your question.

  2. #17
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Problem with adding DLL/lib file into VC++ Project

    Quote Originally Posted by guptesanket View Post
    I just used the functions normally. like function(arg1,arg2);
    I hope this answers your question.
    Show your code with such a call of some dll function.
    Victor Nijegorodov

  3. #18
    Join Date
    Jul 2010
    Location
    Baltimore, MD, USA
    Posts
    84

    Re: Problem with adding DLL/lib file into VC++ Project

    Quote Originally Posted by VictorN View Post
    Show your code with such a call of some dll function.

    GOIO_SENSOR_HANDLE CRT_TDoc::OpenDevice(int vendorId, int productId, LPCSTR pDeviceName)
    {

    CRT_TView *pView = (CRT_TView *)(((CFrameWnd *) AfxGetMainWnd())->GetActiveView());
    ASSERT(pView);
    char tmpstring[50];
    if (m_pDevice)
    {
    char openDeviceName[GOIO_MAX_SIZE_DEVICE_NAME];
    int openVendorId, openProductId;
    GoIO_Sensor_GetOpenDeviceName(m_pDevice, openDeviceName, GOIO_MAX_SIZE_DEVICE_NAME, &openVendorId, &openProductId);

    if (0 != strcmp(openDeviceName, pDeviceName))
    {
    //Close the open device if it does not match the new one.
    CloseDevice();
    }
    }

    if (!m_pDevice)
    m_pDevice = GoIO_Sensor_Open(pDeviceName, vendorId, productId, 0);

    if (m_pDevice)
    {
    unsigned char charId;
    GoIO_Sensor_DDSMem_GetSensorNumber(m_pDevice, &charId, 0, 0);


    float ftemp[3];
    unsigned char calPageIndex;
    GoIO_Sensor_DDSMem_GetActiveCalPage(m_pDevice, &calPageIndex);
    GoIO_Sensor_DDSMem_GetCalPage(m_pDevice, calPageIndex,
    &ftemp[0], &ftemp[1], &ftemp[2], tmpstring, sizeof(tmpstring));

    SetMeasurementPeriodInSeconds(GoIO_Sensor_GetMeasurementPeriod(m_pDevice, SKIP_TIMEOUT_MS_DEFAULT));
    }

    return m_pDevice;
    }

    Above is my function to open the device. The dll vendor (Vernier) provided functions are the ones which start with GoIO.
    Thank you.

  4. #19
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Problem with adding DLL/lib file into VC++ Project

    1. Please, use Code tags while posting code snippets. See Announcement: Before you post....
    2. What is the m_pDevice and what is this value when GOIO_SENSOR_HANDLE CRT_TDoc::OpenDevice(...) is called?
    Please, set a break point in the begin of this function, then start Debugger (F5), execute this code step by step (F10) and see what happens, the values of variables and so on...
    Victor Nijegorodov

  5. #20
    Join Date
    Jul 2010
    Location
    Baltimore, MD, USA
    Posts
    84

    Re: Problem with adding DLL/lib file into VC++ Project

    m_pDevice is the handle to open the device. It is NULL initially. The function opens the device and the sensor associated with the hardware, and returns the handle to it.( It is supposed to but it doesnt)
    I am sure there is no problem with the code, since I am using most of the code as provided in the source code. I am just missing something in the connection. Like you said,
    "added the .lib file in the list of additional libraries/modules" or
    "Project Properties->Linker->Input->Additional Dependencies"

    I do not know what is supposed to be done in the above mentioned things. I would be really glad if you could put some light in that matter.
    Thank you

  6. #21
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Problem with adding DLL/lib file into VC++ Project

    Quote Originally Posted by guptesanket View Post
    ... I am just missing something in the connection. Like you said,
    "added the .lib file in the list of additional libraries/modules" or
    "Project Properties->Linker->Input->Additional Dependencies"

    I do not know what is supposed to be done in the above mentioned things. I would be really glad if you could put some light in that matter.
    Thank you
    Please, forget this type of problems!
    Since your App compiles and links OK, since you don't have any error messages/crashes while executing - all these things seem to be OK.
    Please, have a look at the executing. Do it with debug and see whether all the thing are OK or somewhere some error occurs.

    What does GoIO_Sensor_DDSMem_GetSensorNumber() return? A valid handle or NULL?
    How could you get the reason of an error if it occurs?
    Victor Nijegorodov

  7. #22
    Join Date
    Jul 2010
    Location
    Baltimore, MD, USA
    Posts
    84

    Re: Problem with adding DLL/lib file into VC++ Project

    Hey Mr. VictorN,
    Thank you very much for your expert advice. I really appreciate your help and patience. It was really helpful when you said that "Since your App compiles and links OK, since you don't have any error messages/crashes while executing - all these things seem to be OK."
    I concentrated on the debugging part, and found a tiny mistake. The sensors are to be initialized before I use them, and apparently the vendor provided me a dll, which did not initialize it in the dll and nor was it mentioned in the source code and documentation.
    But thanks a lot for your help.

  8. #23
    Join Date
    Jan 2007
    Posts
    5

    Re: [RESOLVED] Problem with adding DLL/lib file into VC++ Project

    Hi,

    For me it seems that the problem is not with #include and dlls and libs; it is with connections. E.g. if you scan the external devices, your functions are sending requests to external devices and the devices can't understand them or they replay and your program does not understand the replays. Did you check the communication protocols?

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured