Página 1 de 1

Erro linkedição com HB_ZIP

Enviado: 08 Mai 2012 15:25
por viniciuspc
Olá Forum,

Já faz alguns anos (desde de 2007) que não uso o xHarbour, naquela epoca havia um concenso que era melhor utilizar o xHarbour ao Harbour, mas hoje vejo que a mesa virou. então resolvi re-converter um sistema em Clipper 5.2 para Harbour 3.0/MSVC. já eliminei muitos erros, mas não consigo compilar o meu aplicativo com as funções : HB_ZIPFILE, hb_GetFilesInZip e hb_unzipfile. estão com erro na linkedição.

Para exemplificar melhor, eu alterei o version.prg que esta em c:\hb30\tests, e inclui 2 funções com as chamadas acima, criei um version.hbp para utilizar o hbmk2.

arquivo version.hbp

Código: Selecionar todos

-std
-oversion.exe
-iC:\ARQUIV~1\MICROS~1.0\VC\include
-LC:\ARQUIV~1\MI2578~1\Windows\v6.0A\Lib\
-LC:\ARQUIV~1\MICROS~1.0\VC\LIB\
-LC:\hb30\lib\win\msvc
-comp=msvc
version.prg
arquivo version.prg

Código: Selecionar todos

PROCEDURE Main()

   outstd( chr( 34 ) + version() + chr( 34 ) + hb_eol() )
   outstd( chr( 34 ) + hb_compiler() + chr( 34 ) + hb_eol() )
   outstd( chr( 34 ) + os() + chr( 34 ) + hb_eol() )

   RETURN


FUNC FCOMPRESS(cFONTE , cDESTI)
HB_ZIPFILE( cDESTI, cFONTE, 9,  )
Return .t.

FUNC FDCOMPRESS(cFONTE, cDESTI)
LOCAL aExtract
aExtract := hb_GetFilesInZip(cFonte)
hb_unzipfile(cFONTE, , , , '.\' , aExtract ,  )
Return .t.
Os erros apresentados na linkedição são :

Código: Selecionar todos

version.obj : error LNK2001: unresolved external symbol _HB_FUN_HB_UNZIPFILE
version.obj : error LNK2001: unresolved external symbol _HB_FUN_HB_GETFILESINZIP
version.obj : error LNK2001: unresolved external symbol _HB_FUN_HB_ZIPFILE
version.exe : fatal error LNK1120: 3 unresolved externals
hbmk2: Error: Running linker. 1120
se retirar as funçoes, ele passa com o resultado sem erros! com o resultado abaixo na tela :

Código: Selecionar todos

"Harbour 3.0.0 (Rev. 16951)"
"Microsoft Visual C++ 16.0.40219 (32-bit)"
"Windows XP 5.1.2600 Service Pack 3"
já alterei o hbp incluindo -lC:\hb30\lib\win\msvc\hbzlib.lib mas não adiantou...

se alguem já passou por algum problema assim e puder me dar uma luz, eu agradeço! :)Pos

[]´s

Erro linkedição com HB_ZIP

Enviado: 08 Mai 2012 15:52
por alxsts
Olá!

Pode ser bug do próprio xHarbour.

Verifique se está usando a versão mais atual. Se não estiver, atualize para ela.

Erro linkedição com HB_ZIP

Enviado: 08 Mai 2012 16:10
por viniciuspc
Salve Alexandre!

Estou utilizando o Harbour e não o xHarbour...

Utilizei outra Maquina com Win7, baixei o Harbour novamente (http://sourceforge.net/projects/harbour ... ows/3.0.0/) e utilizei o BCC5.

Configurei o path, e o problema foi o mesmo (claro que a mensagem de erro no BCC5 é um pouco diferente...)

[]´s

Erro linkedição com HB_ZIP

Enviado: 08 Mai 2012 18:29
por alxsts
Olá Vinicius!

Desculpe-me pela confusão.

Certamente está faltando alguma Lib mas, não saberia te dizer onde ficam essas funções.

Vamos aguardar a opinião de algum colega que entenda melhor este erro.

Erro linkedição com HB_ZIP

Enviado: 08 Mai 2012 21:25
por viniciuspc
Sem problemas Alexandre!

Vc usa o xHarbour? Nele funciona sem problemas?

[]'s

Erro linkedição com HB_ZIP

Enviado: 08 Mai 2012 21:32
por rochinha
Amiguinho,

Para saber se uma função esta dentro de uma biblioteca, é claro que vai zer casativo, mas voce pode usar o Lib Explorer para isto.

Faça o download de hbZIPlibs.rar onde coloquei duas bibliotecas para Harbour que talvez te ajudem.

Erro linkedição com HB_ZIP

Enviado: 08 Mai 2012 21:34
por Pablo César
Em MiniGUI compila-se com esta opções:

call ..\..\..\batch\compile.bat demo2 /l hbziparc /l hbmzip /l minizip /l hbzlib
(veja exemplo C:\MiniGUI\SAMPLES\BASIC\Zip\demo2.prg)

call ..\..\..\batch\compile.bat demo %1 /l hbmzip /l minizip /l hbzlib
(veja exemplo C:\MiniGUI\SAMPLES\BASIC\Zip_3\demo.prg)

Erro linkedição com HB_ZIP

Enviado: 09 Mai 2012 11:36
por viniciuspc
Obrigado pessoal,

Não gostaria de utilizar outras bibliotecas, por isto que estou insistindo no HB3.0, pois estou querendo utilizar apenas o modo console no momento.

então o Lib Explorer me indicou o caminho, que seria utilizar as bibliotecas hbmzip.lib e minizip.lib que se encontram em C:\hb30\lib\win\msvc\ (para o caso do MSVC é claro)

encontrei um fonte legal em http://www.mail-archive.com/harbour@har ... 04839.html

Código: Selecionar todos

#define MZIP_BUFFER_READ 1024

/*
   HB_ZIPFILE( <cFile>,
               <cFileToCompress> | <aFilesToCompress>,
               [<nLevel>],
               [<bUpdate>],
               [<lOverWrite>],
               [<cPassword>],
               [<lWithPath>],
               [<lWithDrive>],
               [<bFileUpdate>] ) --> lCompress

   This function creates a zip file named <cFile>. If the extension
   is omitted, .ZIP will be assumed. If the second parameter is a
   character string, this file will be added to the zip file. If the
   second parameter is an array, all file names contained in <aFiles>
   will be compressed.

   If <nLevel> is used, it determines the compression type where 0 means
   no compression and 9 means best compression.

   If <bUpdate> is used, every time the file is opened to compress it
   will evaluate bBlock. Parameters of bBlock are cFile and nPos.

   If <lOverWrite> is used, it toggles to overwrite or not the existing
   file. Default is to overwrite the file,otherwise if <lOverWrite> is false
   the new files are added to the <cFile>.

   If <cPassword> is used, all files that are added to the archive are encrypted
   with the password.

   If <lWithPath> is used, it tells  the path should also be stored with
   the file name. Default is false.

   If <lWithDrive> is used, it tells thats the Drive and path should also be stored
   with the file name. Default is false.

   If <bFileUpdate> is used, an Code block is evaluated, showing the total
   of that file has being processed.
   The codeblock must be defined as follow {|nPos,nTotal| GaugeUpdate(aGauge1,(nPos/nTotal))}

   lWithPath and lWithDrive are not supported yet
*/

procedure HB_ZipFile( cFile, uFileToCompress, nLevel, bUpdate, lOverwrite, cPassword, lWithPath, lWithDrive, bFileUpdate, cComment )
local hZip, hHandle, nLen, cBuffer := Space( MZIP_BUFFER_READ ), cFileToZip, nPos := 1, nRead, cExt
   *if !( ".zip" $ cFile )
   *   cFile += ".zip"
   *endif
   hZip = HB_ZipOpen( cFile )
   if !Empty( hZip )
      if HB_IsString( uFileToCompress )
         uFileToCompress = { uFileToCompress }
      endif
      for each cFileToZip in uFileToCompress
         if HB_IsBlock( bUpdate )
            Eval( bUpdate, cFileToZip, nPos++ )
         endif
         hHandle = FOpen( cFileToZip )
         nRead = 0
         HB_FNameSplit( cFileToZip, nil, @cFileToZip, @cExt )
         HB_ZipFileCreate( hZip, cFileToZip + cExt, nil, nil, nil, nil, nil, nLevel, cPassword, nil, nil )
         while ( nLen := FRead( hHandle, @cBuffer, MZIP_BUFFER_READ ) ) > 0
            if HB_IsBlock( bFileUpdate )
               nRead += nLen
               Eval( bFileUpdate, nRead, FSize( cFileToZip ) )
            endif
            HB_ZipFileWrite( hZip, SubStr( cBuffer, 1, nLen ), nLen )
         enddo
         FClose( hHandle )
         HB_ZipFileClose( hZip )
      next
      HB_ZipClose( hZip, cComment )
   endif
return

/*
   HB_UNZIPFILE( <cFile>,
                 [<bUpdate>],
                 [<lWithPath>],
                 [<cPassword>],
                 [<cPath>],
                 [<cFile> | <aFile>],
                 [<bFileUpdate>]  ) --> lCompress

   <cFile>     Name of the zip file to extract

   <bUpdate>   Code block to execute while extracting

   <lWithPath> Toggle to create directory if needed

   <cPassword> Password to use to extract files

   <cPath>     Path to extract the files to - mandatory

   <cFile> | <aFiles> A File or Array of files to extract - mandatory

   <bFileUpdate> Code block for File Progress

   lWithPath are not supported yet
*/

procedure HB_UnZipFile( cFile, bUpdate, lWithPath, cPassword, cPath, uFileToUnzip, bFileUpdate )
   local hUnZip, nErr, cZipName
   *if !( ".zip" $ cFile )
   *   cFile += ".zip"
   *endif
   hUnZip = HB_UnZipOpen( cFile )
   if !Empty( hUnZip )
      if HB_IsString( uFileToUnzip )
        uFileToUnzip = { uFileToUnzip }
      endif
      if Empty( cPath )
         HB_FNameSplit( cFile, @cPath )
      endif
      nErr = HB_UnZipFileFirst( hUnZip )
      while nErr == 0
         if HB_UnzipFileInfo( hUnzip, @cZipName ) == 0
            if AScan( uFileToUnzip, cZipName ) > 0
               cZipName = cPath + cZipName
               HB_UnzipExtractCurrentFile( hUnZip, cZipName, cPassword
            endif
         endif
         nErr = HB_UnZipFileNext( hUnZip )
      enddo
      HB_UnZipClose( hUnZip )
   endif
return

/*
   HB_GETFILESINZIP( <cFile>, [<lExtended>] )

   <cFile>        Is the zip file to get information

   <lExtended>    Is the type of information. The default is .f. and is compatible with old ZipArch method,
                  returning an array with file name only. If lExtended is TRUE, the returned array have additional 
                  informations like: { cFile, dDate, cTime, nSize, nCompSize, lCrypted, cComment }
*/

function HB_GetFilesInZip( cFile, lExtended )
local hUnZip, nErr, dDate, cTime, nSize, nCompSize, lCrypted, cComment, aFiles := {}
   *if !( ".zip" $ cFile )
   *   cFile += ".zip"
   *endif
   if !HB_IsLogical( lExtended )
      lExtended = .f.
   endif
   hUnZip = HB_UnZipOpen( cFile )
   if !Empty( hUnZip )
      nErr = HB_UnZipFileFirst( hUnZip )
      while nErr == 0
         HB_UnzipFileInfo( hUnzip, @cFile, @dDate, @cTime, nil, nil, nil, @nSize, @nCompSize, @lCrypted, @cComment )
         if lExtended
            AAdd( aFiles, { cFile, dDate, cTime, nSize, nCompSize, lCrypted, cComment } )
         else
            AAdd( aFiles, cFile )
         endif
         nErr = HB_UnZipFileNext( hUnZip )
      enddo
      HB_UnZipClose( hUnZip )
   endif
return aFiles
então foi só incluir as funcoes acima no sistema, só ficou faltando a função FSIZE, que encontrei em viewtopic.php?f=43&t=4922&start=15

pronto! passou sem erros de compilação!! :))

Obrigado a todos! :{