Hello you guys, i'm new to this community and relatively new to c++.
right now i have a big problem with namespaces and i'm not able to resolve this issue on my own, so here we go:

I want to integrate 2 simmilar projects into my project. they are so simmilar, that they have the same class names, so i had to put them into different namespaces. first i tried to put just one into a specified namespace "os", but that didnt work out, so i put the second one into the namespace "cs":

#ifndef INTEGRAL_H
#define INTEGRAL_H

namespace cs {
 cudaImage* Integral(IplImage *src);
}
#endif /* INTEGRAL_H */
#include "integral.h"

namespace cs {
 cudaImage* Integral(IplImage *src) {
  ...
 }
}
#ifndef OINTEGRAL_H
#define OINTEGRAL_H

namespace os {

 IplImage *Integral(IplImage *img);

 inline float BoxIntegral(IplImage *img, int row, int col, int rows, int cols) 
 {
  ...
 }
}
#endif
#include "integral.h"
namespace os {
 IplImage *Integral(IplImage *source)
 {
   ...
 }
}

in my main class i import both files (lying in different folders, lets call them a and b)

#include "a/integral.h"
#include "b/integral.h"

int main(int argc, char** argv[])
{
 os::Integral(image);
 cs::Integral(image);
}

but i still get the following error:

error LNK2019: unresolved external symbol "struct cudaImage * __cdecl cs::Integral(struct _IplImage *)" (?Integral@cs@@YAPAUcudaImage@@PAU_IplImage@@@Z) referenced in function "private: int __thiscall myclass:myfunction(struct _IplImage *,struct _IplImage *,struct CvMat * *,struct CvMat * *,float)" (?myfunction@myclass@@AAEHPAU_IplImage@@0PAPAUCvMat@@1M@Z)

btw: im using visual studio 2008 and i'm really desperate. please help me! :)

Recommended Answers

All 3 Replies

Unless I am mistaken you haven't provided the source that the linker is complaining about.

Hi,

I think you are giving same file name for both namespace declaration files (Integral). when VS compiles, it replaces one object file with another so when it tries to link one obj file will be missing it will lead to linker error. so try it with different file names.

Regards,

Thank you both for your answers and thank you play_c even more :)

renaming the files totally did the trick. i wasted so many hours on trying to find the error and would have wasted much more without your help. thank you so much!

best regards

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.