11:26:08 **** Incremental Build of configuration Debug for project T101_FirstAll ****
make all
Building target: T101_FirstAll
Invoking: GCC C++ Linker
g++ -o "T101_FirstAll" ./src/BoundaryCondition.o ./src/CalculateEvaporation.o ./src/CalculateFlowfield.o ./src/FiniteVolume.o ./src/Geometry.o ./src/Meshing.o ./src/Physics.o ./src/PoreThroat.o ./src/T101_FirstAll.o
./src/CalculateEvaporation.o: In function `calculateEvaporation()':
/home/david/Work/KeplerSpace/T101_FirstAll/Debug/../src/CalculateEvaporation.cpp:12: multiple definition of `voidPointer'
./src/BoundaryCondition.o:/home/david/Work/KeplerSpace/T101_FirstAll/Debug/../src/BoundaryCondition.cpp:17: first defined here
./src/CalculateFlowfield.o: In function `calculateFlowfield()':
/home/david/Work/KeplerSpace/T101_FirstAll/Debug/../src/CalculateFlowfield.cpp:13: multiple definition of `voidPointer'
./src/BoundaryCondition.o:/home/david/Work/KeplerSpace/T101_FirstAll/Debug/../src/BoundaryCondition.cpp:17: first defined here
./src/Geometry.o: In function `__gnu_cxx::new_allocator<point_c>::new_allocator()':
/home/david/Work/KeplerSpace/T101_FirstAll/Debug/../src/Geometry.cpp:17: multiple definition of `voidPointer'
./src/BoundaryCondition.o:/home/david/Work/KeplerSpace/T101_FirstAll/Debug/../src/BoundaryCondition.cpp:17: first defined here
./src/Meshing.o: In function `__gnu_cxx::new_allocator<block_c>::new_allocator()':
/home/david/Work/KeplerSpace/T101_FirstAll/Debug/../src/Meshing.cpp:30: multiple definition of `voidPointer'
./src/BoundaryCondition.o:/home/david/Work/KeplerSpace/T101_FirstAll/Debug/../src/BoundaryCondition.cpp:17: first defined here
./src/Physics.o: In function `operator>>(std::istream&, material_c&)':
/home/david/Work/KeplerSpace/T101_FirstAll/Debug/../src/Physics.cpp:13: multiple definition of `voidPointer'
./src/BoundaryCondition.o:/home/david/Work/KeplerSpace/T101_FirstAll/Debug/../src/BoundaryCondition.cpp:17: first defined here
./src/PoreThroat.o: In function `std::vector<unsignedlong, std::allocator<unsignedlong> >::operator[](unsignedlong)':
/home/david/Work/KeplerSpace/T101_FirstAll/Debug/../src/PoreThroat.cpp:17: multiple definition of `voidPointer'
./src/BoundaryCondition.o:/home/david/Work/KeplerSpace/T101_FirstAll/Debug/../src/BoundaryCondition.cpp:17: first defined here
./src/T101_FirstAll.o: In function `__gnu_cxx::new_allocator<throat_c>::new_allocator()':
/home/david/Work/KeplerSpace/T101_FirstAll/Debug/../src/T101_FirstAll.cpp:39: multiple definition of `voidPointer'
./src/BoundaryCondition.o:/home/david/Work/KeplerSpace/T101_FirstAll/Debug/../src/BoundaryCondition.cpp:17: first defined here
collect2: error: ld returned 1 exit status
make: *** [T101_FirstAll] Error 1
11:26:08 Build Finished (took 209ms)
What is at some of the other source references mentioned by the linker?
CalculateEvaporation.cpp:12
CalculateFlowfield.cpp:13
Geometry.cpp:17
Meshing.cpp:30
Physics.cpp:13
PoreThroat.cpp:17
T101_FirstAll.cpp:39
Sorry to be tedious about this, but short of posting all your code, the only option is to drill down piece by piece.
> but short of posting all your code
I would prefer a minimal setup that reproduces the problem, but if that is too much to ask, then posting the full code is the first thing to do.
The first supposition is that you are doing something wrong. To know what you are doing wrong, we need to know what you are doing.
So we need your code, and the commands that you are using to build, and the error messages that you are receiving.
We shouldn't need to ask for them.
> The error lines printed are all where the first function of that file is defined. Very Strange!
the message is not relevant apart from stating the repeated symbol and the object file where it is defined.
As a guess, you've got a variable named `voidPointer' (note, no spaces like in the topic title) that you defined in a header file, instead of declaring it as extern.
All the sources that include that header define the variable on their own, and then clash.
ne555, How did you know? You are real amazing! Thanks!!!
Yes, I defined a constvoid* voidPointer(0);
After I comment it, everything is fine now.
But I am wondering, this is a const. And when it is const, there should be no need to use extern, right? All my other const didn't use extern and got no problems. Why?
> Yes, I defined a constvoid* voidPointer(0);
> But I am wondering, this is a const. And when it is const, there should be no need to use extern, right?
It is not a const. It is a non-const pointer to const void.
This is a const pointer to const void: constvoid* const pointer = nullptr ;