"undefined reference" error message when using mkoctfile to create oct file

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
28 messages Options
12
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

"undefined reference" error message when using mkoctfile to create oct file

Yan Zhang

Hi Folks,

 

I’m a new user of Octave and trying to make a oct file so that I can control a Newport Power Meter in my octave program. I have a c++ code file “PowerMeter.cc”, and I also have a header file “NewpDll.h” and a dll file “usbdll.dll” which are obtained from Newport driver examples.  When I tried to create the OCT file, I got the following messages:

 

----------------------------------------------------------------

>> mkoctfile PowerMeter.cc -usbdll.dll

PowerMeter.o: In function `Z12CloseDevicesv':

C:\Users\yan.zhang\Desktop\TestCam_Project\Oct_Src\cc/PowerMeter.cc:19: undefined reference to `newp_usb_uninit_system@0'

PowerMeter.o: In function `Z11OpenDevicesi':

C:\Users\yan.zhang\Desktop\TestCam_Project\Oct_Src\cc/PowerMeter.cc:29: undefined reference to `newp_usb_init_product@4'

C:\Users\yan.zhang\Desktop\TestCam_Project\Oct_Src\cc/PowerMeter.cc:30: undefined reference to `newp_usb_get_device_info@4'

PowerMeter.o: In function `Z4ReadiPciPm':

C:\Users\yan.zhang\Desktop\TestCam_Project\Oct_Src\cc/PowerMeter.cc:40: undefined reference to `newp_usb_get_ascii@16'

PowerMeter.o: In function `Z5WriteiPc':

C:\Users\yan.zhang\Desktop\TestCam_Project\Oct_Src\cc/PowerMeter.cc:66: undefined reference to `newp_usb_send_ascii@12'

collect2.exe: error: ld returned 1 exit status

warning: mkoctfile exited with failure status

warning: called from

    mkoctfile at line 171 column 5

----------------------------------------------------------------

 

The functions “newp_usb_uninit_system”, “newp_usb_init_product”, etc are already declared in the “NewpDll.h”, and they should be implemented in the usbdll.dll (I checked the dll file using “depends”, a program that can look into dll files). I don’t understand why I still got the above error messages.

 

I’m wondering if anyone in this list can help me fix this. The content of “PowerMeter.cc” and “newpdll.h” is as follows:

 

*****************************************

PowerMeter.cc

*****************************************

#include <octave/oct.h>

#include <windows.h>

#include <string.h>

#include <winuser.h>

#include "newpdll.h"

 

bool m_bOpen=false;

char szDevInfo[1024];

 

void CloseDevices()

{

   if (m_bOpen)

   {

     m_bOpen = false;

     try

      {newp_usb_uninit_system ();}

     catch (...) {}

   }

}

 

bool OpenDevices(int nProductID)

{

  if (m_bOpen) return true;

  try

   {

     m_bOpen = newp_usb_init_product (nProductID) == 0;

     if (m_bOpen && (newp_usb_get_device_info (&szDevInfo[0]) != 0)) CloseDevices ();

   }

  catch (...)  {CloseDevices ();}

  return m_bOpen;

}

 

int Read (int nDeviceID, char* lpBuffer, int nLength, unsigned long* lBytesRead)

{

  try

  {

    int nStatus = newp_usb_get_ascii (nDeviceID, lpBuffer, nLength, lBytesRead);

    int i = *lBytesRead;

    // Search from the end of the response string

    if (i==0) lpBuffer[0]=0;

    while (--i >= 0)

    {

                // If a linefeed is found

                if (lpBuffer[i] == '\n')

                {

                 // If a return is found

                  if (lpBuffer[i - 1] == '\r') i--;

                  *lBytesRead = i;

                  // Add a string terminator

                  lpBuffer[i] = 0; //(char) NULL;

                  break;

                }

    }

 

    return nStatus;

  }

  catch (...) {return -1;}

}

 

int Write (int nDeviceID, char* lpBuffer)

{

  try

    {return newp_usb_send_ascii (nDeviceID, lpBuffer, (unsigned long) strlen (lpBuffer));}

  catch (...)

    {return -1;}

}

 

DEFUN_DLD (PowerMeterConnect, args,,"Connect to Newport Powermeter via USB inteface")

{

   if (args.length()<1) error("Newport Product ID is missing");

 

   if (OpenDevices(args(0).int_value()))

   { 

    for (int i=0;i<1024;i++)

      if (szDevInfo[i]==13) {szDevInfo[i]=0;break;}

    charMatrix retval((char *) &szDevInfo[0]);

    return octave_value(retval);

   }

   else error("Cannot connect to Power Meter device");

   return octave_value(0);

}

 

DEFUN_DLD (PowerMeterWrite, args,,"Send command to Newport Powermeter via USB inteface")

{

   if (args.length()<2) error("Not enough parameters");

   int devID=args(0).int_value();

   const octave_base_value& data = args(1).get_rep();

 

   if (data.is_string() )

     {

       std::string s = data.string_value();      

       return octave_value((Write(devID,  &s[0])==0));      

     }

   else  error("Command must be a string");

   return octave_value_list();

}

 

DEFUN_DLD (PowerMeterRead, args,,"Read data from Newport Powermeter via USB inteface")

{

   if (args.length()<1) error("Device ID is missing");

   int devID=args(0).int_value();

   char buf[256]; buf[0]=0;

 

   unsigned long lBytesRead;

   if (Read (devID, &buf[0], 255,&lBytesRead)==0)

   buf[lBytesRead]=0;

  

   charMatrix retval(&buf[0]);

   return octave_value(retval);

}

 

DEFUN_DLD (PowerMeterDisconnect, args,,"Close connection to Pwer Meter")

{

  CloseDevices(); 

  return octave_value(1);

}

 

*****************************************

NewpDll.h (with comments deleted)

*****************************************

#ifndef __usbdll_h__

#define __usbdll_h__

 

#ifdef __cplusplus

extern "C"

{

#undef  EXPORT

#define EXPORT _stdcall

#else

#define EXPORT EXTERN_C _stdcall

#endif

 

#define USBDUPLICATEADDRESS 1          // More than one device on the bus has the same device ID

#define USBADDRESSNOTFOUND -2       // The device ID cannot be found among the open devices on the bus

#define USBINVALIDADDRESS -3              // The device ID is outside the valid range of 0 - 31

 

typedef void (__stdcall *DeviceStateChanged)(int handle, int nState);

extern DeviceStateChanged g_lpDeviceStateChangedCB;

 

long EXPORT newp_usb_init_system (void);

 

long EXPORT newp_usb_init_product (int nProductID);

 

long EXPORT newp_usb_open_devices (int nProductID, bool bUseUSBAddress, int* nNumDevices);

 

void EXPORT newp_usb_uninit_system (void);

 

long EXPORT newp_usb_event_init (int nProductID, DeviceStateChanged lpDeviceStateChangedCB);

 

long EXPORT newp_usb_event_assign_key (char* DeviceKey, int handle);

 

long EXPORT newp_usb_event_remove_key (char* DeviceKey);

 

long EXPORT newp_usb_event_get_attached_devices (char** ppDeviceKeys, int* pDeviceHandles);

 

long EXPORT newp_usb_event_get_key_from_handle (int handle, char* DeviceKey);

 

long EXPORT newp_usb_get_device_info (char* Buffer);

 

long EXPORT newp_usb_get_model_serial_keys (char** ppBuffer);

 

long EXPORT GetInstrumentList (int* arInstruments, int* arInstrumentsModel, int* arInstrumentsSN, int* nArraySize);

 

long EXPORT newp_usb_read_by_key (char* DeviceKey, char* Buffer, unsigned long Length, unsigned long* BytesRead);

 

long EXPORT newp_usb_get_ascii (long DeviceID, char* Buffer, unsigned long Length, unsigned long* BytesRead);

 

long EXPORT newp_usb_write_by_key (char* DeviceKey, char* Command, unsigned long Length);

 

long EXPORT newp_usb_send_ascii (long DeviceID, char* Command, unsigned long Length);

 

long EXPORT newp_usb_write_binary_by_key (char* DeviceKey, char* Command, unsigned long Length);

 

long EXPORT newp_usb_send_binary (long DeviceID, char* Command, unsigned long Length);

 

#ifdef __cplusplus

}

#endif

 

#endif //#ifndef __espdll_h__

 

 

Thanks a lot,

 

YanZ

 


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "undefined reference" error message when using mkoctfile to create oct file

Mike Miller-4
On Thu, Feb 16, 2017 at 10:45:03 -0800, Yan Zhang wrote:

> Hi Folks,
>
> I'm a new user of Octave and trying to make a oct file so that I can
> control a Newport Power Meter in my octave program. I have a c++ code
> file "PowerMeter.cc", and I also have a header file "NewpDll.h" and a
> dll file "usbdll.dll" which are obtained from Newport driver examples.
> When I tried to create the OCT file, I got the following messages:
>
> ----------------------------------------------------------------
> >> mkoctfile PowerMeter.cc -usbdll.dll
> PowerMeter.o: In function `Z12CloseDevicesv':
> C:\Users\yan.zhang\Desktop\TestCam_Project\Oct_Src\cc/PowerMeter.cc:19: undefined reference to `newp_usb_uninit_system@0'
> PowerMeter.o: In function `Z11OpenDevicesi':
> C:\Users\yan.zhang\Desktop\TestCam_Project\Oct_Src\cc/PowerMeter.cc:29: undefined reference to `newp_usb_init_product@4'
> C:\Users\yan.zhang\Desktop\TestCam_Project\Oct_Src\cc/PowerMeter.cc:30: undefined reference to `newp_usb_get_device_info@4'
> PowerMeter.o: In function `Z4ReadiPciPm':
> C:\Users\yan.zhang\Desktop\TestCam_Project\Oct_Src\cc/PowerMeter.cc:40: undefined reference to `newp_usb_get_ascii@16'
> PowerMeter.o: In function `Z5WriteiPc':
> C:\Users\yan.zhang\Desktop\TestCam_Project\Oct_Src\cc/PowerMeter.cc:66: undefined reference to `newp_usb_send_ascii@12'
> collect2.exe: error: ld returned 1 exit status
> warning: mkoctfile exited with failure status
> warning: called from
>     mkoctfile at line 171 column 5
> ----------------------------------------------------------------
>
> The functions "newp_usb_uninit_system", "newp_usb_init_product", etc
> are already declared in the "NewpDll.h", and they should be
> implemented in the usbdll.dll (I checked the dll file using "depends",
> a program that can look into dll files). I don't understand why I
> still got the above error messages.

I know very little about Windows programming, but isn't an import
library required as well as a dll? From what I do understand, the dll is
used at runtime, but an import library is required at build time to
resolve the symbols above. I think this library would typically be
called "usbdll.lib".

--
mike

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: "undefined reference" error message when using mkoctfile to create oct file

Yan Zhang
Hi Mike,

Thank you for the response. I also found out later about what you just said. I'll try convert the dll file to lib file then see how it works.

Thanks,

Yan

-----Original Message-----
From: Mike Miller [mailto:[hidden email]]
Sent: Friday, February 17, 2017 9:46 AM
To: Yan Zhang
Cc: [hidden email]
Subject: Re: "undefined reference" error message when using mkoctfile to create oct file

On Thu, Feb 16, 2017 at 10:45:03 -0800, Yan Zhang wrote:

> Hi Folks,
>
> I'm a new user of Octave and trying to make a oct file so that I can
> control a Newport Power Meter in my octave program. I have a c++ code
> file "PowerMeter.cc", and I also have a header file "NewpDll.h" and a
> dll file "usbdll.dll" which are obtained from Newport driver examples.
> When I tried to create the OCT file, I got the following messages:
>
> ----------------------------------------------------------------
> >> mkoctfile PowerMeter.cc -usbdll.dll
> PowerMeter.o: In function `Z12CloseDevicesv':
> C:\Users\yan.zhang\Desktop\TestCam_Project\Oct_Src\cc/PowerMeter.cc:19: undefined reference to `newp_usb_uninit_system@0'
> PowerMeter.o: In function `Z11OpenDevicesi':
> C:\Users\yan.zhang\Desktop\TestCam_Project\Oct_Src\cc/PowerMeter.cc:29: undefined reference to `newp_usb_init_product@4'
> C:\Users\yan.zhang\Desktop\TestCam_Project\Oct_Src\cc/PowerMeter.cc:30: undefined reference to `newp_usb_get_device_info@4'
> PowerMeter.o: In function `Z4ReadiPciPm':
> C:\Users\yan.zhang\Desktop\TestCam_Project\Oct_Src\cc/PowerMeter.cc:40: undefined reference to `newp_usb_get_ascii@16'
> PowerMeter.o: In function `Z5WriteiPc':
> C:\Users\yan.zhang\Desktop\TestCam_Project\Oct_Src\cc/PowerMeter.cc:66: undefined reference to `newp_usb_send_ascii@12'
> collect2.exe: error: ld returned 1 exit status
> warning: mkoctfile exited with failure status
> warning: called from
>     mkoctfile at line 171 column 5
> ----------------------------------------------------------------
>
> The functions "newp_usb_uninit_system", "newp_usb_init_product", etc
> are already declared in the "NewpDll.h", and they should be
> implemented in the usbdll.dll (I checked the dll file using "depends",
> a program that can look into dll files). I don't understand why I
> still got the above error messages.

I know very little about Windows programming, but isn't an import library required as well as a dll? From what I do understand, the dll is used at runtime, but an import library is required at build time to resolve the symbols above. I think this library would typically be called "usbdll.lib".

--
mike
_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "undefined reference" error message when using mkoctfile to create oct file

marco atzeri-2
On 17/02/2017 18:53, Yan Zhang wrote:
> Hi Mike,
>
> Thank you for the response. I also found out later about what you just said. I'll try convert the dll file to lib file then see how it works.
>
> Thanks,
>
> Yan

You can not convert it.
Together with the dll you should also have the equivalent
import library.





_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "undefined reference" error message when using mkoctfile to create oct file

Andreas Weber-6
Am 17.02.2017 um 19:03 schrieb Marco Atzeri:

> On 17/02/2017 18:53, Yan Zhang wrote:
>> Hi Mike,
>>
>> Thank you for the response. I also found out later about what you just
>> said. I'll try convert the dll file to lib file then see how it works.
>>
>> Thanks,
>>
>> Yan
>
> You can not convert it.
> Together with the dll you should also have the equivalent
> import library.

Borland Builder 6 had a tool "implib" which creates the import library
from a dll. And as far as I can see this tool makes the same:
http://www.digitalmars.com/ctg/implib.html

And he could use LoadLibrary/GetProcAddress only with the dll.

But, as you said, having the proper import lib would be the easiest.

-- Andy

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: "undefined reference" error message when using mkoctfile to create oct file

Yan Zhang
In reply to this post by marco atzeri-2
I found an article online written by Adrian Henke:
https://adrianhenke.wordpress.com/2008/12/05/create-lib-file-from-dll/
and created a lib file from the dll file. Then when I tried using the lib file, I got the following message:

----------------------------------------------------------------
>> mkoctfile PowerMeter.cc -l NewpDll.lib
c:/users/yan/downloads/octave-4.0.0_0/octave-4.0.0/bin/../lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -l-LC
:\Users\yan\Downloads\octave-4.0.0_0\octave-4.0.0\lib\octave\4.0.0
c:/users/yan/downloads/octave-4.0.0_0/octave-4.0.0/bin/../lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -loct
interp
c:/users/yan/downloads/octave-4.0.0_0/octave-4.0.0/bin/../lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -loct
ave
collect2.exe: error: ld returned 1 exit status
warning: mkoctfile exited with failure status
warning: called from
    mkoctfile at line 171 column 5
----------------------------------------------------------------

What does that mean and what should I do now?

Thanks,

Yan

-----Original Message-----
From: Help-octave [mailto:help-octave-bounces+yan=[hidden email]] On Behalf Of Marco Atzeri
Sent: Friday, February 17, 2017 10:04 AM
To: [hidden email]
Subject: Re: "undefined reference" error message when using mkoctfile to create oct file

On 17/02/2017 18:53, Yan Zhang wrote:
> Hi Mike,
>
> Thank you for the response. I also found out later about what you just said. I'll try convert the dll file to lib file then see how it works.
>
> Thanks,
>
> Yan

You can not convert it.
Together with the dll you should also have the equivalent import library.





_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "undefined reference" error message when using mkoctfile to create oct file

Andreas Weber-6
Am 17.02.2017 um 19:31 schrieb Yan Zhang:
> I found an article online written by Adrian Henke:
> https://adrianhenke.wordpress.com/2008/12/05/create-lib-file-from-dll/
> and created a lib file from the dll file. Then when I tried using the lib file, I got the following message:
>
> ----------------------------------------------------------------
>>> mkoctfile PowerMeter.cc -l NewpDll.lib

Where have you entered that command? In a windoze cmd or the shell which
is started from the octave directory octave-cmd.bat or .vbs (I don't use
windows).

-- Andy

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: "undefined reference" error message when using mkoctfile to create oct file

Yan Zhang
I first started a GUI window by running "octave.bat" under the octave-4.0.0 folder ( I'm using the non-installed version of octave), then I ran the command.

Thanks,

Yan Zhang | Sr. Product Characterization Engineer | OmniVision Technologies, Inc. | 4275 Burton Drive | Santa Clara, CA 95054
t: 408.567.4723 | email: [hidden email] | web: www.ovt.com

This e-mail and any attachments thereto may contain private, confidential, and privileged material for the sole use of the intended recipient. If you are not the intended recipient, any dissemination, distribution or copying is strictly prohibited. If you think that you have received this e-mail message in error, please contact the sender at OmniVision Technologies, Inc. immediately and permanently delete the original and any copies of this e-mail and any attachments thereto.


-----Original Message-----
From: Help-octave [mailto:help-octave-bounces+yan=[hidden email]] On Behalf Of Andreas Weber
Sent: Friday, February 17, 2017 11:03 AM
To: [hidden email]
Subject: Re: "undefined reference" error message when using mkoctfile to create oct file

Am 17.02.2017 um 19:31 schrieb Yan Zhang:
> I found an article online written by Adrian Henke:
> https://adrianhenke.wordpress.com/2008/12/05/create-lib-file-from-dll/
> and created a lib file from the dll file. Then when I tried using the lib file, I got the following message:
>
> ----------------------------------------------------------------
>>> mkoctfile PowerMeter.cc -l NewpDll.lib

Where have you entered that command? In a windoze cmd or the shell which is started from the octave directory octave-cmd.bat or .vbs (I don't use windows).

-- Andy

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: "undefined reference" error message when using mkoctfile to create oct file

tmacchant
In reply to this post by Yan Zhang
octave for windows is built by GCC.

Your linker option is perhaps wrong.

-l NewpDll.lib might be modified to

-lNewpDll

Tatsuro

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "undefined reference" error message when using mkoctfile to create oct file

Andreas Weber-6
In reply to this post by Yan Zhang
Am 17.02.2017 um 19:31 schrieb Yan Zhang:
>>> mkoctfile PowerMeter.cc -l NewpDll.lib

I guess the right call is
>> mkoctfile ("PowerMeter.cc", "-l NewpDll.lib")

Your command is equal to
>> mkoctfile ("PowerMeter.cc", "-l", "NewpDll.lib")

Note the difference...

-- Andy


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: "undefined reference" error message when using mkoctfile to create oct file

Yan Zhang
In reply to this post by tmacchant
Thank you for the help. I tried different formats of the mkoctfile command and here are the messages I got (please note that a file "NewpDll.lib" is in the same folder as PowerMeter.cc):

>> mkoctfile ("PowerMeter.cc", "-l NewpDll.lib")
c:/users/yan/downloads/octave-4.0.0_0/octave-4.0.0/bin/../lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -l Ne
wpDll.lib
collect2.exe: error: ld returned 1 exit status
warning: mkoctfile exited with failure status
warning: called from
    mkoctfile at line 171 column 5

>> mkoctfile PowerMeter.cc -lNewpDll
c:/users/yan/downloads/octave-4.0.0_0/octave-4.0.0/bin/../lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lNew
pDll
collect2.exe: error: ld returned 1 exit status
warning: mkoctfile exited with failure status
warning: called from
    mkoctfile at line 171 column 5

>> mkoctfile PowerMeter.cc -l NewpDll
mkoctfile: unrecognized argument NewpDll
warning: mkoctfile exited with failure status
warning: called from
    mkoctfile at line 171 column 5
Thanks,

Yan

-----Original Message-----
From: [hidden email] [mailto:[hidden email]]
Sent: Friday, February 17, 2017 6:55 PM
To: Yan Zhang; Marco Atzeri; [hidden email]
Subject: RE: "undefined reference" error message when using mkoctfile to create oct file

octave for windows is built by GCC.

Your linker option is perhaps wrong.

-l NewpDll.lib might be modified to

-lNewpDll

Tatsuro
_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: RE: "undefined reference" error message when using mkoctfile to create oct file

tmacchant
In reply to this post by Yan Zhang
You perhaps forget "-L." flag before specifying library.

Tatsuro

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "undefined reference" error message when using mkoctfile to create oct file

tmacchant
In reply to this post by Yan Zhang
----- Original Message -----

> From: Yan Zhang 
> To: "help-octave> Cc: 
> Date: 2017/2/19, Sun 07:40
> Subject: RE: "undefined reference" error message when using mkoctfile to create oct file
>
>T hank you for the help. I tried different formats of the mkoctfile command and
> here are the messages I got (please note that a file "NewpDll.lib" is
> in the same folder as PowerMeter.cc):
>
>>>  mkoctfile ("PowerMeter.cc", "-l NewpDll.lib")
> c:/users/yan/downloads/octave-4.0.0_0/octave-4.0.0/bin/../lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/bin/ld.exe:
> cannot find -l Ne
> wpDll.lib
> collect2.exe: error: ld returned 1 exit status
> warning: mkoctfile exited with failure status
> warning: called from
>     mkoctfile at line 171 column 5
>
>>>  mkoctfile PowerMeter.cc -lNewpDll
> c:/users/yan/downloads/octave-4.0.0_0/octave-4.0.0/bin/../lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/bin/ld.exe:
> cannot find -lNew
> pDll
> collect2.exe: error: ld returned 1 exit status
> warning: mkoctfile exited with failure status
> warning: called from
>     mkoctfile at line 171 column 5
>
>>>  mkoctfile PowerMeter.cc -l NewpDll
> mkoctfile: unrecognized argument NewpDll
> warning: mkoctfile exited with failure status
> warning: called from
>     mkoctfile at line 171 column 5
> Thanks,
>
> Yan
>
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]]
> Sent: Friday, February 17, 2017 6:55 PM
> To: Yan Zhang; Marco Atzeri; [hidden email]
> Subject: RE: "undefined reference" error message when using mkoctfile
> to create oct file
>
> octave for windows is built by GCC.
>
> Your linker option is perhaps wrong.
>
> -l NewpDll.lib might be modified to
>
> -lNewpDll
>
> Tatsuro



Is the below helpful for you?

http://www.mingw.org/wiki/specify_the_libraries_for_the_linker_to_use


If your libraries are located current directory, you have to specify it by 
"-L." (. means current directory)  before library flag -l(libname).

Tatsuro

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: "undefined reference" error message when using mkoctfile to create oct file

Yan Zhang
I tried adding the "-L" flag but still didn't get through. Here is what I got:

-------------------------------------------------------
>> mkoctfile PowerMeter.cc -L -l usbdll.lib
usbdll.lib: error adding symbols: File format not recognized
collect2.exe: error: ld returned 1 exit status
warning: mkoctfile exited with failure status
warning: called from
    mkoctfile at line 171 column 5
-------------------------------------------------------

I guess the "lib" file I created using Visual Studio 2015 is not recognized by mkoctfile.

Thanks,

Yan Zhang | Sr. Product Characterization Engineer | OmniVision Technologies, Inc. | 4275 Burton Drive | Santa Clara, CA 95054
t: 408.567.4723 | email: [hidden email] | web: www.ovt.com

This e-mail and any attachments thereto may contain private, confidential, and privileged material for the sole use of the intended recipient. If you are not the intended recipient, any dissemination, distribution or copying is strictly prohibited. If you think that you have received this e-mail message in error, please contact the sender at OmniVision Technologies, Inc. immediately and permanently delete the original and any copies of this e-mail and any attachments thereto.


-----Original Message-----
From: Tatsuro MATSUOKA [mailto:[hidden email]]
Sent: Sunday, February 19, 2017 3:42 PM
To: Yan Zhang; [hidden email]
Subject: Re: "undefined reference" error message when using mkoctfile to create oct file

----- Original Message -----

> From: Yan Zhang
> To: "help-octave> Cc:
> Date: 2017/2/19, Sun 07:40
> Subject: RE: "undefined reference" error message when using mkoctfile
> to create oct file
>
>T hank you for the help. I tried different formats of the mkoctfile
>command and  here are the messages I got (please note that a file
>"NewpDll.lib" is  in the same folder as PowerMeter.cc):
>
>>>  mkoctfile ("PowerMeter.cc", "-l NewpDll.lib")
> c:/users/yan/downloads/octave-4.0.0_0/octave-4.0.0/bin/../lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/bin/ld.exe:
> cannot find -l Ne
> wpDll.lib
> collect2.exe: error: ld returned 1 exit status
> warning: mkoctfile exited with failure status
> warning: called from
>     mkoctfile at line 171 column 5
>
>>>  mkoctfile PowerMeter.cc -lNewpDll
> c:/users/yan/downloads/octave-4.0.0_0/octave-4.0.0/bin/../lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/bin/ld.exe:
> cannot find -lNew
> pDll
> collect2.exe: error: ld returned 1 exit status
> warning: mkoctfile exited with failure status
> warning: called from
>     mkoctfile at line 171 column 5
>
>>>  mkoctfile PowerMeter.cc -l NewpDll
> mkoctfile: unrecognized argument NewpDll
> warning: mkoctfile exited with failure status
> warning: called from
>     mkoctfile at line 171 column 5
> Thanks,
>
> Yan
>
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]]
> Sent: Friday, February 17, 2017 6:55 PM
> To: Yan Zhang; Marco Atzeri; [hidden email]
> Subject: RE: "undefined reference" error message when using mkoctfile
> to create oct file
>
> octave for windows is built by GCC.
>
> Your linker option is perhaps wrong.
>
> -l NewpDll.lib might be modified to
>
> -lNewpDll
>
> Tatsuro



Is the below helpful for you?

http://www.mingw.org/wiki/specify_the_libraries_for_the_linker_to_use


If your libraries are located current directory, you have to specify it by "-L." (. means current directory)  before library flag -l(libname).

Tatsuro

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: RE: "undefined reference" error message when using mkoctfile to create oct file

tmacchant
In reply to this post by Yan Zhang
--- yan.zhang

> I tried adding the "-L" flag but still didn't get through. Here is what I got:
>
> -------------------------------------------------------
> >> mkoctfile PowerMeter.cc -L -l usbdll.lib
> usbdll.lib: error adding symbols: File format not recognized
> collect2.exe: error: ld returned 1 exit status
> warning: mkoctfile exited with failure status
> warning: called from
>     mkoctfile at line 171 column 5
> -------------------------------------------------------
>
> I guess the "lib" file I created using Visual Studio 2015 is not recognized by mkoctfile.
>
> Thanks,
>
> Yan Zhang | Sr. Product Characterization Engineer | OmniVision Technologies, Inc. | 4275 Burton Drive | Santa Clara, CA 95054
> t: 408.567.4723 | email: [hidden email] | web: www.ovt.com
>
> This e-mail and any attachments thereto may contain private, confidential, and privileged material for the sole use of the intended recipient. If you are not the intended recipient, any dissemination, distribution or copying is strictly prohibited. If you think that you have received this e-mail message in error, please contact the sender at OmniVision Technologies, Inc. immediately and permanently delete the original and any copies of this e-mail and any attachments thereto.
>
>
> -----Original Message-----
> From: Tatsuro MATSUOKA [mailto:[hidden email]]
> Sent: Sunday, February 19, 2017 3:42 PM
> To: Yan Zhang; [hidden email]
> Subject: Re: "undefined reference" error message when using mkoctfile to create oct file
>
> ----- Original Message -----
>
> > From: Yan Zhang
> > To: "help-octave> Cc:
> > Date: 2017/2/19, Sun 07:40
> > Subject: RE: "undefined reference" error message when using mkoctfile
> > to create oct file
> >
> >T hank you for the help. I tried different formats of the mkoctfile
> >command and  here are the messages I got (please note that a file
> >"NewpDll.lib" is  in the same folder as PowerMeter.cc):
> >
> >>>  mkoctfile ("PowerMeter.cc", "-l NewpDll.lib")
> > c:/users/yan/downloads/octave-4.0.0_0/octave-4.0.0/bin/../lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/bin/ld.exe:
> > cannot find -l Ne
> > wpDll.lib
> > collect2.exe: error: ld returned 1 exit status
> > warning: mkoctfile exited with failure status
> > warning: called from
> >     mkoctfile at line 171 column 5
> >
> >>>  mkoctfile PowerMeter.cc -lNewpDll
> > c:/users/yan/downloads/octave-4.0.0_0/octave-4.0.0/bin/../lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/bin/ld.exe:
> > cannot find -lNew
> > pDll
> > collect2.exe: error: ld returned 1 exit status
> > warning: mkoctfile exited with failure status
> > warning: called from
> >     mkoctfile at line 171 column 5
> >
> >>>  mkoctfile PowerMeter.cc -l NewpDll
> > mkoctfile: unrecognized argument NewpDll
> > warning: mkoctfile exited with failure status
> > warning: called from
> >     mkoctfile at line 171 column 5
> > Thanks,
> >
> > Yan
> >
> > -----Original Message-----
> > From: [hidden email] [mailto:[hidden email]]
> > Sent: Friday, February 17, 2017 6:55 PM
> > To: Yan Zhang; Marco Atzeri; [hidden email]
> > Subject: RE: "undefined reference" error message when using mkoctfile
> > to create oct file
> >
> > octave for windows is built by GCC.
> >
> > Your linker option is perhaps wrong.
> >
> > -l NewpDll.lib might be modified to
> >
> > -lNewpDll
> >
> > Tatsuro
>
>
>
> Is the below helpful for you?
>
> http://www.mingw.org/wiki/specify_the_libraries_for_the_linker_to_use
>
>
> If your libraries are located current directory, you have to specify it by "-L." (. means current directory)  before library flag -l(libname).
>
> Tatsuro
>
You forget to specify "." (period) to -L flag.  
"." indcates current directory.

Use not "-L" but "-L." as indcated before.

Tatsuro

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: RE: "undefined reference" error message when using mkoctfile to create oct file

tmacchant
In reply to this post by Yan Zhang


--- [hidden email] wrote:

> I tried adding the "-L" flag but still didn't get through. Here is what I got:
>
> -------------------------------------------------------
> >> mkoctfile PowerMeter.cc -L -l usbdll.lib
> usbdll.lib: error adding symbols: File format not recognized
> collect2.exe: error: ld returned 1 exit status
> warning: mkoctfile exited with failure status
> warning: called from
>     mkoctfile at line 171 column 5
> -------------------------------------------------------
>
> I guess the "lib" file I created using Visual Studio 2015 is not recognized by mkoctfile.
>
> Thanks,
>
> Yan Zhang | Sr. Product Characterization Engineer | OmniVision Technologies, Inc. | 4275 Burton Drive | Santa Clara, CA 95054
> t: 408.567.4723 | email: [hidden email] | web: www.ovt.com
>
> This e-mail and any attachments thereto may contain private, confidential, and privileged material for the sole use of the intended recipient. If you are not the intended recipient, any dissemination, distribution or copying is strictly prohibited. If you think that you have received this e-mail message in error, please contact the sender at OmniVision Technologies, Inc. immediately and permanently delete the original and any copies of this e-mail and any attachments thereto.
>
>
> -----Original Message-----
> From: Tatsuro MATSUOKA [mailto:[hidden email]]
> Sent: Sunday, February 19, 2017 3:42 PM
> To: Yan Zhang; [hidden email]
> Subject: Re: "undefined reference" error message when using mkoctfile to create oct file
>
> ----- Original Message -----
>
> > From: Yan Zhang
> > To: "help-octave> Cc:
> > Date: 2017/2/19, Sun 07:40
> > Subject: RE: "undefined reference" error message when using mkoctfile
> > to create oct file
> >
> >T hank you for the help. I tried different formats of the mkoctfile
> >command and  here are the messages I got (please note that a file
> >"NewpDll.lib" is  in the same folder as PowerMeter.cc):
> >
> >>>  mkoctfile ("PowerMeter.cc", "-l NewpDll.lib")
> > c:/users/yan/downloads/octave-4.0.0_0/octave-4.0.0/bin/../lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/bin/ld.exe:
> > cannot find -l Ne
> > wpDll.lib
> > collect2.exe: error: ld returned 1 exit status
> > warning: mkoctfile exited with failure status
> > warning: called from
> >     mkoctfile at line 171 column 5
> >
> >>>  mkoctfile PowerMeter.cc -lNewpDll
> > c:/users/yan/downloads/octave-4.0.0_0/octave-4.0.0/bin/../lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/bin/ld.exe:
> > cannot find -lNew
> > pDll
> > collect2.exe: error: ld returned 1 exit status
> > warning: mkoctfile exited with failure status
> > warning: called from
> >     mkoctfile at line 171 column 5
> >
> >>>  mkoctfile PowerMeter.cc -l NewpDll
> > mkoctfile: unrecognized argument NewpDll
> > warning: mkoctfile exited with failure status
> > warning: called from
> >     mkoctfile at line 171 column 5
> > Thanks,
> >
> > Yan
> >
> > -----Original Message-----
> > From: [hidden email] [mailto:[hidden email]]
> > Sent: Friday, February 17, 2017 6:55 PM
> > To: Yan Zhang; Marco Atzeri; [hidden email]
> > Subject: RE: "undefined reference" error message when using mkoctfile
> > to create oct file
> >
> > octave for windows is built by GCC.
> >
> > Your linker option is perhaps wrong.
> >
> > -l NewpDll.lib might be modified to
> >
> > -lNewpDll
> >
> > Tatsuro
>
>
>
> Is the below helpful for you?
>
> http://www.mingw.org/wiki/specify_the_libraries_for_the_linker_to_use
>
>
> If your libraries are located current directory, you have to specify it by "-L." (. means current directory)  before library flag -l(libname).
>
> Tatsuro
>

-l usbdll.lib is incorrect,

-lusbdll

Tatsuro

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: RE: "undefined reference" error message when using mkoctfile to create oct file

Yan Zhang
I tried the "-L." flag but got the same message:

---------------------------------------------
>> mkoctfile PowerMeter.cc -L. -lusbdll
./usbdll.lib: error adding symbols: File in wrong format
collect2.exe: error: ld returned 1 exit status
warning: mkoctfile exited with failure status
warning: called from
    mkoctfile at line 171 column 5
---------------------------------------------

Thanks,


-----Original Message-----
From: [hidden email] [mailto:[hidden email]]
Sent: Tuesday, February 21, 2017 10:57 AM
To: Yan ; [hidden email]
Subject: Re: RE: "undefined reference" error message when using mkoctfile to create oct file



--- [hidden email] wrote:

> I tried adding the "-L" flag but still didn't get through. Here is what I got:
>
> -------------------------------------------------------
> >> mkoctfile PowerMeter.cc -L -l usbdll.lib
> usbdll.lib: error adding symbols: File format not recognized
> collect2.exe: error: ld returned 1 exit status
> warning: mkoctfile exited with failure status
> warning: called from
>     mkoctfile at line 171 column 5
> -------------------------------------------------------
>
> I guess the "lib" file I created using Visual Studio 2015 is not recognized by mkoctfile.
>
> Thanks,
>
> Yan
>
>
> -----Original Message-----
> From: Tatsuro MATSUOKA [mailto:[hidden email]]
> Sent: Sunday, February 19, 2017 3:42 PM
> To: Yan ; [hidden email]
> Subject: Re: "undefined reference" error message when using mkoctfile
> to create oct file
>
> ----- Original Message -----
>
> > From: Yan
> > To: "help-octave> Cc:
> > Date: 2017/2/19, Sun 07:40
> > Subject: RE: "undefined reference" error message when using
> > mkoctfile to create oct file
> >
> >T hank you for the help. I tried different formats of the mkoctfile
> >command and  here are the messages I got (please note that a file
> >"NewpDll.lib" is  in the same folder as PowerMeter.cc):
> >
> >>>  mkoctfile ("PowerMeter.cc", "-l NewpDll.lib")
> > c:/users/yan/downloads/octave-4.0.0_0/octave-4.0.0/bin/../lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/bin/ld.exe:
> > cannot find -l Ne
> > wpDll.lib
> > collect2.exe: error: ld returned 1 exit status
> > warning: mkoctfile exited with failure status
> > warning: called from
> >     mkoctfile at line 171 column 5
> >
> >>>  mkoctfile PowerMeter.cc -lNewpDll
> > c:/users/yan/downloads/octave-4.0.0_0/octave-4.0.0/bin/../lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/bin/ld.exe:
> > cannot find -lNew
> > pDll
> > collect2.exe: error: ld returned 1 exit status
> > warning: mkoctfile exited with failure status
> > warning: called from
> >     mkoctfile at line 171 column 5
> >
> >>>  mkoctfile PowerMeter.cc -l NewpDll
> > mkoctfile: unrecognized argument NewpDll
> > warning: mkoctfile exited with failure status
> > warning: called from
> >     mkoctfile at line 171 column 5
> > Thanks,
> >
> > Yan
> >
> > -----Original Message-----
> > From: [hidden email] [mailto:[hidden email]]
> > Sent: Friday, February 17, 2017 6:55 PM
> > To: Yan ; Marco Atzeri; [hidden email]
> > Subject: RE: "undefined reference" error message when using
> > mkoctfile to create oct file
> >
> > octave for windows is built by GCC.
> >
> > Your linker option is perhaps wrong.
> >
> > -l NewpDll.lib might be modified to
> >
> > -lNewpDll
> >
> > Tatsuro
>
>
>
> Is the below helpful for you?
>
> http://www.mingw.org/wiki/specify_the_libraries_for_the_linker_to_use
>
>
> If your libraries are located current directory, you have to specify it by "-L." (. means current directory)  before library flag -l(libname).
>
> Tatsuro
>

-l usbdll.lib is incorrect,

-lusbdll

Tatsuro

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: RE: "undefined reference" error message when using mkoctfile to create oct file

tmacchant
----- Original Message -----

> From: Yan Zhang 
> To: "help-octave
> Cc:
> Date: 2017/2/22, Wed 07:21
> Subject: RE: RE: "undefined reference" error message when using mkoctfile to create oct file
>
> I tried the "-L." flag but got the same message:
>
> ---------------------------------------------
>>>  mkoctfile PowerMeter.cc -L. -lusbdll
> ./usbdll.lib: error adding symbols: File in wrong format
> collect2.exe: error: ld returned 1 exit status
> warning: mkoctfile exited with failure status
> warning: called from
>     mkoctfile at line 171 column 5
> ---------------------------------------------
>
>> I guess the "lib" file I created using Visual Studio 2015 is not 
> recognized by mkoctfile.


Sorry my confusion.

You probably made library file using MS Visual Studio related tool.
However, octave for window uses MinGW w64 GCC.

I have experienced to make library file for GCC from windows dll libraries.
I used  pexports and dlltool on MinGW.


***********************************
Tool preparation

dlltool is fortunately shipped with octave distribution but pexports is not shiped.
Therefore pexports should be downloaded.

https://sourceforge.net/projects/mingw/files/MinGW/Extension/pexports/pexports-0.47/pexports-0.47-mingw32-bin.tar.xz/download


The binary archivied in tar.xz
pexports-0.47-mingw32-bin.tar.xz


Therefore you need un-archive software which can handle tar.xz.
I use 7-zip application which can download from
http://www.7-zip.org/


extract pexport.exe (is located in bin folder in archived file)
copy it to the folder where target dll file is located or 
octave bin folder (typical location C:\octave\Octave-4.0.0\bin)
***********************************


***********************************
make library file for dll

* Start octave

* Octave prompt
>> cd <path to the folder where dll file located>
>> system bash

The you see the bash prompt
bash-3.1$

On bash prompt (please change xxx to your situation)
bash-3.1$  pexports xxx.dll > libxxx.def

bash-3.1$  dlltool -D xxx.dll -d libxxx.def -l libxxx.dll.a

Useally library file lib(name).dll.a is used for MinGW environments.

***********************************

Note that the above from my experience.
It is possible that you will not get successful result.

Tatsuro

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: RE: "undefined reference" error message when using mkoctfile to create oct file

Yan Zhang
Thanks a lot for the kind help. I tried the dlltool and pexports and successfully got a new lib file which I renamed as "usbdllnew.lib". Unfortunately, I still couldn't make it work. Following are the messages I got:


-----------------------------------------------------
>> mkoctfile PowerMeter.cc -L. -lusbdllnew
PowerMeter.o: In function `Z12CloseDevicesv':
C:\Users\yan\Desktop\TestCam_Project\Oct_Src\cc/PowerMeter.cc:20: undefined reference to `newp_usb_uninit_system@0'
PowerMeter.o: In function `Z11OpenDevicesi':
C:\Users\yan\Desktop\TestCam_Project\Oct_Src\cc/PowerMeter.cc:30: undefined reference to `newp_usb_init_product@4'
C:\Users\yan\Desktop\TestCam_Project\Oct_Src\cc/PowerMeter.cc:31: undefined reference to `newp_usb_get_device_info@4'
PowerMeter.o: In function `Z4ReadiPciPm':
C:\Users\yan\Desktop\TestCam_Project\Oct_Src\cc/PowerMeter.cc:41: undefined reference to `newp_usb_get_ascii@16'
PowerMeter.o: In function `Z5WriteiPc':
C:\Users\yan\Desktop\TestCam_Project\Oct_Src\cc/PowerMeter.cc:67: undefined reference to `newp_usb_send_ascii@12'
collect2.exe: error: ld returned 1 exit status
warning: mkoctfile exited with failure status
warning: called from
    mkoctfile at line 171 column 5
-----------------------------------------------------

-----------------------------------------------------
>> mkoctfile PowerMeter.cc -L. -l usbdllnew.lib
c:/users/yan/downloads/octave-4.0.0_0/octave-4.0.0/bin/../lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -l-LC
:\Users\yan\Downloads\octave-4.0.0_0\octave-4.0.0\lib\octave\4.0.0
c:/users/yan/downloads/octave-4.0.0_0/octave-4.0.0/bin/../lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -loct
interp
c:/users/yan/downloads/octave-4.0.0_0/octave-4.0.0/bin/../lib/gcc/i686-w64-mingw32/4.9.2/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -loct
ave
collect2.exe: error: ld returned 1 exit status
warning: mkoctfile exited with failure status
warning: called from
    mkoctfile at line 171 column 5
-----------------------------------------------------

Thanks,

Yan

-----Original Message-----
From: Tatsuro MATSUOKA [mailto:[hidden email]]
Sent: Tuesday, February 21, 2017 5:00 PM
To: Yan Zhang; [hidden email]
Subject: Re: RE: "undefined reference" error message when using mkoctfile to create oct file

----- Original Message -----

> From: Yan Zhang 
> To: "help-octave
> Cc:
> Date: 2017/2/22, Wed 07:21
> Subject: RE: RE: "undefined reference" error message when using mkoctfile to create oct file
>
> I tried the "-L." flag but got the same message:
>
> ---------------------------------------------
>>>  mkoctfile PowerMeter.cc -L. -lusbdll
> ./usbdll.lib: error adding symbols: File in wrong format
> collect2.exe: error: ld returned 1 exit status
> warning: mkoctfile exited with failure status
> warning: called from
>     mkoctfile at line 171 column 5
> ---------------------------------------------
>
>> I guess the "lib" file I created using Visual Studio 2015 is not 
> recognized by mkoctfile.


Sorry my confusion.

You probably made library file using MS Visual Studio related tool.
However, octave for window uses MinGW w64 GCC.

I have experienced to make library file for GCC from windows dll libraries.
I used  pexports and dlltool on MinGW.


***********************************
Tool preparation

dlltool is fortunately shipped with octave distribution but pexports is not shiped.
Therefore pexports should be downloaded.

https://sourceforge.net/projects/mingw/files/MinGW/Extension/pexports/pexports-0.47/pexports-0.47-mingw32-bin.tar.xz/download


The binary archivied in tar.xz
pexports-0.47-mingw32-bin.tar.xz


Therefore you need un-archive software which can handle tar.xz.
I use 7-zip application which can download from
http://www.7-zip.org/


extract pexport.exe (is located in bin folder in archived file)
copy it to the folder where target dll file is located or 
octave bin folder (typical location C:\octave\Octave-4.0.0\bin)
***********************************


***********************************
make library file for dll

* Start octave

* Octave prompt
>> cd <path to the folder where dll file located>
>> system bash

The you see the bash prompt
bash-3.1$

On bash prompt (please change xxx to your situation)
bash-3.1$  pexports xxx.dll > libxxx.def

bash-3.1$  dlltool -D xxx.dll -d libxxx.def -l libxxx.dll.a

Useally library file lib(name).dll.a is used for MinGW environments.

***********************************

Note that the above from my experience.
It is possible that you will not get successful result.

Tatsuro

_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: RE: "undefined reference" error message when using mkoctfile to create oct file

tmacchant




----- Original Message -----

> From: Yan Zhang 
> To: "help-octave
> Cc:
> Date: 2017/2/22, Wed 11:15
> Subject: RE: RE: "undefined reference" error message when using mkoctfile to create oct file
>
>T hanks a lot for the kind help. I tried the dlltool and pexports and
> successfully got a new lib file which I renamed as "usbdllnew.lib".
> Unfortunately, I still couldn't make it work. Following are the messages I
> got:
>
>
> -----------------------------------------------------
>>>  mkoctfile PowerMeter.cc -L. -lusbdllnew
> PowerMeter.o: In function `Z12CloseDevicesv':
> C:\Users\yan\Desktop\TestCam_Project\Oct_Src\cc/PowerMeter.cc:20:
> undefined reference to `newp_usb_uninit_system@0'
> PowerMeter.o: In function `Z11OpenDevicesi':
> C:\Users\yan\Desktop\TestCam_Project\Oct_Src\cc/PowerMeter.cc:30:
> undefined reference to `newp_usb_init_product@4'
> C:\Users\yan\Desktop\TestCam_Project\Oct_Src\cc/PowerMeter.cc:31:
> undefined reference to `newp_usb_get_device_info@4'
> PowerMeter.o: In function `Z4ReadiPciPm':
> C:\Users\yan\Desktop\TestCam_Project\Oct_Src\cc/PowerMeter.cc:41:
> undefined reference to `newp_usb_get_ascii@16'
> PowerMeter.o: In function `Z5WriteiPc':
> C:\Users\yan\Desktop\TestCam_Project\Oct_Src\cc/PowerMeter.cc:67:
> undefined reference to `newp_usb_send_ascii@12'
> collect2.exe: error: ld returned 1 exit status
> warning: mkoctfile exited with failure status
> warning: called from
>     mkoctfile at line 171 column 5
> -----------------------------------------------------
>
>
> Thanks,
>
> Yan


Mmmm

Seeing error messages for "undefined reference to" like 
undefined reference to `newp_usb_uninit_system@0'


Perhaps your problem is related @n (n is interger) symbol issue 
I googled and found the below 

Two possibilities. 

1. order of linker flag. Sometimes "undefined reference error" occur 
in wrong order of library option.
Adding '-v' option, one can  echo commands as they are executed.

>> mkoctfile -v PowerMeter.cc -L. -lusbdllnew

I do not see problems but I do not have enough knowledge to judge with confidence.

2. @n (n is number like @0) symbols problems for pexports.

https://sourceforge.net/p/mingw-w64/wiki2/gendef/
 However, unlike pexports, gendef scans and attempts to decode the dll file 
 to find out relevant details such as call convention used. It will try to 
 append the @n to symbols detected as using stdcall?.

Unfortunately gendef binary distributed with mingw-w64.

Download mingw-w64-v5.0.1.zip (source)

https://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/mingw-w64-v5.0.1.zip/download 

Place mingw-w64-v5.0.1.zip at your preferable folder


Using windows explorer, copy "gendef" in folder "mingw-w64-tools" in mingw-w64-v5.0.1.zip in to another folder.

Start octave
>> system bash

bash-3.1$ cd "(path to 'gendef' folder )"
bash-3.1$ ./configure

bash-3.1$ make


After "make", gendef.exe is generated at (path to 'gendef' folder ) and copy it to appropriate place.  

gendef - xxx.dll 
(Do not forget '-' option to output console)
You can see the symbol generated by gendef.

gendef - xxx.dll > xxx.def

You can generate def file.

Tatsuro


_______________________________________________
Help-octave mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-octave
12
Loading...