public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Problem linking with an import library (.lib) file:
       [not found] <70AE7462E7AD054C89DCBA45343D499A65860E12@CARSMAIL2.CARS.APS.ANL.GOV>
@ 2015-05-13 23:38 ` Mark Rivers
  2015-05-14 15:43   ` Mark Rivers
  0 siblings, 1 reply; 6+ messages in thread
From: Mark Rivers @ 2015-05-13 23:38 UTC (permalink / raw)
  To: 'cygwin@cygwin.com'

Folks,

I am having trouble linking with a normal Windows import library file when creating a DLL on Cygwin.  These same import libraries worked fine when creating static Cygwin executables with older versions of Cygwin.

The error is: "error adding symbols: File in wrong format".

This is an example of the error (I have reformatted the long g++ command onto multiple lines to make it more legible):

$ make
make -C O.cygwin-x86 -f ../Makefile TOP=../../.. \
    T_A=cygwin-x86 install
make[1]: Entering directory '/cygdrive/j/epics/devel/dxp/dxpApp/handelSrc/O.cygwin-x86'
g++ -o handel.dll -shared -Wl,--out-implib,handel.lib -L/cygdrive/j/epics/devel/dxp/lib/cygwin-x86 
    -L/cygdrive/h/epics/base-3.14.12.5/lib/cygwin-x86        -m32              
    xerxes.o xerxes_log.o md_log.o handel.o fdd.o psl.o handel_dbg.o handel_detchan.o handel_dyn_default.o 
    handel_dyn_detector.o handel_dyn_firmware.o handel_dyn_module.o handel_file.o handel_log.o handel_memdbg_win32.o 
    handel_run_control.o handel_run_params.o handel_sort.o handel_system.o handel_xerxes.o xia_assert.o xia_file.o 
    xia_mem.o xia_mem_point.o saturn.o saturn_psl.o xmap.o xmap_psl.o mercury.o mercury_psl.o xia_epp.o xia_plx.o 
    xia_usb.o xia_usb2.o md_win32.o    
    -lrecIoc -lsoftDevIoc -lmiscIoc -lrsrvIoc -ldbtoolsIoc -lasIoc -ldbIoc -lregistryIoc  -ldbStaticIoc -lca -lCom -lDLPORTIO -lPlxApi  -lsetupapi -lUser32 -lpthread    -lm
/cygdrive/j/epics/devel/dxp/lib/cygwin-x86/PlxApi.lib: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status
/corvette/usr/local/epics/base-3.14.12.5/configure/RULES_BUILD:300: recipe for target 'handel.dll' failed
make[1]: *** [handel.dll] Error 1
make[1]: Leaving directory '/cygdrive/j/epics/devel/dxp/dxpApp/handelSrc/O.cygwin-x86'
/corvette/usr/local/epics/base-3.14.12.5/configure/RULES_ARCHS:64: recipe for target 'install.cygwin-x86' failed
make: *** [install.cygwin-x86] Error 2

So it is complaining that the library PlxApi.lib is not in the correct format.  However, this is definitely a valid Windows import library file.

Thanks,
Mark Rivers


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: Problem linking with an import library (.lib) file:
  2015-05-13 23:38 ` Problem linking with an import library (.lib) file: Mark Rivers
@ 2015-05-14 15:43   ` Mark Rivers
  2015-05-15  0:47     ` JonY
  2015-05-15 20:50     ` Mark Rivers
  0 siblings, 2 replies; 6+ messages in thread
From: Mark Rivers @ 2015-05-14 15:43 UTC (permalink / raw)
  To: 'cygwin@cygwin.com'

Additional information:

- This is Cygwin 2.0.1, 32-bit on a Windows 7 64-bit machine.

The "file" utility claims it is an archive file:
$ file ../../lib/cygwin-x86/PlxApi.lib
../../lib/cygwin-x86/PlxApi.lib: current ar archive

The "nm" utility appears to interpret the file OK:

rivers@rivers-mobile2 /corvette/home/epics/devel/dxp/dxpApp/handelSrc
$ nm ../../lib/cygwin-x86/PlxApi.lib

PlxApi631.dll:
00000000 i .idata$2
00000000 i .idata$4
00000000 i .idata$5
00000000 i .idata$6
000420ff a @comp.id
00000000 I __IMPORT_DESCRIPTOR_PlxApi631
         U __NULL_IMPORT_DESCRIPTOR
         U ⌂PlxApi631_NULL_THUNK_DATA

PlxApi631.dll:
000420ff a @comp.id
00000000 I __NULL_IMPORT_DESCRIPTOR

PlxApi631.dll:
000420ff a @comp.id
00000000 I ⌂PlxApi631_NULL_THUNK_DATA

...

PlxApi631.dll:
00000000 I .idata$4
00000000 I .idata$5
00000000 I .idata$6
00000000 T .text
00000000 I __imp__PlxPci_VpdRead
         U __IMPORT_DESCRIPTOR_PlxApi631
00000000 T _PlxPci_VpdRead

PlxApi631.dll:
00000000 I .idata$4
00000000 I .idata$5
00000000 I .idata$6
00000000 T .text
00000000 I __imp__PlxPci_VpdWrite
         U __IMPORT_DESCRIPTOR_PlxApi631
00000000 T _PlxPci_VpdWrite

-----Original Message-----
From: Mark Rivers 
Sent: Wednesday, May 13, 2015 5:41 PM
To: 'cygwin@cygwin.com'
Subject: Problem linking with an import library (.lib) file: 

Folks,

I am having trouble linking with a normal Windows import library file when creating a DLL on Cygwin.  These same import libraries worked fine when creating static Cygwin executables with older versions of Cygwin.

The error is: “error adding symbols: File in wrong format”.

This is an example of the error (I have reformatted the long g++ command onto multiple lines to make it more legible):

$ make
make -C O.cygwin-x86 -f ../Makefile TOP=../../.. \
    T_A=cygwin-x86 install
make[1]: Entering directory '/cygdrive/j/epics/devel/dxp/dxpApp/handelSrc/O.cygwin-x86'
g++ -o handel.dll -shared -Wl,--out-implib,handel.lib -L/cygdrive/j/epics/devel/dxp/lib/cygwin-x86 
    -L/cygdrive/h/epics/base-3.14.12.5/lib/cygwin-x86        -m32              
    xerxes.o xerxes_log.o md_log.o handel.o fdd.o psl.o handel_dbg.o handel_detchan.o handel_dyn_default.o 
    handel_dyn_detector.o handel_dyn_firmware.o handel_dyn_module.o handel_file.o handel_log.o handel_memdbg_win32.o 
    handel_run_control.o handel_run_params.o handel_sort.o handel_system.o handel_xerxes.o xia_assert.o xia_file.o 
    xia_mem.o xia_mem_point.o saturn.o saturn_psl.o xmap.o xmap_psl.o mercury.o mercury_psl.o xia_epp.o xia_plx.o 
    xia_usb.o xia_usb2.o md_win32.o    
    -lrecIoc -lsoftDevIoc -lmiscIoc -lrsrvIoc -ldbtoolsIoc -lasIoc -ldbIoc -lregistryIoc  -ldbStaticIoc -lca -lCom -lDLPORTIO -lPlxApi  -lsetupapi -lUser32 -lpthread    -lm
/cygdrive/j/epics/devel/dxp/lib/cygwin-x86/PlxApi.lib: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status
/corvette/usr/local/epics/base-3.14.12.5/configure/RULES_BUILD:300: recipe for target 'handel.dll' failed
make[1]: *** [handel.dll] Error 1
make[1]: Leaving directory '/cygdrive/j/epics/devel/dxp/dxpApp/handelSrc/O.cygwin-x86'
/corvette/usr/local/epics/base-3.14.12.5/configure/RULES_ARCHS:64: recipe for target 'install.cygwin-x86' failed
make: *** [install.cygwin-x86] Error 2

So it is complaining that the library PlxApi.lib is not in the correct format.  However, this is definitely a valid Windows import library file.

Thanks,
Mark Rivers


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Problem linking with an import library (.lib) file:
  2015-05-14 15:43   ` Mark Rivers
@ 2015-05-15  0:47     ` JonY
  2015-05-15 20:50     ` Mark Rivers
  1 sibling, 0 replies; 6+ messages in thread
From: JonY @ 2015-05-15  0:47 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 423 bytes --]

On 5/14/2015 22:47, Mark Rivers wrote:
> Additional information:
> 
> - This is Cygwin 2.0.1, 32-bit on a Windows 7 64-bit machine.
> 
> The "file" utility claims it is an archive file:
> $ file ../../lib/cygwin-x86/PlxApi.lib
> ../../lib/cygwin-x86/PlxApi.lib: current ar archive


Try using gendef to generate a def file from the DLL and use dlltool to
generate an import library from the new def file.




[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: Problem linking with an import library (.lib) file:
  2015-05-14 15:43   ` Mark Rivers
  2015-05-15  0:47     ` JonY
@ 2015-05-15 20:50     ` Mark Rivers
  2015-05-16  4:58       ` JonY
  1 sibling, 1 reply; 6+ messages in thread
From: Mark Rivers @ 2015-05-15 20:50 UTC (permalink / raw)
  To: 'cygwin@cygwin.com'

Jon Y wrote:

> Try using gendef to generate a def file from the DLL and use dlltool to
> generate an import library from the new def file.

Unfortunately the dll is stripped, so this does not work:

$ nm plxapi631.dll
nm: plxapi631.dll: no symbols

I know that this specific .lib file has worked in the past to link with Cygwin.  Unfortunately it is quite difficult to "roll back" with Cygwin to figure out in which version it last worked.

Thanks,
Mark


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Problem linking with an import library (.lib) file:
  2015-05-15 20:50     ` Mark Rivers
@ 2015-05-16  4:58       ` JonY
  0 siblings, 0 replies; 6+ messages in thread
From: JonY @ 2015-05-16  4:58 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 638 bytes --]

On 5/16/2015 04:08, Mark Rivers wrote:
> Jon Y wrote:
> 
>> Try using gendef to generate a def file from the DLL and use dlltool to
>> generate an import library from the new def file.
> 
> Unfortunately the dll is stripped, so this does not work:
> 
> $ nm plxapi631.dll
> nm: plxapi631.dll: no symbols
> 
> I know that this specific .lib file has worked in the past to link with Cygwin.  Unfortunately it is quite difficult to "roll back" with Cygwin to figure out in which version it last worked.
> 

gendef should still be able to get a list of symbols, it works on
Windows system DLLs, it should work on yours.




[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Problem linking with an import library (.lib) file:
@ 2015-06-12 21:01 Laurent Tassan-Got
  0 siblings, 0 replies; 6+ messages in thread
From: Laurent Tassan-Got @ 2015-06-12 21:01 UTC (permalink / raw)
  To: cygwin


    I got the same problem as Mark Rivers, already reported with the 
same subject.

    I'm running cygwin 32-bits version 2.0.3 under Windows 7 64 bits

  I got from a hardware manufacturer a DLL N957lib.dll and the 
associated import library N957lib.lib

When I try to link a small test program with the command:
gcc -Wall -DWIN32 -I. -o tst tst.c ./N957lib.lib
I get the message:
"N957lib.lib: error adding symbols: Format de fichier non reconnu" (File 
in wrong format)

Now if I use the MingW compiler (either under cygwin or Msys):
i686-pc-mingw32-gcc -Wall -DWIN32 -I. -o tst tst.c ./N957lib.lib
everything is fine and the program (tst.exe) executes as expected,
for example printing error messages issued by the library.
But this doesn't help me because I need the full cygwin capabilities 
(X11, Lesstif)

The cygwin gcc version is 4.9.2, while the MingW one is 4.7.3, so that 
it seems
that there is a problem in decoding .lib libraries with the newest gcc 
versions.

I tried to bypass the problem by re-building the .lib from the dll by 
using pexports
and dlltool. I get a .lib with the right format, readable by gcc, but 
some references are still missing
at the link stage.

Any hint about the gcc (ld) decoding of .lib ?



-- 

             ************************************
             *   Laurent TASSAN-GOT             *
             *   IPN - Bat 102                  *
             *   Universite Paris-Sud           *
             *   91406 ORSAY Cedex (France)     *
             *   tel : 33  1 69 15 72 55        *
             *   fax : 33  1 69 15 45 07        *
             *   email : tassango@ipno.in2p3.fr *
             ************************************
             


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-06-12 21:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <70AE7462E7AD054C89DCBA45343D499A65860E12@CARSMAIL2.CARS.APS.ANL.GOV>
2015-05-13 23:38 ` Problem linking with an import library (.lib) file: Mark Rivers
2015-05-14 15:43   ` Mark Rivers
2015-05-15  0:47     ` JonY
2015-05-15 20:50     ` Mark Rivers
2015-05-16  4:58       ` JonY
2015-06-12 21:01 Laurent Tassan-Got

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).