Porting to Linux: crt1.o and "undefined reference to `main'"

Porting to Linux: crt1.o and "undefined reference to `main'"

Post by Josef Jur » Tue, 14 Sep 1999 04:00:00



I am presently working on a port of a program
from Solaris to Linux, Debian version 2.0.

When compiling a number of object files to create a .so
file as follows:

     gcc -o ./obj/libSrbClient.so obj/clAuth.o obj/clConnect.o
          obj/clExec.o obj/clMisc.o obj/clStub.o obj/srb_perror.o
          obj/dllist.o obj/clGlobal.o

I get the message:

     /usr/lib/crt1.o(.text+0x36): undefined reference to `main'
     collect2: ld returned 1 exit status

Can someone indicate how I solve this problem?

Thank you for your time,

Josef Jurek

 
 
 

Porting to Linux: crt1.o and "undefined reference to `main'"

Post by Remco van den Be » Tue, 14 Sep 1999 04:00:00



>I am presently working on a port of a program
>from Solaris to Linux, Debian version 2.0.

>When compiling a number of object files to create a .so
>file as follows:

>     gcc -o ./obj/libSrbClient.so obj/clAuth.o obj/clConnect.o
>          obj/clExec.o obj/clMisc.o obj/clStub.o obj/srb_perror.o
>          obj/dllist.o obj/clGlobal.o

>I get the message:

>     /usr/lib/crt1.o(.text+0x36): undefined reference to `main'
>     collect2: ld returned 1 exit status

>Can someone indicate how I solve this problem?

>Thank you for your time,

>Josef Jurek


You're actually asking gcc to make a normal executable in stead of a shared
library here. That's why the linker complains about no main entry point.

Use `ld' to generate the shared library (-shared option, see `man ld')
or use gcc and give the ld options to gcc via -Wl,.....
(I think the -shared option can even be given to gcc directly.)

I think you also have to compile your code with the -fpic option.
But I'm not so familiar with these things.

Good luck,

- Remco van den Berg

----------------------------------------------------------------------------
Philips Semiconductors B.V.  tel:(+31 40 27)22031   fax:22764   Room: BE-345


----------------------------------------------------------------------------
 Microsoft and Lotus Notes free.   Don't send me any Microsoft attachments.
----------------------------------------------------------------------------

 
 
 

1. help... crt1.o "undefinied reference to main is _start"

Hi

I have the SWiM release of Motif which I'm trying to install however when I
try to make mwm I get an error telling me that there's an undefined
reference to main in crt1.o. I did a little bit of searching and I've
discovered that other people have had the same problem while trying to
compile other programs too. For the record I have Slackware 3.2 and SWiM
version 2. It's been a while since I've played with Linux but at one point
(about 2 years ago) I did have SWiM working just fine. I was going to
replace crt1.o with an older version from a previous release of slackware
but I can't figure out where to get it from (everything is compressed and I
can't easily find out what's in those files). Does anyone know which tar.gz
file crt1.o lives in (or does anyone else have a solution to this problem)?
I would greatly appreciate any help you can offer. Thanks, Joe

--
        http://www.thecia.net/users/analog

        When the only tool you have is a hammer,
        everything begins to look like a nail.

        -Lotfi Zadeh

 email:  analog at thecia dot net

Any commercial or private email messages not related to music, pro-audio,
or computer programming will be considered as unsolicited. Your postmaster
WILL be notified.

2. partition mount problem

3. /usr/lib/crt1.o(.text+0x69): undefined reference to `main'

4. real 3d "starfigher" card in 1280 res?

5. "increased VM size+Main-memory" better than "Main-memory+Hard-disk" ??

6. MGR and Linux

7. : trouble compiling Stevens' unpv2 - "undefined reference ..."

8. keyboard map

9. building xload: "undefined reference to `XkbLookupKeySym'"

10. Can't compile: "undefined reference..."

11. What is "undefined reference to `__rtti_si'"?

12. """"""""My SoundBlast 16 pnp isn't up yet""""""""""""

13. GETSERVBYNAME()????????????????????"""""""""""""