views:

24

answers:

2

I have taken out some functions from a source file into another since I want to use them also in other files. The current structure is as follows

utils/extFuncs.h

#ifndef _extFuncs_h
#define _extFuncs_h
inline int someFunction (float v);
#endif

utils/extFuncs.cpp

#include "utils/extFuncs.h"
inline int someFunction (float v) {
    return 42;
}

foo/bar.h

#ifndef _bar_h
#define _bar_h
#include "utils/extFuncs.h"
class Bar {
public:
    Bar (float x);
};
#endif

foo/bar.cpp

#include "foo/bar.h"
Bar::Bar (float x) {
    int y = someFunction(x);
}

Problem is, that when I try to compile this, the linker complains and says that the symbol someFunction could not be resolved.

A: 

Have you tried to add the extFunction.h & extFunction.cpp into your project workspace?

wengseng
everything is in the same solution, however in different subfolders.
Etan
+2  A: 

someFunction is declared inline, so it must be defined in your header file:

utils/extFuncs.h

#ifndef _extFuncs_h
#define _extFuncs_h
inline int someFunction (float v)
{
    return 42;
}
#endif
Frédéric Hamidi