A Linking problem

A Linking problem

Post by Stefan Viljoe » Sat, 12 Jun 1999 04:00:00



----------


> Newsgroups: comp.os.msdos.djgpp
> Subject: A Linking problem
> Date: Thursday, June 03, 1999 4:17 PM

> Hello,
> I am have a bit of trouble linking my *.o files. I am trying to port a
mud
> to run at dos. The *.c files compile fine, but when I type "gcc -o
> filename.exe *.o" I get a long list of things that say undefined
reference,
> and it seems to be all of the functions. At the end of the linking
process
> there is a message....

Your problem seems to be that you cannot use wildcards ("*.o*) on the GCC
commandline - I think! Rather create a makefile (take a look at LAMETRO on
WWW page if you do not know how) and assign all the object filenames in the
way I did in LAMETRO's makefile. This  automatically feeds all the .O
filenames to GCC AT ONCE at the correct time and enables you to compile the
program (I think!)

Quote:> "c:\djgpp\lib\libc.a(crt1.o)(.text+0x446):crt1.c:undefined reference to
> 'main'.

This means that the main program function is not present - take a look at
the make file for LAMETRO - you need to define a source file that has the
"main" function in it. What happens above is that GCC obliging compiles,
but when it comes time to create the .EXE it can't find the .O file with
the "main()" function - it thus complains with the text+0x446 error message
that it cannot find main. It is considered an "underfined reference" since
it is "referenced" by default. Remember from basic C class that when a C
program starts, it always starts at the top of main() - if it cannot find
it - BLOOEY! The compiler stops with a link time error.

Quote:> thank you very much!!

No problem!

This message courtesy of

http://home.intekom.com/rylan/
--
StarWars for ever!.

 
 
 

A Linking problem

Post by Eli Zaretski » Mon, 14 Jun 1999 04:00:00



> Your problem seems to be that you cannot use wildcards ("*.o*) on the GCC
> commandline - I think!

Actually, there should be no problems with using wildcards on the GCC
command line, provided that they don't conflict with each other (like
if they define functions by the same name).  GCC doesn't see the
wildcards, since they are all expanded by the startup code (see
section 16.1 of the FAQ for details).  So by the time GCC's `main'
function runs, it sees a long list of object files, not the wildcard
you typed.

 
 
 

1. 3rd Try: Maybe an asm problem? (Problems linking)

When I link the test code for my graphics library, I get no error
message on references to C++ functions, but I get 'undefined reference'
error messages at every line of C++ code containing a function call to
an assembler routine.  I'm using nasm; GLOBAL statements appear at the
beginning of the source for about every function in the source without
any extra specifiers, and my functions start with just a label followed
by a colon.  Every other technique I've tried didn't assemble at all.

2. SMS requirements/costs?

3. DJGPP links: 400 links!

4. PLEASE

5. To link or not to link???

6. no sound

7. Where does the 1st links prev. pointer point to in doubly linked list?

8. How to create running time in excel sheet

9. "100 Shateware Links Page" (Free Shareware Links)

10. "100 Shareware Links Page" (Free Shareware Links)

11. links and symbolic links

12. Linked List of a Linked List ??

13. Where does the 1st links prev. pointer point to in doubly linked list?