It seems that since I re-installed C::B(now using 3455) and cygwin(fresh install of both), all of my projects fail during the linking stage. I'm not sure whether this is a Cygwin-GCC problem, or a C::B problem. However, C::B should be able to fix what I describe below.
The problem is the order of object files given to the linker. Noramlly, files with the most dependencies go first, while files with no dependencies go last. This ensures that the linker links all external functions and data.
Output:
-------------- Build: Debug in libBSException ---------------
g++.exe -Wall -DLIBBSEXCEPTION_EXPORTS -g -DDEBUG -DWIN32 -ID:/Projects/libBSException/ -c NullPointer.cpp -o .objs/Debug/NullPointer.o
g++.exe -Wall -DLIBBSEXCEPTION_EXPORTS -g -DDEBUG -DWIN32 -ID:/Projects/libBSException/ -c NullPointerNF.cpp -o .objs/Debug/NullPointerNF.o
g++.exe -Wall -DLIBBSEXCEPTION_EXPORTS -g -DDEBUG -DWIN32 -ID:/Projects/libBSException/ -c Exception.cpp -o .objs/Debug/Exception.o
g++.exe -shared -Wl,--dll -L .objs/Debug/NullPointer.o .objs/Debug/NullPointerNF.o .objs/Debug/Exception.o -o bin/libBSException_d.dll
.objs/Debug/NullPointerNF.o: In function `_ZN2BS10Exceptions13NullPointerNFD0Ev':
/cygdrive/d/Projects/libBSException/NullPointerNF.cpp:(.text+0x14): undefined reference to `BS::Exceptions::NullPointer::NullPointer(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
.objs/Debug/NullPointerNF.o: In function `_ZN2BS10Exceptions13NullPointerNFC1ERKSs':
/cygdrive/d/Projects/libBSException/NullPointerNF.cpp:4: undefined reference to `BS::Exceptions::NullPointer::NullPointer(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
.objs/Debug/NullPointerNF.o: In function `_ZN2BS10Exceptions13NullPointerNFD0Ev':
/cygdrive/d/Projects/libBSException/NullPointerNF.cpp:(.text$_ZN2BS10Exceptions11NullPointerD2Ev[BS::Exceptions::NullPointer::~NullPointer()]+0xb): undefined reference to `vtable for BS::Exceptions::NullPointer'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 2 seconds)
1 errors, 0 warnings
This is the output of one of my smaller projects. As you can see, the linker is given a list of object files in alphabetical order, which is incorrect. The
NullPointerNF.o file should be first, because it has dependencies in
NullPointer.o and
Exception.o. I can manually fix this, but this requires me to change the compilation priority of all my files in every project. Normally, link dependencies can be assumed in such a way: if object A's source includes object B's header, then object A can be assumed to depend on object B, and should therefore come before B on the link command.
Maybe theres a new GCC option that will alleviate this easier? Get back to me, please.