Re: [Dev-C++] Compilation of multiple files
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Per W. <pw...@ia...> - 2007-07-10 14:17:35
|
It seems that you declare variables in main.h and then include the file from two source files. That gets you two sets of variables with the same name. Either modify main.h to contain: extern int my_variable; and in main.c actually instantiate the variables: int my_variable; or modify main.h to contain. #ifdef MAIN_APP #define EXTERN #else #define EXTERN extern #endif EXTERN int my_variable; and in main.c, write: #define MAIN_APP #include "main.h" and in other source files just write: #include "main.h" /pwm On Tue, 10 Jul 2007, Jan Mura wrote: > Hello, > > I have problems with compiling using gcc in Dev-C. > > I am trying to compile > two .c and two .h files. > > In main.h I have preprocesor commands: > > #ifndef __stdio_h__ > #include<stdio.h> > #define __stdio_h__ > #endif > /* and the similarly with standard .h headers. */ > #ifndef __bet_list_h__ > #include "bet_list.h" > #define __bet_list_h__ > #endif > #ifndef __bet_list_h__ > #include "bet_list.h" > #define __bet_list_h__ > #endif > > > In main.c and bet_list.c I have: > > #ifndef __main_h__ > #include "main.h" > #define __main_h__ > #endif > > > The output from make is: > > gcc main.c bet_list.c -o out_exe > C:\DOCUME~1\tereza\LOCALS~1\Temp/ccqobaaa.o(.data+0x0):bet_list.c: multiple > definition of `bet_no' > C:\DOCUME~1\tereza\LOCALS~1\Temp/cc0Yaaaa.o(.data+0x0):main.c: first defined > here > C:\DOCUME~1\tereza\LOCALS~1\Temp/ccqobaaa.o(.data+0x4):bet_list.c: multiple > definition of `max_bet_no' > C:\DOCUME~1\tereza\LOCALS~1\Temp/cc0Yaaaa.o(.data+0x4):main.c: first defined > here > C:\DOCUME~1\tereza\LOCALS~1\Temp/ccqobaaa.o(.data+0x8):bet_list.c: multiple > definition of `d_name' > C:\DOCUME~1\tereza\LOCALS~1\Temp/cc0Yaaaa.o(.data+0x8):main.c: first defined > here > C:\DOCUME~1\tereza\LOCALS~1\Temp/ccqobaaa.o(.data+0x10):bet_list.c: multiple > definition of `d_description' > C:\DOCUME~1\tereza\LOCALS~1\Temp/cc0Yaaaa.o(.data+0x10):main.c: first > defined here > C:\DOCUME~1\tereza\LOCALS~1\Temp/ccqobaaa.o(.data+0x18):bet_list.c: multiple > definition of `d_multiplicator' > C:\DOCUME~1\tereza\LOCALS~1\Temp/cc0Yaaaa.o(.data+0x18):main.c: first > defined here > C:\DOCUME~1\tereza\LOCALS~1\Temp/ccqobaaa.o(.data+0x20):bet_list.c: multiple > definition of `d_calculation' > C:\DOCUME~1\tereza\LOCALS~1\Temp/cc0Yaaaa.o(.data+0x20):main.c: first > defined here > C:\DOCUME~1\tereza\LOCALS~1\Temp/ccqobaaa.o(.data+0x28):bet_list.c: multiple > definition of `module_name' > C:\DOCUME~1\tereza\LOCALS~1\Temp/cc0Yaaaa.o(.data+0x28):main.c: first > defined here > C:\DOCUME~1\tereza\LOCALS~1\Temp/cc0Yaaaa.o(.text+0xb2):main.c: undefined > reference to `print_' > collect2: ld returned 1 exit status > make: *** [build] Error 1 > > > Anyone knows where is an error. > I have tried to do it > using just simple #include, without the definition > the preprocesor variables but it doesn't work neither. > > Thank you very much > > Jan Mura > jan...@vo... > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |