Sign in to follow this  
Cornflake420

Major Linking Problem

Recommended Posts

Cornflake420    138
When I try building my project, I get a very large list of problems. I would list them, but there are literally over 500 errors. My project compiles perfectly fine, but linking it recently started giving me errors like
In function `vector<View, allocator<View> >::begin(void) const':
multiple definition of `__copy_backward_dispatch<Node **, Node **, __true_type>::copy(Node *const *, Node *const *, Node **)'
These aren't functions I wrote myself, but functions that belong to the STL. All of the errors pertain to functions in the STL, which I need in all of my source code files. I can't remove the
#include <stl.h>
lines because that causes the program to fail to compile. If anyone could help me, please respond.

Share this post


Link to post
Share on other sites
Xai    1838
what the hell is #include <stl.h>????

the C++ way is stuff like:

#include <vector>
#include <algorithm>
#include <cctype>

etc ...

show us like the top 15 lines of 2 of your files ... and maybe the top 20 lines of that stl.h file ...

Share this post


Link to post
Share on other sites
Cornflake420    138
Inside "stl.h"

#include <algorithm>
#include <deque>
#include <functional>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <utility>
#include <vector>


Since I only use vectors, I tried replacing "stl.h" with <vector>, but I am still getting the same huge list of problems.

At the top of all of my files, there is a line that includes this:

#ifndef __STDINCS_H__
#define __STDINCS_H__


typedef unsigned char uchar;
typedef unsigned short ushort;
typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned char byte;


#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>


#include <vector>


#define _DEBUG


#include "debug.h"
#include "globals.h"
#include "log.h"
#include "render.h"
#include "scene.h"
#include "vector2.h"
#include "vector3.h"
#include "vector4.h"
#include "vertex.h"
#include "world.h"


#endif // __STDINCS_H__



I have already tried removing the STL inclusion from this file and putting it in only the files that need it, but I am continuing to get the errors.

Share this post


Link to post
Share on other sites
ZQJ    496
What compiler and C++ library are you using?

Edit: along the lines of that thought I'm going to guess you're using Visual C++ and SGI or GNU STL headers. Anyway even if I'm wrong about that my best guess would be the compiler doesn't support template specialisations (or whatever it's called), although I'd expect this to show up in the compiler not the linker not I might be very wide of the mark. The reason I mention it is that VC++6 doesn't have full template support.

Share this post


Link to post
Share on other sites
Cornflake420    138
I am using GCC. It supports templates perfectly fine; the problem is that it gives a huge list of "multiple definition" errors. I know what the problem is, but I don't know how to fix it. Every source file needs STL, so every object file has the functions for the STL compiled in it. Then, when the linker combines the object files into an executable, it finds the same functions in all of the files and gives an error. Five-hundred one errors, actually.

I need a suggestion on how to use the STL in all source files without this problem.

Share this post


Link to post
Share on other sites
Abbacabba    122
Steps I would take:

Clean your build. Most IDE's have a simple option to clean all old files from previous builds. Use that if you have it... else just go delete all the files in your build directory(assumes your build and source are not in the same directory).




Create a new blank project.
Include your stl.h and just do an empty main().. see if that links.
If it does, do some basic stuff with vector and try again.
This could help identify exactally where the break down occurs.


Share this post


Link to post
Share on other sites
Cornflake420    138
I already tried a clean rebuild.

In a simple project, the STL compiles and links without a problem. In my real project, every object file has tons of errors saying that each STL function has already been defined. I need to know some possible causes of the problem.

Share this post


Link to post
Share on other sites
Mantear    251
It sounds like multiple files are trying to include your stl.h file. Try to put header guards in your stl.h file and see if that fixes it.

Share this post


Link to post
Share on other sites
Cornflake420    138
I just fixed the problem, however, I don't know how. I restored an older backup copy of my project and recompiled it. It worked, so I added my newer code back into it and the errors are gone. Because I still don't know why the problem started in the first place, I am still open to suggestions on why the problems occured, but this isn't a big deal anymore.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this