Jump to content
  • Advertisement
Sign in to follow this  
Cornflake420

Major Linking Problem

This topic is 4736 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
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
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
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
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
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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!