I am trying to get a very simple program to compile while using functions from libpano13, but I am running into linking errors. I am on Ubuntu 10.04, and have done the following:
sudo apt-get install libpano13-dev
My sample program is as follows:
#include <cstring>
#include <pano13/PTcommon.h>
int main(int argc, char **argv) {
fullPath *outFile = new fullPath();
StringtoFullPath(outFile, (char *)"/tmp/randomImage.jpg");
return 0;
}
I am attempting to compile this with the following command (the above code is located in a file called panoTest.cpp):
$ g++ panoTest.cpp -o testApp -L/usr/lib -lpano13
When I run this command I get the following error:
$ g++ panoTest.cpp -o testApp -L/usr/lib -lpano13
/tmp/ccyIioEi.o: In function `main':
panoTest.cpp:(.text+0x87): undefined reference to `StringtoFullPath(fullPath*, char*)'
collect2: ld returned 1 exit status
make: *** [all] Error 1
Now, I’ve checked /usr/lib for libpano* and found the following files:
$ ls /usr/lib/libpano*
/usr/lib/libpano13.a /usr/lib/libpano13.so /usr/lib/libpano13.so.1
/usr/lib/libpano13.so.1.0.0
I’ve checked libpano13.so using nm and got the following output:
$ nm --demangle /usr/lib/libpano13.a | grep StringtoFullPath
U StringtoFullPath
U StringtoFullPath
00000000 T StringtoFullPath
$ nm --demangle /usr/lib/libpano13.so | grep StringtoFullPath
nm: /usr/lib/libpano13.so: no symbols
I also checked it using objdump:
$ objdump -T /usr/lib/libpano13.so | grep StringtoFullPath
00057fd0 g DF .text 0000004c Base StringtoFullPath
So, the following seems to be true:
- libpano13 exists in /usr/lib,
- libpano13 contains the symbols for StringtoFullPath,
- I am using the correct library directory of /usr/lib,
- I am using the correct library name of pano13, and
- g++ is able to locate the library
But, for some reason, g++ is unable to find the symbol for StringtoFullPath.
Does anyone have any suggestions/ideas about why this is happening?
Any help would be greatly appreciated!
The
worries me a bit: it contains the types of the parameters. Most Linux libraries are not C++, so there should be no types…
Try surrounding the #include for the header with an extern “C” { … } block.