Can't build hex2bin on Linux

Pagina 1/2
| 2

Door The Apeman

Master (137)

afbeelding van The Apeman

12-12-2020, 11:43

Hi all,

When trying to build the hex2bin from SourceForge that is suggested by Fusion-C 2.1, I'm running into trouble on Linux:

gcc -c -std=c99 -O2 -Wall -pedantic hex2bin.c -o hex2bin.o
hex2bin.c: In functie ‘main’:
hex2bin.c:212:17: let op: this ‘if’ clause does not guard... [-Wmisleading-indentation]
  212 |                 if (temp > Highest_Address)
      |                 ^~
hex2bin.c:214:21: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’
  214 |                     if (Verbose_Flag) fprintf(stderr,"Highest_Address: %08X\n",Highest_Address);
      |                     ^~
gcc -c -std=c99 -O2 -Wall -pedantic common.c -o common.o
gcc -c -std=c99 -O2 -Wall -pedantic libcrc.c -o libcrc.o
gcc -c -std=c99 -O2 -Wall -pedantic binary.c -o binary.o
gcc -O2 -Wall -o hex2bin hex2bin.o common.o libcrc.o binary.o
/usr/bin/ld: common.o:(.data+0xc): multiple definition of `Pad_Byte'; hex2bin.o:(.bss+0xa4): first defined here
/usr/bin/ld: common.o:(.bss+0x38): multiple definition of `Batch_Mode'; hex2bin.o:(.bss+0x3c): first defined here
/usr/bin/ld: common.o:(.bss+0xa0): multiple definition of `Filin'; hex2bin.o:(.bss+0xb0): first defined here
/usr/bin/ld: common.o:(.bss+0x98): multiple definition of `Filout'; hex2bin.o:(.bss+0xa8): first defined here
/usr/bin/ld: common.o:(.bss+0x88): multiple definition of `Checksum'; hex2bin.o:(.bss+0x98): first defined here
/usr/bin/ld: common.o:(.bss+0x90): multiple definition of `Enable_Checksum_Error'; hex2bin.o:(.bss+0xa0): first defined here
/usr/bin/ld: common.o:(.bss+0x84): multiple definition of `Record_Nb'; hex2bin.o:(.bss+0x94): first defined here
/usr/bin/ld: common.o:(.bss+0x8c): multiple definition of `Status_Checksum_Error'; hex2bin.o:(.bss+0x9c): first defined here
/usr/bin/ld: common.o:(.bss+0x4c): multiple definition of `Floor_Address_Setted'; hex2bin.o:(.bss+0x50): first defined here
/usr/bin/ld: common.o:(.bss+0x48): multiple definition of `Ceiling_Address_Setted'; hex2bin.o:(.bss+0x4c): first defined here
/usr/bin/ld: common.o:(.bss+0x5c): multiple definition of `Floor_Address'; hex2bin.o:(.bss+0x60): first defined here
/usr/bin/ld: common.o:(.data+0x4): multiple definition of `Ceiling_Address'; hex2bin.o:(.bss+0x64): first defined here
/usr/bin/ld: common.o:(.bss+0x2c): multiple definition of `Cks_Type'; hex2bin.o:(.bss+0x30): first defined here
/usr/bin/ld: common.o:(.data+0x0): multiple definition of `Crc_Poly'; hex2bin.o:(.bss+0x10): first defined here
/usr/bin/ld: common.o:(.bss+0xc): multiple definition of `Crc_Init'; hex2bin.o:(.bss+0xc): first defined here
/usr/bin/ld: common.o:(.bss+0x8): multiple definition of `Crc_XorOut'; hex2bin.o:(.bss+0x8): first defined here
/usr/bin/ld: common.o:(.bss+0x20): multiple definition of `Cks_Addr'; hex2bin.o:(.bss+0x24): first defined here
/usr/bin/ld: common.o:(.bss+0x74): multiple definition of `Lowest_Address'; hex2bin.o:(.bss+0x80): first defined here
/usr/bin/ld: common.o:(.bss+0x30): multiple definition of `Endian'; hex2bin.o:(.bss+0x34): first defined here
/usr/bin/ld: common.o:(.bss+0x78): multiple definition of `Memory_Block'; hex2bin.o:(.bss+0x88): first defined here
/usr/bin/ld: common.o:(.bss+0x10): multiple definition of `Force_Value'; hex2bin.o:(.bss+0x14): first defined here
/usr/bin/ld: common.o:(.bss+0x70): multiple definition of `Highest_Address'; hex2bin.o:(.bss+0x7c): first defined here
/usr/bin/ld: common.o:(.bss+0x60): multiple definition of `Max_Length'; hex2bin.o:(.bss+0x6c): first defined here
/usr/bin/ld: common.o:(.bss+0x54): multiple definition of `Minimum_Block_Size_Setted'; hex2bin.o:(.bss+0x58): first defined here
/usr/bin/ld: common.o:(.bss+0x14): multiple definition of `Cks_Addr_set'; hex2bin.o:(.bss+0x18): first defined here
/usr/bin/ld: common.o:(.data+0x8): multiple definition of `Minimum_Block_Size'; hex2bin.o:(.bss+0x68): first defined here
/usr/bin/ld: common.o:(.bss+0x58): multiple definition of `Module'; hex2bin.o:(.bss+0x5c): first defined here
/usr/bin/ld: common.o:(.bss+0x18): multiple definition of `Cks_range_set'; hex2bin.o:(.bss+0x1c): first defined here
/usr/bin/ld: common.o:(.bss+0x28): multiple definition of `Cks_Start'; hex2bin.o:(.bss+0x2c): first defined here
/usr/bin/ld: common.o:(.bss+0x24): multiple definition of `Cks_End'; hex2bin.o:(.bss+0x28): first defined here
/usr/bin/ld: common.o:(.bss+0x1c8): multiple definition of `crc_table'; hex2bin.o:(.bss+0x1e8): first defined here
/usr/bin/ld: common.o:(.bss+0x44): multiple definition of `Max_Length_Setted'; hex2bin.o:(.bss+0x48): first defined here
/usr/bin/ld: common.o:(.bss+0x1c): multiple definition of `Cks_Value'; hex2bin.o:(.bss+0x20): first defined here
/usr/bin/ld: common.o:(.bss+0x4): multiple definition of `Crc_RefIn'; hex2bin.o:(.bss+0x4): first defined here
/usr/bin/ld: common.o:(.bss+0x50): multiple definition of `Starting_Address_Setted'; hex2bin.o:(.bss+0x54): first defined here
/usr/bin/ld: common.o:(.bss+0x64): multiple definition of `Records_Start'; hex2bin.o:(.bss+0x70): first defined here
/usr/bin/ld: common.o:(.bss+0x6c): multiple definition of `Starting_Address'; hex2bin.o:(.bss+0x78): first defined here
/usr/bin/ld: common.o:(.bss+0x80): multiple definition of `Nb_Bytes'; hex2bin.o:(.bss+0x90): first defined here
/usr/bin/ld: common.o:(.bss+0x68): multiple definition of `Phys_Addr'; hex2bin.o:(.bss+0x74): first defined here
/usr/bin/ld: common.o:(.bss+0x40): multiple definition of `Swap_Wordwise'; hex2bin.o:(.bss+0x44): first defined here
/usr/bin/ld: common.o:(.bss+0x34): multiple definition of `Verbose_Flag'; hex2bin.o:(.bss+0x38): first defined here
/usr/bin/ld: common.o:(.bss+0xb0): multiple definition of `Extension'; hex2bin.o:(.bss+0xc0): first defined here
/usr/bin/ld: common.o:(.bss+0x3c): multiple definition of `Address_Alignment_Word'; hex2bin.o:(.bss+0x40): first defined here
/usr/bin/ld: common.o:(.bss+0x0): multiple definition of `Crc_RefOut'; hex2bin.o:(.bss+0x0): first defined here
/usr/bin/ld: common.o:(.bss+0xc0): multiple definition of `Filename'; hex2bin.o:(.bss+0xe0): first defined here
/usr/bin/ld: libcrc.o:(.bss+0x0): multiple definition of `crc_table'; hex2bin.o:(.bss+0x1e8): first defined here
collect2: fout: ld gaf exit-status 1 terug
make: *** [Makefile:23: hex2bin] Fout 1

Using gcc versie 10.2.0 (GCC) On Linux kernel 5.9.13-arch1-1

I have also tried to use the hex2bin from the Arch User Repository, but that doesn't seem to deliver .COM-files working on MSX.

Does anyone have any luck building this on a recent Linux machine and if so, how?

Aangemeld of registreer om reacties te plaatsen

Van lintweaker

Champion (400)

afbeelding van lintweaker

12-12-2020, 12:36

I think I have the same version and also having the same issue. It compiled just fine on Fedora 31 but no longer on Fedora 33 I am currently using. I do have a compiled version which works.

Edit: getting it to compile again is doable but a bit of work. I'll see If I can make it work again

Van The Apeman

Master (137)

afbeelding van The Apeman

12-12-2020, 12:54

Thanks! I'd send a message to the author, but I'd need an account on SourceForge, which I don't like.

Van lintweaker

Champion (400)

afbeelding van lintweaker

12-12-2020, 12:51

Quick compile fix, patch here, patch with :

patch -p1 < ../patch-file.txt
Common subdirectories: Hex2bin-2.5/bin and Hex2bin-2.5-jk/bin
diff -u Hex2bin-2.5/common.h Hex2bin-2.5-jk/common.h
--- Hex2bin-2.5/common.h	2017-05-11 02:38:36.000000000 +0200
+++ Hex2bin-2.5-jk/common.h	2020-12-12 12:44:32.735949112 +0100
@@ -11,11 +11,11 @@
 #ifdef _MSC_VER
 #define _CRT_SECURE_NO_WARNINGS
 #endif
-
+
 //#if defined(_WIN32) || defined(_WIN64)
 //#include 
 //#endif /* _WIN32 */
-
+
 /* option character */
 #if defined(MSDOS) || defined(__DOS__) || defined(__MSDOS__) || defined(_MSDOS)
 #define _IS_OPTION_(x)	 (((x) == '-') || ((x) == '/'))
@@ -74,10 +74,10 @@
 void GetExtension(const char *str,char *ext);
 void PutExtension(char *Flnm, char *Extension);
 
-filetype    Filename;           /* string for opening files */
-char        Extension[MAX_EXTENSION_SIZE];       /* filename extension for output files */
+extern filetype    Filename;           /* string for opening files */
+extern char        Extension[MAX_EXTENSION_SIZE];       /* filename extension for output files */
 
-FILE        *Filin,             /* input files */
+extern FILE        *Filin,             /* input files */
             *Filout;            /* output files */
 
 #ifdef USE_FILE_BUFFERS
@@ -85,44 +85,44 @@
             *FiloutBuf;         /* text buffer for file output */
 #endif
 
-int Pad_Byte;
-bool Enable_Checksum_Error;
-bool Status_Checksum_Error;
-byte 	Checksum;
-unsigned int Record_Nb;
-unsigned int Nb_Bytes;
+extern int Pad_Byte;
+extern bool Enable_Checksum_Error;
+extern bool Status_Checksum_Error;
+extern byte 	Checksum;
+extern unsigned int Record_Nb;
+extern unsigned int Nb_Bytes;
 
 /* This will hold binary codes translated from hex file. */
-byte *Memory_Block;
-unsigned int Lowest_Address, Highest_Address;
-unsigned int Starting_Address, Phys_Addr;
-unsigned int Records_Start; // Lowest address of the records
-unsigned int Max_Length;
-unsigned int Minimum_Block_Size;
-unsigned int Ceiling_Address;
-unsigned int Floor_Address;
-int Module;
-bool Minimum_Block_Size_Setted;
-bool Starting_Address_Setted;
-bool Floor_Address_Setted;
-bool Ceiling_Address_Setted;
-bool Max_Length_Setted;
-bool Swap_Wordwise;
-bool Address_Alignment_Word;
-bool Batch_Mode;
-bool Verbose_Flag;
-
-int Endian;
-
-t_CRC Cks_Type;
-unsigned int Cks_Start, Cks_End, Cks_Addr, Cks_Value;
-bool Cks_range_set;
-bool Cks_Addr_set;
-bool Force_Value;
-
-unsigned int Crc_Poly, Crc_Init, Crc_XorOut;
-bool Crc_RefIn;
-bool Crc_RefOut;
+extern byte *Memory_Block;
+extern unsigned int Lowest_Address, Highest_Address;
+extern unsigned int Starting_Address, Phys_Addr;
+extern unsigned int Records_Start; // Lowest address of the records
+extern unsigned int Max_Length;
+extern unsigned int Minimum_Block_Size;
+extern unsigned int Ceiling_Address;
+extern unsigned int Floor_Address;
+extern int Module;
+extern bool Minimum_Block_Size_Setted;
+extern bool Starting_Address_Setted;
+extern bool Floor_Address_Setted;
+extern bool Ceiling_Address_Setted;
+extern bool Max_Length_Setted;
+extern bool Swap_Wordwise;
+extern bool Address_Alignment_Word;
+extern bool Batch_Mode;
+extern bool Verbose_Flag;
+
+extern int Endian;
+
+extern t_CRC Cks_Type;
+extern unsigned int Cks_Start, Cks_End, Cks_Addr, Cks_Value;
+extern bool Cks_range_set;
+extern bool Cks_Addr_set;
+extern bool Force_Value;
+
+extern unsigned int Crc_Poly, Crc_Init, Crc_XorOut;
+extern bool Crc_RefIn;
+extern bool Crc_RefOut;
 
 void VerifyChecksumValue(void);
 void VerifyRangeFloorCeil(void);
@@ -130,7 +130,7 @@
 void WriteMemBlock16(uint16_t Value);
 void WriteMemBlock32(uint32_t Value);
 void WriteMemory(void);
-void Allocate_Memory_And_Rewind(void);
-char *ReadDataBytes(char *p);
-void ParseOptions(int argc, char *argv[]);
+void Allocate_Memory_And_Rewind(void);
+char *ReadDataBytes(char *p);
+void ParseOptions(int argc, char *argv[]);
 
Common subdirectories: Hex2bin-2.5/doc and Hex2bin-2.5-jk/doc
Only in Hex2bin-2.5: hex2bin
diff -u Hex2bin-2.5/libcrc.h Hex2bin-2.5-jk/libcrc.h
--- Hex2bin-2.5/libcrc.h	2015-02-22 05:16:35.000000000 +0100
+++ Hex2bin-2.5-jk/libcrc.h	2020-12-12 12:45:17.678737885 +0100
@@ -24,7 +24,7 @@
 #ifndef _LIBCRC_H_
 #define _LIBCRC_H_
 
-void *crc_table;
+extern void *crc_table;
 
 void init_crc8_normal_tab(uint8_t polynom);
 void init_crc8_reflected_tab(uint8_t polynom);
Only in Hex2bin-2.5: mot2bin

Hope this helps.

Van The Apeman

Master (137)

afbeelding van The Apeman

12-12-2020, 13:03

Hmmm...

patching file common.h
Hunk #1 FAILED at 11.
Hunk #3 FAILED at 85.
Hunk #4 FAILED at 130.
3 out of 4 hunks FAILED -- saving rejects to file common.h.rej
patching file libcrc.h

Question

Van Pencioner

Scribe (1399)

afbeelding van Pencioner

12-12-2020, 13:09

@The Apeman i remember same problem. if you look carefully to the patch, you will see that some variables are defined without the modifier 'extern' in header and then GCC thinks that you were declaring variable multiple times, and the patch just fxed that by adding 'extern'. btw, if you add 'extern' to all declarations in .H (header) files you should be fine with compiling

Van The Apeman

Master (137)

afbeelding van The Apeman

12-12-2020, 14:07

@Pencioner, yes, thats what I saw, but it's still complaining about crc_table:

$ make
gcc -O2 -Wall -o hex2bin hex2bin.o common.o libcrc.o binary.o
/usr/bin/ld: common.o:(.bss+0x1c8): multiple definition of `crc_table'; hex2bin.o:(.bss+0x0): first defined here
/usr/bin/ld: libcrc.o:(.bss+0x0): multiple definition of `crc_table'; hex2bin.o:(.bss+0x0): first defined here
collect2: fout: ld gaf exit-status 1 terug
make: *** [Makefile:23: hex2bin] Fout 1

Even though it is only declared in one header file and I made it external:

$ grep "crc_table" *h
libcrc.h:extern void *crc_table;

this calls for make clean first. since it is not a compiler but linker who complains, i guess some object files were generated without errors but still was having wrong duplicate generation. and they don't recompile because changes there was only in header file included not in C files..

Van lintweaker

Champion (400)

afbeelding van lintweaker

12-12-2020, 13:34

The Apeman wrote:

Hmmm...

patching file common.h
Hunk #1 FAILED at 11.
Hunk #3 FAILED at 85.
Hunk #4 FAILED at 130.
3 out of 4 hunks FAILED -- saving rejects to file common.h.rej
patching file libcrc.h

Question

Those failures should not happen, it should apply clean. Maybe we have slightly different versions.
My version says:

hex2bin v2.5, Copyright (C) 2017 Jacques Pelletier & contributors

Also: do not forget to do a 'make clean' or apply to clean sources.

Van Wolverine_nl

Paragon (1149)

afbeelding van Wolverine_nl

12-12-2020, 13:54

Doesn't Fusion-C 1.2 use SDCC ? I never read that GCC could be compiled with a Z80 assembler in the chain? Interesting ;-)
This I would like to know Smile

Van Pencioner

Scribe (1399)

afbeelding van Pencioner

12-12-2020, 14:13

"The ApeMan" wrote:

@Pencioner, yes, thats what I saw, but it's still complaining about crc_table:

$ make
gcc -O2 -Wall -o hex2bin hex2bin.o common.o libcrc.o binary.o
/usr/bin/ld: common.o:(.bss+0x1c8): multiple definition of `crc_table'; hex2bin.o:(.bss+0x0): first defined here
/usr/bin/ld: libcrc.o:(.bss+0x0): multiple definition of `crc_table'; hex2bin.o:(.bss+0x0): first defined here
collect2: fout: ld gaf exit-status 1 terug
make: *** [Makefile:23: hex2bin] Fout 1

Even though it is only declared in one header file and I made it external:

$ grep "crc_table" *h
libcrc.h:extern void *crc_table;

this calls for make clean first. since it is not a compiler but linker who complains, i guess some object files were generated without errors but have wrong duplicate declaration. and they don't recompile because changes there was only in header file included not in C files, so gnu make thinks it is fresh

Van Pencioner

Scribe (1399)

afbeelding van Pencioner

12-12-2020, 14:21

Wolverine_nl wrote:

Doesn't Fusion-C 1.2 use SDCC ? I never read that GCC could be compiled with a Z80 assembler in the chain? Interesting ;-)
This I would like to know Smile

We speak about compiling a tool which is used in SDCC/Fusion-C chain with GCC, not about using GCC to compile MSX programs btw Smile

Pagina 1/2
| 2