C Board  

Go Back   C Board > Platform Specific Boards > Linux Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 04-29-2003, 09:19 PM   #1
Rebooted
 
Inquirer's Avatar
 
Join Date: Apr 2002
Posts: 281
Makefiles, Object files, Source files, OH MY!

Hmm... My third qhestion of the night.

I am trying to make my program lake less time to compile, so i made my program modular (.o files), and made a makefile to only compile what is needed.

Here is the deal (greatly simplified):
main.cpp
Code:
#include "file2.h"
#include "file3.h"
#include "file4.h"
file2.cpp
Code:
#include "file2.h"
class stuff;
file3.cpp
Code:
#include "file3.h"
class morejunk;
file4.cpp
Code:
#include "file4.h"
class evenmorejunk;
And all the .h files hold the prototypes for their namesake.cpp files.
Now, the makefile has this: (simplified, again)

makefile
Code:
junk : main.o file2.o file3.o file4.o
        g++ -o junk main.o file2.o file2.o file4.o

file2.o : file2.cpp file2.h
        g++ -c file2.cpp

file3.o : file3.cpp file3.h
        g++ -c file3.cpp

file4.o : file4.cpp file4.h
        g++ -c file4.cpp
Now, the linker is giving me errors telling me:
Code:
nemoserv.cpp:27: storage size of `log' isn't known
nemoserv.cpp:30: storage size of `opts' isn't known
nemoserv.cpp:49: storage size of `chman' isn't known
nemoserv.cpp:50: storage size of `cmd' isn't known
These are the elements of a struct that is defined in a separate source file, and
Code:
nemoserv.cpp:277: aggregate `rawMsg message' has incomplete type and 
cannot be initialized
This class is defined also in another source file.

Please tell me what I am doing wrong, or if you need more information (and what)

Thanks!
~EtherealFlaim
[/code]
__________________
Compilers:
GCC on Red Hat 8.1 (Primary)
GCC on Mac OS X 10.2.4 (Secondary)

Others:
MinGW on XP

Last edited by Inquirer; 04-29-2003 at 09:40 PM.
Inquirer is offline   Reply With Quote
Old 04-29-2003, 09:58 PM   #2
Registered User
 
Codeplug's Avatar
 
Join Date: Mar 2003
Posts: 3,844
Those are compiler errors, not linker errors. You will need to post nemoserv.cpp (and any files it includes) if you want it fixed for you.
Also, if you've made any changes, re-post the compiler errors so the line numbers will correct.

gg
Codeplug is offline   Reply With Quote
Old 04-29-2003, 10:36 PM   #3
Rebooted
 
Inquirer's Avatar
 
Join Date: Apr 2002
Posts: 281
Code:
g++ -ggdb -pthread -c nemoserv.cpp
nemoserv.cpp:27: aggregate `logger log' has incomplete type and cannot 
be initialized
nemoserv.cpp:30: aggregate `parsedArgs opts' has incomplete type and 
cannot be initialized
nemoserv.cpp:49: aggregate `chanManager chman' has incomplete type and 
cannot be initialized
nemoserv.cpp:50: aggregate `commander cmd' has incomplete type and 
cannot be initialized
nemoserv.cpp: In function `int main (int, char **)':
nemoserv.cpp:88: invalid use of undefined type `struct parsedArgs'
nemoirc.h:20: forward declaration of `struct parsedArgs'
nemoserv.cpp: In function `int recvParser (char *, int)':
nemoserv.cpp:277: aggregate `rawMsg message' has incomplete type and 
cannot be initialized
nemoserv.cpp: At top level:
nemoserv.cpp:27: storage size of `log' isn't known
nemoserv.cpp:30: storage size of `opts' isn't known
nemoserv.cpp:49: storage size of `chman' isn't known
nemoserv.cpp:50: storage size of `cmd' isn't known
make: *** [nemoserv.o] Error 1
Thats the full make output. It works (compiles, not like perfectly) if you uncomment the line in the two .h files (that have .cpp namesakes) and just compile the main module.

(NOTE: THIS FILE IS MADE WITH `tar -czvf all.zip *`, so you will need tar to unzip it. I'm not sure what graphical unzippers can untar/gunzip files. You may have to rename the file to .tgz or .tar.gz)
Attached Files
File Type: zip all.zip (7.6 KB, 58 views)
__________________
Compilers:
GCC on Red Hat 8.1 (Primary)
GCC on Mac OS X 10.2.4 (Secondary)

Others:
MinGW on XP
Inquirer is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create a C project with multiple source files MSF1981 C Programming 5 03-22-2009 09:25 AM
Multiple Source Files, make files, scope, include thetinman C++ Programming 13 11-05-2008 11:37 PM
Conditional compilation for object files in Makefile? jutirain C++ Programming 13 12-19-2007 06:23 AM
Threads to keep the CPU faster than the disk? matthew180 C Programming 4 06-06-2007 03:23 PM
A question about constructors... Wolve C++ Programming 9 05-04-2005 04:24 PM


All times are GMT -6. The time now is 01:42 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22