martin11_ar
asked on
link .lib files with gcc
I have to link a .lib file using gcc for PalmOS (m68k-palmos-gcc) but i think it is the same with gcc.
I don´t know how to link it so te compiler tells me udefined reference for all Procedures that exist in muy .lib file.
Do anyone know how to link a .lib file?
Thanks
I don´t know how to link it so te compiler tells me udefined reference for all Procedures that exist in muy .lib file.
Do anyone know how to link a .lib file?
Thanks
ASKER
ok , but i have a .lib library and the -l option is for .a libraries. The linker tells me that the file doesn´t exist, i think for that reason.
I read that exists an application to convert .lib files into .a files but i can´t find it
Do you know where can i download it (for windows)?
I read that exists an application to convert .lib files into .a files but i can´t find it
Do you know where can i download it (for windows)?
It might be as simple as renaming (copying) the .lib
file to a .dll.a name:
cp foo.lib foo.dll.a
Then using -lfoo will find it.
However - that still might not work, because gcc
uses slightly different symbols for stdcall functions.
Just try it - if it doesn't work then tell me WHAT doesn't
work (I want to see the actual errors) I'll add more
directions.
file to a .dll.a name:
cp foo.lib foo.dll.a
Then using -lfoo will find it.
However - that still might not work, because gcc
uses slightly different symbols for stdcall functions.
Just try it - if it doesn't work then tell me WHAT doesn't
work (I want to see the actual errors) I'll add more
directions.
ASKER
I tried:
m68k-palmos-gcc pruebascanner.cpp -l ScanMgr.dll.a
m68k-palmos-gcc pruebascanner.cpp -l ScanMgr
m68k-palmos-gcc pruebascanner.cpp -l "complete path\ScanMgr.dll.a"
m68k-palmos-gcc pruebascanner.cpp -l "complete path\ScanMgr"
In all cases the compiler says:
/prc-tools/H-i586-cygwin32 /m68k-palm os/bin/ld: cannot open -lScanMgr.dll.a: No such file o directory
where say ScanMgr.dll.a change for the correspondent -l file on command line
m68k-palmos-gcc pruebascanner.cpp -l ScanMgr.dll.a
m68k-palmos-gcc pruebascanner.cpp -l ScanMgr
m68k-palmos-gcc pruebascanner.cpp -l "complete path\ScanMgr.dll.a"
m68k-palmos-gcc pruebascanner.cpp -l "complete path\ScanMgr"
In all cases the compiler says:
/prc-tools/H-i586-cygwin32
where say ScanMgr.dll.a change for the correspondent -l file on command line
Assuming that ScanMgr.dll.a exists and is in fact
a copy of the .lib file and is readable and executable
(not sure if that is really needed actually), then you
should do the following:
m68k-palmos-gcc pruebascanner.cpp -L"complete path" -lScanMgr
This should look for ScanMgr.dll.a in "complete path".
Note that "complete path" is only a directory, it does not
include the name of the library of course.
a copy of the .lib file and is readable and executable
(not sure if that is really needed actually), then you
should do the following:
m68k-palmos-gcc pruebascanner.cpp -L"complete path" -lScanMgr
This should look for ScanMgr.dll.a in "complete path".
Note that "complete path" is only a directory, it does not
include the name of the library of course.
ASKER
Again in all cases the compiler says:
/prc-tools/H-i586-cygwin32 /m68k-palm os/bin/ld: cannot open -lScanMgr.dll.a: No such file o directory
I remember you that i´m compiling no Windows NT. I´m using m68k-palmos-gcc for windows which use cygwin.dll
It means that i don´t have readable and executable options for files.
/prc-tools/H-i586-cygwin32
I remember you that i´m compiling no Windows NT. I´m using m68k-palmos-gcc for windows which use cygwin.dll
It means that i don´t have readable and executable options for files.
What do you mean in _all_ cases? I just gave one command line.
Can you repeat (copy&paste) that command line along with
everything that is being output, when doing:
m68k-palmos-gcc pruebascanner.cpp -L"complete path" -lScanMgr -v
Note the added -v and fix the path of course. Also show me the
output of:
ls -l "complete path" /ScanMgr *
or whatever is the equivalent of that on windows NT. I want to see
with own eyes that that file actually exists at that place.
Can you repeat (copy&paste) that command line along with
everything that is being output, when doing:
m68k-palmos-gcc pruebascanner.cpp -L"complete path" -lScanMgr -v
Note the added -v and fix the path of course. Also show me the
output of:
ls -l "complete path" /ScanMgr *
or whatever is the equivalent of that on windows NT. I want to see
with own eyes that that file actually exists at that place.
ASKER
Ok, the command line:
C:\Archivos de programa\InfomercSA\FORMBY \bin>m68k- palmos-gcc pruebascanner.cpp
-L "c:\archivos de programa\infomercsa\formby \bin" -lScanmgr -v
Reading specs from /prc-tools/H-i586-cygwin32 /lib/gcc-l ib/m68k-pa lmos/2.95. 2-kgp
d/specs
gcc version 2.95.2-kgpd 19991024 (release)
/prc-tools/H-i586-cygwin32 /lib/gcc-l ib/m68k-pa lmos/2.95. 2-kgpd/cpp .exe -lang-c+
+ -v -D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=95 -D__cplusplus -Dm68000 -Dmc68
000 -Dm68k -D__palmos__ -D__m68000__ -D__mc68000__ -D__m68k__ -D__palmos__ -D__m
68000 -D__mc68000 -D__m68k -Asystem(palmos) -Acpu(m68k) -Amachine(pilot) -D__EXC
EPTIONS -Dmc68000 -D__mc68000 -D__mc68000__ -isystem /PalmDev/include -isystem /
PalmDev/sdk/include/Core/S ystem -isystem /PalmDev/sdk/include/Core/ UI -isystem /
PalmDev/sdk/include -isystem /PalmDev/sdk/include/Core -isystem /PalmDev/sdk/inc
lude/Core/Hardware -isystem /PalmDev/sdk/include/Core/ System/Uni x -remap pruebas
canner.cpp C:\TEMP/cctODilx.ii
GNU CPP version 2.95.2-kgpd 19991024 (release) (68k, Motorola syntax)
#include "..." search starts here:
#include <...> search starts here:
/PalmDev/include
/PalmDev/sdk/include/Core/ System
/PalmDev/sdk/include/Core/ UI
/PalmDev/sdk/include
/PalmDev/sdk/include/Core
/PalmDev/sdk/include/Core/ Hardware
/PalmDev/sdk/include/Core/ System/Uni x
/prc-tools/H-i586-cygwin32 /lib/gcc-l ib/m68k-pa lmos/2.95. 2-kgpd/inc lude
/prc-tools/H-i586-cygwin32 /lib/gcc-l ib/m68k-pa lmos/2.95. 2-kgpd/../ ../../../m 68k
-palmos/include
End of search list.
The following default directories have been omitted from the search path:
/prc-tools/H-i586-cygwin32 /lib/gcc-l ib/m68k-pa lmos/2.95. 2-kgpd/../ ../../../. ./i
nclude/g++-3
/prc-tools/H-i586-cygwin32 /lib/gcc-l ib/m68k-pa lmos/2.95. 2-kgpd/../ ../../../m 68k
-palmos/sys-include
End of omitted list.
/prc-tools/H-i586-cygwin32 /lib/gcc-l ib/m68k-pa lmos/2.95. 2-kgpd/cc1 plus.exe C:\T
EMP/cctODilx.ii -fpic -msoft-float -m68000 -Wno-multichar -quiet -dumpbase prueb
ascanner.cc -version -o C:\TEMP/ccfbjRHC.s
GNU C++ version 2.95.2-kgpd 19991024 (release) (m68k-palmos) compiled by GNU C v
ersion egcs-2.91.57 19980901 (egcs-1.1 release).
/prc-tools/H-i586-cygwin32 /m68k-palm os/bin/as. exe -mno-68881 -m68000 -l -o C:\T
EMP/cctYOHdw.o C:\TEMP/ccfbjRHC.s
/prc-tools/H-i586-cygwin32 /lib/gcc-l ib/m68k-pa lmos/2.95. 2-kgpd/col lect2.exe -L/
PalmDev/lib/m68k-palmos-co ff -L/PalmDev/sdk/lib/m68k-pa lmos-coff --embedded-relo
cs -N -dy -T /prc-tools/H-i586-cygwin32 /lib/gcc-l ib/m68k-pa lmos/2.95. 2-kgpd/pil o
t.ld /prc-tools/H-i586-cygwin32 /m68k-palm os/lib/crt 0.o -L c:\archivos de program
a\infomercsa\formby\bin -L/prc-tools/H-i586-cygwin 32/lib/gcc -lib/m68k- palmos/2.9
5.2-kgpd -L/prc-tools/H-i586-cygwin 32/m68k-pa lmos/lib C:\TEMP/cctYOHdw.o -lScanm
gr -lcrt -lgcc -lc -lcrt -lgcc
C:\TEMP/cctYOHdw.o(.text+0 x1420):pru ebascanner .cpp: undefined reference to `ScanIsPalmSymbolUnit(void )'
C:\TEMP/cctYOHdw.o(.text+0 x142a):pru ebascanner .cpp: undefined reference to `ScanOpenDecoder(void)'
C:\TEMP/cctYOHdw.o(.text+0 x1432):pru ebascanner .cpp: undefined reference to `ScanCmdScanEnable(void)'
C:\TEMP/cctYOHdw.o(.text+0 x143a):pru ebascanner .cpp: undefined reference to `ScanSetTriggeringModes(un signed short)'
C:\TEMP/cctYOHdw.o(.text+0 x1448):pru ebascanner .cpp: undefined reference to `ScanSetBarcodeEnabled(tag BarType, unsigned char)'
C:\TEMP/cctYOHdw.o(.text+0 x1456):pru ebascanner .cpp: undefined reference to `ScanSetBarcodeEnabled(tag BarType, unsigned char)'
C:\TEMP/cctYOHdw.o(.text+0 x1464):pru ebascanner .cpp: undefined reference to `ScanSetBarcodeEnabled(tag BarType, unsigned char)'
C:\TEMP/cctYOHdw.o(.text+0 x1472):pru ebascanner .cpp: undefined reference to `ScanSetBarcodeEnabled(tag BarType, unsigned char)'
C:\TEMP/cctYOHdw.o(.text+0 x1480):pru ebascanner .cpp: undefined reference to `ScanSetBarcodeEnabled(tag BarType, unsigned char)'
C:\TEMP/cctYOHdw.o(.text+0 x148e):pru ebascanner .cpp: more undefined references to
`ScanSetBarcodeEnabled(tag BarType, unsigned char)' follow
C:\TEMP/cctYOHdw.o(.text+0 x14a4):pru ebascanner .cpp: undefined reference to `ScanCmdSendParams(tagBeep Type)'
C:\TEMP/cctYOHdw.o(.text+0 x14b8):pru ebascanner .cpp: undefined reference to `ScanGetDecodedData(tagMES SAGE *)'
C:\TEMP/cctYOHdw.o(.text+0 x15ec):pru ebascanner .cpp: undefined reference to `ScanCmdScanDisable(void)'
C:\TEMP/cctYOHdw.o(.text+0 x15f0):pru ebascanner .cpp: undefined reference to `ScanCloseDecoder(void)'
collect2: ld returned 1 exit status
Equivalent to ls on Windows NT
C:\Archivos de programa\InfomercSA\FORMBY \bin>dir Scanmgr*
El volumen de la unidad C no tiene etiqueta.
El número de serie del volumen es: 3B46-1AED
Directorio de C:\Archivos de programa\InfomercSA\FORMBY \bin
01/10/04 15.46 7.930 ScanMgr.h
01/10/04 15.45 10.528 ScanMgrDef.h
01/10/04 15.46 2.904 ScanMgrStruct.h
17/03/99 13.53 12.508 ScanMgr.lib
17/03/99 13.53 12.508 ScanMgr.dll.a
5 archivos 46.378 bytes
70.877.184 bytes libres
C:\Archivos de programa\InfomercSA\FORMBY
-L "c:\archivos de programa\infomercsa\formby
Reading specs from /prc-tools/H-i586-cygwin32
d/specs
gcc version 2.95.2-kgpd 19991024 (release)
/prc-tools/H-i586-cygwin32
+ -v -D__GNUC__=2 -D__GNUG__=2 -D__GNUC_MINOR__=95 -D__cplusplus -Dm68000 -Dmc68
000 -Dm68k -D__palmos__ -D__m68000__ -D__mc68000__ -D__m68k__ -D__palmos__ -D__m
68000 -D__mc68000 -D__m68k -Asystem(palmos) -Acpu(m68k) -Amachine(pilot) -D__EXC
EPTIONS -Dmc68000 -D__mc68000 -D__mc68000__ -isystem /PalmDev/include -isystem /
PalmDev/sdk/include/Core/S
PalmDev/sdk/include -isystem /PalmDev/sdk/include/Core -isystem /PalmDev/sdk/inc
lude/Core/Hardware -isystem /PalmDev/sdk/include/Core/
canner.cpp C:\TEMP/cctODilx.ii
GNU CPP version 2.95.2-kgpd 19991024 (release) (68k, Motorola syntax)
#include "..." search starts here:
#include <...> search starts here:
/PalmDev/include
/PalmDev/sdk/include/Core/
/PalmDev/sdk/include/Core/
/PalmDev/sdk/include
/PalmDev/sdk/include/Core
/PalmDev/sdk/include/Core/
/PalmDev/sdk/include/Core/
/prc-tools/H-i586-cygwin32
/prc-tools/H-i586-cygwin32
-palmos/include
End of search list.
The following default directories have been omitted from the search path:
/prc-tools/H-i586-cygwin32
nclude/g++-3
/prc-tools/H-i586-cygwin32
-palmos/sys-include
End of omitted list.
/prc-tools/H-i586-cygwin32
EMP/cctODilx.ii -fpic -msoft-float -m68000 -Wno-multichar -quiet -dumpbase prueb
ascanner.cc -version -o C:\TEMP/ccfbjRHC.s
GNU C++ version 2.95.2-kgpd 19991024 (release) (m68k-palmos) compiled by GNU C v
ersion egcs-2.91.57 19980901 (egcs-1.1 release).
/prc-tools/H-i586-cygwin32
EMP/cctYOHdw.o C:\TEMP/ccfbjRHC.s
/prc-tools/H-i586-cygwin32
PalmDev/lib/m68k-palmos-co
cs -N -dy -T /prc-tools/H-i586-cygwin32
t.ld /prc-tools/H-i586-cygwin32
a\infomercsa\formby\bin -L/prc-tools/H-i586-cygwin
5.2-kgpd -L/prc-tools/H-i586-cygwin
gr -lcrt -lgcc -lc -lcrt -lgcc
C:\TEMP/cctYOHdw.o(.text+0
C:\TEMP/cctYOHdw.o(.text+0
C:\TEMP/cctYOHdw.o(.text+0
C:\TEMP/cctYOHdw.o(.text+0
C:\TEMP/cctYOHdw.o(.text+0
C:\TEMP/cctYOHdw.o(.text+0
C:\TEMP/cctYOHdw.o(.text+0
C:\TEMP/cctYOHdw.o(.text+0
C:\TEMP/cctYOHdw.o(.text+0
C:\TEMP/cctYOHdw.o(.text+0
`ScanSetBarcodeEnabled(tag
C:\TEMP/cctYOHdw.o(.text+0
C:\TEMP/cctYOHdw.o(.text+0
C:\TEMP/cctYOHdw.o(.text+0
C:\TEMP/cctYOHdw.o(.text+0
collect2: ld returned 1 exit status
Equivalent to ls on Windows NT
C:\Archivos de programa\InfomercSA\FORMBY
El volumen de la unidad C no tiene etiqueta.
El número de serie del volumen es: 3B46-1AED
Directorio de C:\Archivos de programa\InfomercSA\FORMBY
01/10/04 15.46 7.930 ScanMgr.h
01/10/04 15.45 10.528 ScanMgrDef.h
01/10/04 15.46 2.904 ScanMgrStruct.h
17/03/99 13.53 12.508 ScanMgr.lib
17/03/99 13.53 12.508 ScanMgr.dll.a
5 archivos 46.378 bytes
70.877.184 bytes libres
ASKER
Can you help me?
I did:
m68k-palmos-gcc pruebascanner.cpp -L"complete path" -lScanMgr -v
And i wrote the output
I did:
m68k-palmos-gcc pruebascanner.cpp -L"complete path" -lScanMgr -v
And i wrote the output
A few observations:
1) You didn't get
/prc-tools/H-i586-cygwin32 /m68k-palm os/bin/ld: cannot open -lScanMgr.dll.a: No such file o directory
Like you said in your post of 10/07/2004 05:30PM CEST. Instead I see that the error is:
C:\TEMP/cctYOHdw.o(.text+0 x1420):pru ebascanner .cpp: undefined reference to `ScanIsPalmSymbolUnit(void )'
2) The final linker uses:
-L c:\archivos de programa\infomercsa\formby \bin
-L/prc-tools/H-i586-cygwin 32/lib/gcc -lib/m68k- palmos/2.9 5.2-kgpd
-L/prc-tools/H-i586-cygwin 32/m68k-pa lmos/lib
Apparently in one of those directories it finds the library(?).
The only directory that makes sense to every find it however is
c:\archivos de programa\infomercsa\formby \bin
(Ugh, I hate that confusing lower/upper case mixup), which you listed:
Directorio de C:\Archivos de programa\InfomercSA\FORMBY \bin
01/10/04 15.46 7.930 ScanMgr.h
01/10/04 15.45 10.528 ScanMgrDef.h
01/10/04 15.46 2.904 ScanMgrStruct.h
17/03/99 13.53 12.508 ScanMgr.lib
17/03/99 13.53 12.508 ScanMgr.dll.a
5 archivos 46.378 bytes
70.877.184 bytes
Try removing ScanMgr.lib there, just to be sure.
And try renaming ScanMgr.dll.a to libScanMgr.dll.a
Make sure that have gotten rid of the error
"-lScanMgr.dll.a: No such file o directory"
and instead get a
"undefined reference to ..."
that is progress. Make sure you get that progress
because it files the *ScanMgr* file in
C:\Archivos de programa\InfomercSA\FORMBY \bin
by removing it and adding it again, so that you are
sure that that files causes the improvement: then you
are sure that at least it is found and used.
1) You didn't get
/prc-tools/H-i586-cygwin32
Like you said in your post of 10/07/2004 05:30PM CEST. Instead I see that the error is:
C:\TEMP/cctYOHdw.o(.text+0
2) The final linker uses:
-L c:\archivos de programa\infomercsa\formby
-L/prc-tools/H-i586-cygwin
-L/prc-tools/H-i586-cygwin
Apparently in one of those directories it finds the library(?).
The only directory that makes sense to every find it however is
c:\archivos de programa\infomercsa\formby
(Ugh, I hate that confusing lower/upper case mixup), which you listed:
Directorio de C:\Archivos de programa\InfomercSA\FORMBY
01/10/04 15.46 7.930 ScanMgr.h
01/10/04 15.45 10.528 ScanMgrDef.h
01/10/04 15.46 2.904 ScanMgrStruct.h
17/03/99 13.53 12.508 ScanMgr.lib
17/03/99 13.53 12.508 ScanMgr.dll.a
5 archivos 46.378 bytes
70.877.184 bytes
Try removing ScanMgr.lib there, just to be sure.
And try renaming ScanMgr.dll.a to libScanMgr.dll.a
Make sure that have gotten rid of the error
"-lScanMgr.dll.a: No such file o directory"
and instead get a
"undefined reference to ..."
that is progress. Make sure you get that progress
because it files the *ScanMgr* file in
C:\Archivos de programa\InfomercSA\FORMBY
by removing it and adding it again, so that you are
sure that that files causes the improvement: then you
are sure that at least it is found and used.
Replace that last alinea with this:
Make sure that you have gotten rid of the error
"-lScanMgr: No such file or directory"
and instead get _only_
"undefined reference to ..."
error. That would be progress. Make sure you get rid of
the former error because it finds the *ScanMgr* file in
C:\Archivos de programa\InfomercSA\FORMBY \bin
,by removing the libScanMgr.dll.a file and adding it again,
and observing the change in the eror, so that you are
sure that it is that file that causes the improvement: then you
are sure that at least it is found and used. After that
we can tackle the undefined symbols...
Make sure that you have gotten rid of the error
"-lScanMgr: No such file or directory"
and instead get _only_
"undefined reference to ..."
error. That would be progress. Make sure you get rid of
the former error because it finds the *ScanMgr* file in
C:\Archivos de programa\InfomercSA\FORMBY
,by removing the libScanMgr.dll.a file and adding it again,
and observing the change in the eror, so that you are
sure that it is that file that causes the improvement: then you
are sure that at least it is found and used. After that
we can tackle the undefined symbols...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
as "-lm" for the math library
check
http://vergil.chemistry.gatech.edu/resources/programming/c-tutorial/libraries.html
excerpts
# When linking your program to the libraries, make sure you specify where the library can be found:
gcc -o foo -L. -lmylib foo.o
The -L. piece tells gcc to look in the current directory in addition to the other library directories for finding libmylib.a.