I have successufully compiled my spellcheck program and libspellcheck library. Now my problem is allowing other developers to use my libspellcheck. I created a simple test program:
#include <spellcheck.h>
#include <iostream>
using namespace std;
int main(void)
{
bool spell_result = check_spelling("english.dict", "abed");
if(spell_result == true)
{
cout << "your dictionary / libspellcheck works!" << endl;
}
else
{
cout << "problem with your dictionary / libspellcheck" << endl;
}
return 0;
}
If everything is functioning fine, the program will output:
your dictionary / libspellcheck works
However, this program won’t even compile. I used:
g++ -lspellcheck -o test test.cpp
And it did not work. I believe this is a problem with the header file, as the compiler gives me this:
test.cpp: In function ‘int main()’:
test.cpp:9:59: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
test.cpp:9:59: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
/tmp/ccIz3ivT.o: In function `main':
test.cpp:(.text+0x19): undefined reference to `check_spelling(char*, char*)'
collect2: ld returned 1 exit status
The only problem is, spellcheck.h is located in /usr/include, which is where I believe it should be. My question is, how do I fix this error, and was a it a problem with my header file or was it a problem with my libspellcheck. If you need to look at additional code, I will gladly provide it, as spellcheck and libspellcheck are licensed under the GPL.
Assuming your
check_spellingdeclaration in header is correct, try this:(
-lshould be after the objects depending on the libraries in the command line). As of the header, it is indeed found and used, or you would get an error from the compiler, not the linker.