S
Sune
Hi,
previously I used Eclipse CDT for compiling my files just to get
started with C and leave C++ behind. Now it's time to get a little more
serious so I've moved my files to a new workplace and begun to use GNU
Autotools. I'm sorry to say I'm new to gcc as well
Now I get the most ridiculous compile error which I'm unable to solve.
Can someone, please, help me with this? gcc output together with the
files mentioned in the gcc error output follows below. It is about 50
lines all in all, so I'm sure someone out there can find what's wrong
pretty quickly.
Thanks in advance anyone!
Sune
**************** Here is the gcc output *************
[sune@localhost rsd2]$ make all
make all-recursive
make[1]: Entering directory `/home/sune/gnu-ws/rsd2'
Making all in collections
make[2]: Entering directory `/home/sune/gnu-ws/rsd2/collections'
gcc -g -O2 -o collections_test DynamicString.o test_main.o
test_main.o(.rodata+0x0): In function `t1':
/home/sune/gnu-ws/rsd2/collections/test_main.c:12: multiple definition
of `DynamicString_SUCCESS'
DynamicString.o(.rodata+0x0):/home/sune/gnu-ws/rsd2/collections/DynamicString.c:10:
first defined here
test_main.o(.rodata+0x4): In function `t1':
/home/sune/gnu-ws/rsd2/collections/test_main.c:12: multiple definition
of `DynamicString_ERROR'
DynamicString.o(.rodata+0x4):/home/sune/gnu-ws/rsd2/collections/DynamicString.c:10:
first defined here
collect2: ld returned 1 exit status
make[2]: *** [collections_test] Error 1
make[2]: Leaving directory `/home/sune/gnu-ws/rsd2/collections'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/sune/gnu-ws/rsd2'
make: *** [all] Error 2
**************** Here is the beginning of my DynamicString.c file
*************
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include "DynamicString.h"
static const int FILE_ID = 0;
inline void DynamicString_init( DynamicString* string_obj, int trace_id
)
{
string_obj->stack_string[0] = '\0';
string_obj->heap_string = 0;
string_obj->string = 0;
string_obj->size = 0;
string_obj->capacity = DynamicString_stack_string_size;
}
**************** Here is the beginning of my DynamicString.h file
*************
#ifndef DYNAMICSTRING_H_
#define DYNAMICSTRING_H_
#include <stddef.h>
#include "../config.h" // Don't worry about the relative path, I'll
fix it...
const int DynamicString_ERROR=0;
const int DynamicString_SUCCESS=1;
enum { DynamicString_stack_string_size = 256 };
typedef struct DynamicString_
{
char stack_string[ DynamicString_stack_string_size ];
char* heap_string;
char* string;
size_t size;
size_t capacity;
} DynamicString;
**************** Here is the beginning of my test_main.c file
*************
#include <stdio.h>
#include <string.h>
#include "debug/Debug.h"
#include "collections/DynamicString.h"
int
t1(int),t2(int),t3(int),t4(int),t5(int),t6(int),t7(int),t8(int),t9(int),t10(int);
int (*func[])(int) = { t1,t2,t3,t4,t5,t6,t7,t8,t9,t10 };
// Init
int t1( int trace_id )
{
DynamicString string;
DynamicString_init( &string, trace_id );
return 1; // Can't fail!
}
previously I used Eclipse CDT for compiling my files just to get
started with C and leave C++ behind. Now it's time to get a little more
serious so I've moved my files to a new workplace and begun to use GNU
Autotools. I'm sorry to say I'm new to gcc as well
Now I get the most ridiculous compile error which I'm unable to solve.
Can someone, please, help me with this? gcc output together with the
files mentioned in the gcc error output follows below. It is about 50
lines all in all, so I'm sure someone out there can find what's wrong
pretty quickly.
Thanks in advance anyone!
Sune
**************** Here is the gcc output *************
[sune@localhost rsd2]$ make all
make all-recursive
make[1]: Entering directory `/home/sune/gnu-ws/rsd2'
Making all in collections
make[2]: Entering directory `/home/sune/gnu-ws/rsd2/collections'
gcc -g -O2 -o collections_test DynamicString.o test_main.o
test_main.o(.rodata+0x0): In function `t1':
/home/sune/gnu-ws/rsd2/collections/test_main.c:12: multiple definition
of `DynamicString_SUCCESS'
DynamicString.o(.rodata+0x0):/home/sune/gnu-ws/rsd2/collections/DynamicString.c:10:
first defined here
test_main.o(.rodata+0x4): In function `t1':
/home/sune/gnu-ws/rsd2/collections/test_main.c:12: multiple definition
of `DynamicString_ERROR'
DynamicString.o(.rodata+0x4):/home/sune/gnu-ws/rsd2/collections/DynamicString.c:10:
first defined here
collect2: ld returned 1 exit status
make[2]: *** [collections_test] Error 1
make[2]: Leaving directory `/home/sune/gnu-ws/rsd2/collections'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/sune/gnu-ws/rsd2'
make: *** [all] Error 2
**************** Here is the beginning of my DynamicString.c file
*************
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include "DynamicString.h"
static const int FILE_ID = 0;
inline void DynamicString_init( DynamicString* string_obj, int trace_id
)
{
string_obj->stack_string[0] = '\0';
string_obj->heap_string = 0;
string_obj->string = 0;
string_obj->size = 0;
string_obj->capacity = DynamicString_stack_string_size;
}
**************** Here is the beginning of my DynamicString.h file
*************
#ifndef DYNAMICSTRING_H_
#define DYNAMICSTRING_H_
#include <stddef.h>
#include "../config.h" // Don't worry about the relative path, I'll
fix it...
const int DynamicString_ERROR=0;
const int DynamicString_SUCCESS=1;
enum { DynamicString_stack_string_size = 256 };
typedef struct DynamicString_
{
char stack_string[ DynamicString_stack_string_size ];
char* heap_string;
char* string;
size_t size;
size_t capacity;
} DynamicString;
**************** Here is the beginning of my test_main.c file
*************
#include <stdio.h>
#include <string.h>
#include "debug/Debug.h"
#include "collections/DynamicString.h"
int
t1(int),t2(int),t3(int),t4(int),t5(int),t6(int),t7(int),t8(int),t9(int),t10(int);
int (*func[])(int) = { t1,t2,t3,t4,t5,t6,t7,t8,t9,t10 };
// Init
int t1( int trace_id )
{
DynamicString string;
DynamicString_init( &string, trace_id );
return 1; // Can't fail!
}