Page 1 of 2

A library problem

Posted: Fri Jun 11, 2010 5:12 pm
by esgici
Hi

Upon a problem I had encountered while building a HMG project, I had write this to Harbour:
- hbmk2 say :
...lib/libhbct.a(charop.o):charop.c:(.text+0xa40): multiple definition of
`HB_FUN_CHARXOR'
...lib/libcrypt.a(c_crypt.o):c_crypt.c:(.text+0x0): first defined here
and responded (by Przemek) like this :
Sorry but libcrypt.a is not part of Harbour.
I do not know where did you take this library from and what it does
but it tries creates name conflict with CHARXOR() function in HBCT
library. You should contact with this library author and ask about
the fix.
First my fault by saying hbmk2 say, and second, how would correct this conflict ?

Regards

--

Esgici

PS: IMHO libcrypt.a would rewrite from scratch and this is necessary.

Re: A library problem

Posted: Fri Jun 11, 2010 5:15 pm
by Rathinagiri
Thanks for the info Esgici.

Can this be avoided?! ie., to ignore the second occurrence?

Re: A library problem

Posted: Fri Jun 11, 2010 5:27 pm
by esgici
rathinagiri wrote: Can this be override?! ie., to ignore the second occurrence?
IMHO yes; but by first author of this library ;)

Regards

--

Esgici

Re: A library problem

Posted: Fri Jun 11, 2010 5:29 pm
by Rathinagiri
It is ok. However I wish to know whether there is any linker option to ignore the second occurrence.

Re: A library problem

Posted: Fri Jun 11, 2010 5:41 pm
by Rathinagiri
I had seen the source code for crypt library in c:\hmg\source\crypt\h_crypt.prg. There is a HB_FUNCTION definition of charxor() in c_crypt.c.

So, to avoid the error, we can do one of the following two.

1. If the original charxor function and the Harbour charxor function are giving similar results, we can delete c_crypt.c and recompile & rebuild the libcrypt.a. :)

2. If we want to retain both the functions, then we can rename charxor function to another name in both h_crypt.prg and c_crypt.c. Then again, recompile and rebuild the library.

That's all.

I am enclosing the new libcrypt.a using the second method. Kindly backup old libcrypt.a and replace the new one and recompile your project.
libcrypt.zip
(4.02 KiB) Downloaded 278 times

Re: A library problem

Posted: Fri Jun 11, 2010 8:04 pm
by esgici
rathinagiri wrote: I am enclosing the new libcrypt.a using the second method.
Hi Rathi

Thanks, worked :)

I hope Roberto confirm modification and include in next release.

Regards

--

Esgici

Re: A library problem

Posted: Fri Jun 11, 2010 9:56 pm
by Roberto Lopez
rathinagiri wrote:I had seen the source code for crypt library in c:\hmg\source\crypt\h_crypt.prg. There is a HB_FUNCTION definition of charxor() in c_crypt.c.

So, to avoid the error, we can do one of the following two.

1. If the original charxor function and the Harbour charxor function are giving similar results, we can delete c_crypt.c and recompile & rebuild the libcrypt.a. :)

2. If we want to retain both the functions, then we can rename charxor function to another name in both h_crypt.prg and c_crypt.c. Then again, recompile and rebuild the library.

That's all.

I am enclosing the new libcrypt.a using the second method. Kindly backup old libcrypt.a and replace the new one and recompile your project.
libcrypt.zip
AFAIR the author is Grigory. perhaps, it could be better if he post here an updated version.

Re: A library problem

Posted: Sat Jun 12, 2010 12:32 pm
by esgici
Hi
rathinagiri wrote: If the original charxor function and the Harbour charxor function are giving similar results, we can delete c_crypt.c and recompile & rebuild the libcrypt.a. :)
Results must be similar, I don't know is (exactly) same; but tested and no problem encountered.
makefile.rar
Make file for building (new) libcrypt.a
(355 Bytes) Downloaded 280 times
Regards

--

Esgici

Re: A library problem

Posted: Sat Jun 12, 2010 12:42 pm
by Rathinagiri
Thanks a lot Esgici. :)

Re: A library problem

Posted: Sat Jun 12, 2010 12:48 pm
by esgici
Hi

Now, I Know: result is same :)

Code: Select all

PROC TestCharXOR()
    
   LOCAL cXOredHRB := CHARXOR( "This is a string", "this is password" ),;
         cXOredHMG := CHARXOR_2( "This is a string", "this is password" )  // renamed and re-libbed c_crypt.c.
         
   MsgInfo( "Result is " + IF( cXOredHRB == cXOredHMG, "same.", "different." ) )      
   
RETU // TestCharXOR()


Regards

--

Esgici