I'm trying to use a library where one of the classes has a constructor like so:
public:
AreaNodeIndex(size_t cacheSize);
I'm trying to instantiate an object of this class in my program like so:
size_t const cacheSize = 50000;
AreaNodeIndex areaNodeIndex(cacheSize);
The linker gives me the following error:
main.o: In function `main':
make: Leaving directory `/home/Dev/_quicktest_build'
main.cpp:(.text+0x212): undefined reference to
osmscout::AreaNodeIndex::AreaNodeIndex(unsigned int)
I think I have the necessary includes and I'm linking to the library with the compiler. For example, if I try to instantiate the object without any arguments on purpose I get this error:
../quicktest/main.cpp: In function ‘int main()’:
../quicktest/main.cpp:36: error: no matching function for call to ‘osmscout::AreaNodeIndex::AreaNodeIndex()’
/usr/local/include/osmscout/AreaNodeIndex.h:75: note: candidates are: osmscout::AreaNodeIndex::AreaNodeIndex(size_t)
/usr/local/include/osmscout/AreaNodeIndex.h:33: note: osmscout::AreaNodeIndex::AreaNodeIndex(const osmscout::AreaNodeIndex&)
So I can see the correct prototype (though here it says size_t and before it said unsigned int)...
I can use other parts of the library fine. Here are the actual source files for the class in question:
I'm pretty lost as to why this is happening. I feel like I've missed something obvious.
*In response to the replies: The library gets size_t from "sys/types.h", so I don't think we're using different versions. The library was compiled on my system with the same compiler (g++, linux). Changing the 'const' specifier location has no effect.
I am linking to the library. As I mentioned, I can use other classes from the library without issue. Here's the linking command:
g++ -Wl,-O1 -Wl,-rpath,/home/QtSDK/Desktop/Qt/473/gcc/lib -o quicktest main.o -L/home/QtSDK/Desktop/Qt/473/gcc/lib -losmscout -lpthread
The library name is 'osmscout'.
kfl