NO

Author Topic: Newbie question concerning .dll and .lib files  (Read 4137 times)

munmark

  • Guest
Newbie question concerning .dll and .lib files
« on: August 20, 2010, 12:16:01 AM »
Dear all,

I have a dll file called libusb0.dll (see http://sourceforge.net/apps/trac/libusb-win32/wiki) and I want to use the routines in a simple C program. However, all references to said routines can not be resolved.
...
POLINK: error: Unresolved external symbol '_usb_bulk_write'.
POLINK: error: Unresolved external symbol '_usb_bulk_read'.
...
Initially I had generated a .lib file using polib; the resulting libusb0.lib file was copied to ...\PellesC\lib and added to the project options->linker->Library and object Files.

polib /out:libusb0.lib \windows\system32\libusb0.dll

At the moment I have no idea how to proceed. Can you give me some hints? Thanks a lot.

Kind regards

Markus

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Newbie question concerning .dll and .lib files
« Reply #1 on: August 20, 2010, 06:57:19 AM »
1. use that libusb.lib from lib\msvc folder
or
2. do this

>polib /MACHINE:X86 /out:libusb0.lib /def:libusb0.def

libusb0.def:
Code: [Select]
LIBRARY libusb0.dll
EXPORTS
usb_bulk_read
usb_bulk_setup_async
usb_bulk_write
usb_cancel_async
usb_claim_interface
usb_clear_halt
usb_close
usb_control_msg
usb_device
usb_find_busses
usb_find_devices
usb_free_async
usb_get_busses
usb_get_descriptor
usb_get_descriptor_by_endpoint
usb_get_string
usb_get_string_simple
usb_get_version
usb_init
usb_install_driver_np
usb_install_driver_np_rundll
usb_install_needs_restart_np
usb_install_service_np
usb_install_service_np_rundll
usb_interrupt_read
usb_interrupt_setup_async
usb_interrupt_write
usb_isochronous_setup_async
usb_open
usb_reap_async
usb_reap_async_nocancel
usb_release_interface
usb_reset
usb_resetep
usb_set_altinterface
usb_set_configuration
usb_set_debug
usb_strerror
usb_submit_async
usb_touch_inf_file_np
usb_touch_inf_file_np_rundll
usb_uninstall_service_np
usb_uninstall_service_np_rundll
« Last Edit: August 20, 2010, 07:29:54 AM by timovjl »
May the source be with you

munmark

  • Guest
Re: Newbie question concerning .dll and .lib files
« Reply #2 on: August 20, 2010, 09:28:17 PM »
Thanks a lot for your fast reply. I have used the following command; my .def file looks a little bit different.

Is the command o.k.? The original proposal resulted in an error message (could not find .def file ..)

C:\Program Files\PellesC\Bin>polib /MACHINE:X86 /out:libusb0.lib /makedef:libusb0.def \windows\system32\libusb0.dll

LIBRARY "libusb0.dll"
EXPORTS
"usb_bulk_read" ; libusb0.dll
"usb_bulk_setup_async" ; libusb0.dll
"usb_bulk_write" ; libusb0.dll
...


Is the def file o.k.?

Unfortunately, the polink error persists.

In which directories do I have to place the:

- libusb0.dll file

- libusb0.def file

- libusb0.lib file

Is there anything else that I have to do in order to inform the compiler/linker about these files? In particular: Waht do I have to do with the .def file?

Thanks once again for your kind support

Markus

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Newbie question concerning .dll and .lib files
« Reply #3 on: August 20, 2010, 10:20:50 PM »
If i test something like this i copy file.dll and file.lib to project folder.
Then i add in poide menu Project -> Project options.. -> Folders -> Libraries my project folder
and same to Includes.
I don't add any lib or include files to PellesC folders.
I like to keep PellesC folder as original state.

Quote
The original proposal resulted in an error message (could not find .def file ..)
Do this in folder where you put that libusb0.def (project folder ?)
Code: [Select]
"C:\Program Files\PellesC\Bin\polib.exe" /MACHINE:X86 /out:libusb0.lib /def:libusb0.def
libusb0.lib in attachment.
« Last Edit: August 21, 2010, 07:39:25 AM by timovjl »
May the source be with you