[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] Linkning med g++ 3.2



Claus Ekstrøm <sslug@sslug> writes:

> rm model.o
> g++ -c -o model.o model.cpp
> g++ test.cpp

Men så fortæller du den jo ikke at den skal linke model.o med ind i
programmet.

Det er fuldstændigt ækvivalent til at gøre:
xyzzy% cat > mylib.c 
#include<stdio.h>

void do_stuff() {
    printf("Dette er en test\n");
}
xyzzy% cat > myprog.c
extern void do_stuff();

int main() {
  do_stuff();
  return 0;
}
xyzzy% gcc -c -o mylib.o mylib.c
xyzzy% gcc myprog.c             
/tmp/ccMRnMjd.o(.text+0x11): In function `main':
: undefined reference to `do_stuff'
collect2: ld returned 1 exit status
xyzzy% gcc mylib.o myprog.c     


Prøv:
$ g++ -c -o model.o model.cpp
$ g++ model.o test.cpp

Istedet.

-- 
 Peter Makholm     |                The four letter word beginning with L?
 sslug@sslug |                It's life, love, libc or lisp         
 http://hacking.dk |                    --  Depending on you point of view


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:09 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *