creekmax
September 12th, 2009, 04:05 AM
Hi All,
I've been fussing over a library problem for most of the day, have searched forums, etc. and have not found anything helpful. I'm working with the SIMD Viterbi Decoder library from http://freshmeat.net/projects/simd-viterbi/. Here's a little program that should do little more than verify the existence of the library:
#include "viterbi27.h"
using namespace std;
int main()
{
void *v_ptr;
int status;
v_ptr = create_viterbi27(240);
status = init_viterbi27(v_ptr, 0);
delete_viterbi27(v_ptr);
return(0);
}
My attempt to compile the program results in the following:
>> g++ -g -Wall -o viterbi -lviterbi main.cpp
/tmp/ccwC05Gs.o: In function `main':
/home/creekmax/sandbox/viterbi/main.cpp:11: undefined reference to `create_viterbi27(int)'
/home/creekmax/sandbox/viterbi/main.cpp:12: undefined reference to `init_viterbi27(void*, int)'
/home/creekmax/sandbox/viterbi/main.cpp:13: undefined reference to `delete_viterbi27(void*)'
collect2: ld returned 1 exit statusAll three library functions are not defined. As you can see, there's no error regarding the header file, and there's no error regarding the "viterbi" library that I specified. I'm not a career programmer, but as far as I know, this means that the compiler found both the header file and the library, found the function prototypes in the header file, but did not find definitions for the funcitons in the library.
Why wouldn't these functions be in the library?
When I build the library's source code, I see the proper source files being compiled and included:
>> make
gcc -c -g -O2 -I. -Wall -march=i686 -DSSE2=1 -o viterbi27sse2.o viterbi27.c
as -o sse2bfly27.o sse2bfly27.s
gcc -c -g -O2 -I. -Wall -march=i686 -DSSE2=1 -o viterbi29sse2.o viterbi29.c
as -o sse2bfly29.o sse2bfly29.s
as -o cpu_features.o cpu_features.s
ar rv libviterbi_sse2.a viterbi27sse2.o sse2bfly27.o viterbi29sse2.o sse2bfly29.o cpu_features.o
ar: creating libviterbi_sse2.a
a - viterbi27sse2.o
a - sse2bfly27.o
a - viterbi29sse2.o
a - sse2bfly29.o
a - cpu_features.o
gcc -shared -Xlinker -soname=libviterbi.so.2 -o libviterbi.so.2.0.1 -Wl,-whole-archive libviterbi_sse2.a -Wl,-no-whole-archive -lc
(NOTE: Yes, this output says the library name is "libviterbi_sse2.a", but the installation process creates a symbolic link to the library with the name "libviterbi.a". I've tried linking to each.)
I've examined viterbi27.c, and it does define the functions I'm calling. I've also searched my file system, and there are no other instances of these file names; I'm fairly certain the compiler is linking to the correct library.
I'm at a loss. Any ideas?
Thanks.
I've been fussing over a library problem for most of the day, have searched forums, etc. and have not found anything helpful. I'm working with the SIMD Viterbi Decoder library from http://freshmeat.net/projects/simd-viterbi/. Here's a little program that should do little more than verify the existence of the library:
#include "viterbi27.h"
using namespace std;
int main()
{
void *v_ptr;
int status;
v_ptr = create_viterbi27(240);
status = init_viterbi27(v_ptr, 0);
delete_viterbi27(v_ptr);
return(0);
}
My attempt to compile the program results in the following:
>> g++ -g -Wall -o viterbi -lviterbi main.cpp
/tmp/ccwC05Gs.o: In function `main':
/home/creekmax/sandbox/viterbi/main.cpp:11: undefined reference to `create_viterbi27(int)'
/home/creekmax/sandbox/viterbi/main.cpp:12: undefined reference to `init_viterbi27(void*, int)'
/home/creekmax/sandbox/viterbi/main.cpp:13: undefined reference to `delete_viterbi27(void*)'
collect2: ld returned 1 exit statusAll three library functions are not defined. As you can see, there's no error regarding the header file, and there's no error regarding the "viterbi" library that I specified. I'm not a career programmer, but as far as I know, this means that the compiler found both the header file and the library, found the function prototypes in the header file, but did not find definitions for the funcitons in the library.
Why wouldn't these functions be in the library?
When I build the library's source code, I see the proper source files being compiled and included:
>> make
gcc -c -g -O2 -I. -Wall -march=i686 -DSSE2=1 -o viterbi27sse2.o viterbi27.c
as -o sse2bfly27.o sse2bfly27.s
gcc -c -g -O2 -I. -Wall -march=i686 -DSSE2=1 -o viterbi29sse2.o viterbi29.c
as -o sse2bfly29.o sse2bfly29.s
as -o cpu_features.o cpu_features.s
ar rv libviterbi_sse2.a viterbi27sse2.o sse2bfly27.o viterbi29sse2.o sse2bfly29.o cpu_features.o
ar: creating libviterbi_sse2.a
a - viterbi27sse2.o
a - sse2bfly27.o
a - viterbi29sse2.o
a - sse2bfly29.o
a - cpu_features.o
gcc -shared -Xlinker -soname=libviterbi.so.2 -o libviterbi.so.2.0.1 -Wl,-whole-archive libviterbi_sse2.a -Wl,-no-whole-archive -lc
(NOTE: Yes, this output says the library name is "libviterbi_sse2.a", but the installation process creates a symbolic link to the library with the name "libviterbi.a". I've tried linking to each.)
I've examined viterbi27.c, and it does define the functions I'm calling. I've also searched my file system, and there are no other instances of these file names; I'm fairly certain the compiler is linking to the correct library.
I'm at a loss. Any ideas?
Thanks.