Compiling error - sysdeps/i386/elf/start.S and undefined reference to main

Go To StackoverFlow.com

1

I'm using a development platform called Harbour to use Clipper code to create a Linux executable working on 32bit SuSe.

I can already create an executable that still requires external libraries of the platform, but I need to create an executable that is stand-alone. Harbour allows me to do that by including all needed libraries, but when I try the following compile command:

hbmk test3 -static 

I get the following error output:

Harbour 2.0.0 (Rev. -1) 
Copyright (c) 1999-2010, http://www.harbour-project.org/ 
Compiling 'test3.prg'... 
Lines 3, Functions/Procedures 1 
Generating C source output to 'test3.c'... Done. 
/usr/lib/gcc/i586-suse-linux/4.5/../../../crt1.o: In function 
`_start': 
/usr/src/packages/BUILD/glibc-2.11.2/csu/../sysdeps/i386/elf/start.S: 
115: undefined reference to `main' 
./test3.o: In function `HB_FUN_MAIN': 
test3.c:(.text+0x17): undefined reference to `hb_vmExecute' 
./test3.o: In function `hb_vm_SymbolInit_TEST3': 
test3.c:(.text+0x4e): undefined reference to `hb_vmProcessSymbols' 
./test3.o:(.data+0x38): undefined reference to `HB_FUN_QOUT' 
/tmp/cc5KcKMd.o: In function `hb_lnk_SetDefault_build': 
hb-build-root-24212.c:(.text+0x1e): undefined reference to 
`hb_vmSetDefaultGT' 
/tmp/cc5KcKMd.o: In function `_hb_lnk_ForceLink_build': 
hb-build-root-24212.c:(.text+0x8): undefined reference to 
`HB_FUN_HB_GT_STD' 
collect2: ld returned 1 exit status 

My code at this time is extremely simple and dumbed down:

function main() 
? "All done." 
return nil 

(It basically outputs "All done." onto the screen, and that's all I'm making it do until I can get it to compile properly.)

From my 90 minutes of trying to track down this issue, it sounds like either it can't find the function 'main' (which is clearly there), or the c compiler needs the -g parameter set - which is something I can't do because I don't actually address the compiler myself - the Harbour compiler does everything by itself...

I also would like to point out that the path

/usr/src/packages/BUILD

is empty on my system! However, the full path mentioned in the error on top is hard-coded into the file crt1.o...

I even tried telling the compiler to create a c object and compile that, but it doesn't produce the correct input file for the c compiler, and I'm fairly new to both clipper and c...

I apologize if I didn't tag this issue correctly - this is my first stackoverflow post - but I've seen plenty of extremely knowledgeable answers here on other topics, so I decided to give it a try. If there's any more information needed, please let me know.

Thanks in advance!

2012-04-05 19:28
by semmelbroesel
I realized I could probably edit the compiling script, so I did, found the GCC entry, added "-g" as parameter - and still got the same error, so it doesn't look like it is as simple as that in my case.. - semmelbroesel 2012-04-05 20:22


1

I figured out a way around it.

I installed a copy of Debian (instead of OpenSuSe) and tried again, and this time I no longer encountered the error on top.

Ran into a few issues of missing libraries and had to install gcc and various zlib or libz libraries after the compiler kept complaining about missing them:

/usr/bin/ld: cannot find -l[xyz]

But I kept experimenting with the Synaptic Package Manager's search and installing libraries until it worked.

In the end, one more library was missing:

/usr/bin/ld: cannot find -lz

That one required some Google work, but I found that the library I needed to install was zlib1g-dev, and after that was installed, it compiled normally!

Next hurdle was that when running the new executable on another computer, it required yet more libraries, so I told my compiler to include ALL static libraries - and it finally worked!

So now I have my working stand-alone portable executable, and hopefully someone else runs into the same issue (however unlikely it may be) and find help here.

Problem solved.

2012-04-06 20:48
by semmelbroesel
Ads