I've been working on this program and it grew very large, so I split it up into individual files. Now I'm trying to set it up with make, but I keep getting this error:
Code:
g++ -c -o test.o test.cpp
g++ -c -o test_config.o test_config.cpp
g++ -o make_test main.o test.o test_config.o
test_config.o:(.bss+0x0): multiple definition of `FVAR'
test.o:(.bss+0x0): first defined here
test_config.o:(.bss+0x4): multiple definition of `SVAR'
test.o:(.bss+0x4): first defined here
collect2: ld returned 1 exit status
make: *** [all] Error 1
These are defined in one header file 'test_options.h' and both test.cpp and test_config.cpp include this file. I used the #ifndef, #define statements, and make 'seems' to ignore this. Here's 'test_options.h':
Code:
#ifndef _TEST_OPTIONS_H
#define _TEST_OPTIONS_H
#include <string>
string FVAR = "FirstVar";
string SVAR = "SecondVar";
#endif
Does anyone know how to fix this?
I tried simply removing '#include "test_options.h"' from the main_config.cpp file, since you would think that it is already included since test.cpp has already included it, but when I do this I get this error:
Code:
g++ -c -o main.o main.cpp
g++ -c -o test.o test.cpp
g++ -c -o test_config.o test_config.cpp
test_config.cpp: In function ‘int Test_Config(std::string)’:
test_config.cpp:9: error: ‘FVAR’ was not declared in this scope
test_config.cpp:10: error: ‘SVAR’ was not declared in this scope
make: *** [test_config.o] Error 1
Any help would be greatly appreciated.
Thanks in advance,
Bendeco