undefined reference to... when calling an inline function in a shared library

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I've encountered the following problem:

Shared library code is:
foo.h:
class Foo
{
public:
   bool Nothing(void);
};

foo.cpp:
#include "foo.h"

inline bool Foo::Nothing(void)
{
   return true;
}

I create the library using this command line: g++ foo.cpp -shared -o libfoo.so

Executable code is:
main.cpp:
#include <iostream>
#include "foo.h"

using namespace std;

int main(void)
{
   Foo f;
   cout << f.Nothing() << endl;
   return 0;
}

I create the executable using this command line: g++ main.cpp -o main -L. -Wl,-rpath,. -lfoo
And I get:
undefined reference to 'Foo::Nothing()'

What am I doing  wrong?
How can I expose an inline function WITHOUT implementing it in the header file?


GCC version: 4.1.2 20080704 (Red Hat 4.1.2-44)
Target: i386-redhat-linux

Thanks!

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux