aspell compilation problems

Hi, I tried to post on the forum but it kept coming up with an internal error so i was wondering if you could help me with the following:I have recently been trying to compile aspell (a spell checker written in c and c++) in visual studio .NET (2003) which has taken forever but i managed to get it to compile a dll now. When i come to add this dll file into another project which will be using the methods from this dll it keeps giving the following error and not allowing me to add it: "Add Reference: Error adding reference to the project.". Does anyone have any suggestions on how to overcome this?Any information would be much appreciated.Thanks
[661 byte] By [bijie85] at [2007-12-20]
# 1

There's a difference between plain DLL's and .NET assemblies (which can be through DLL's). Add Reference makes a reference to a .NET assembly. Chances are you're working with a plain DLL.

The DLL should have a header that your executable build uses (which prototype functions exported from the DLL), and an import library (aspell.lib?) that your executable build links against. You specify this under Project Properties->Linker->Input->Additional Dependencies.

Brian

BrianKramer at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 2
when i have come to compile aspell (a spell checker written in c and c++) i keep getting the following errors which i think might be affecting the dll file produced. Does anyone think this will be affecting the compilation of the dll file? in the solution there are 3 projects aspell which creates the dll acompress which creates an exe file used to compress the word file in the spell checker and aspellcmd which is the command line interface. it is in the aspellcmd project that i get the errors one of the errors is shown below but they are all practically the same:aspellcmd error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall acommon::CopyPtr<class acommon::DocumentChecker>::~CopyPtr<class acommon::DocumentChecker>(void)" (__imp_?1?$CopyPtr@VDocumentChecker@acommon@@@acommon@@QAE@XZ) referenced in function __unwindfunclet$?0CheckerString@@QAE@PAUAspellSpeller@@PAU_iobuf@@1H@Z$0does anyone know how to overcome this error?any information given would be much appreciated.cheersshaun
bijie85 at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 3

CopyPtr is a template that appears to lack a destructor. Can you define one?

BrianKramer at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 4
Hi i have tried adding this as a destructor:
~CopyPtr(){delete impl;};
i now dont get any build errors when i run the debug and it calls my exe file but when i build the solution i still get the below error:

aspellcmd error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall acommon::CopyPtr<class acommon::DocumentChecker>::~CopyPtr<class acommon::DocumentChecker>(void)" (__imp_?1?$CopyPtr@VDocumentChecker@acommon@@@acommon@@QAE@XZ) referenced in function __unwindfunclet$?0CheckerString@@QAE@PAUAspellSpeller@@PAU_iobuf@@1H@Z$0

bijie85 at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 5
i do also get these errors:

aspellcmd error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall acommon::CopyPtr&lt;class acommon::DocumentChecker&gt;::CopyPtr&lt;class acommon::DocumentChecker&gt;(class acommon::DocumentChecker *)" (__imp_?0?$CopyPtr@VDocumentChecker@acommon@@@acommon@@QAE@PAVDocumentChecker@1@@Z) referenced in function "public: __thiscall CheckerString::CheckerString(struct AspellSpeller *,struct _iobuf *,struct _iobuf *,int)" (?0CheckerString@@QAE@PAUAspellSpeller@@PAU_iobuf@@1H@Z)

aspellcmd error LNK2019: unresolved external symbol "__declspec(dllimport) public: class acommon::DocumentChecker * __thiscall acommon::CopyPtr&lt;class acommon::DocumentChecker&gt;::operator-&gt;(void)const " (__imp_?C?$CopyPtr@VDocumentChecker@acommon@@@acommon@@QBEPAVDocumentChecker@1@XZ) referenced in function "public: __thiscall CheckerString::CheckerString(struct AspellSpeller *,struct _iobuf *,struct _iobuf *,int)" (?0CheckerString@@QAE@PAUAspellSpeller@@PAU_iobuf@@1H@Z)

aspellcmd error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall acommon::CopyPtr&lt;class acommon::DocumentChecker&gt;::reset(class acommon::DocumentChecker *)" (__imp_?reset@?$CopyPtr@VDocumentChecker@acommon@@@acommon@@QAEXPAVDocumentChecker@2@@Z) referenced in function "public: __thiscall CheckerString::CheckerString(struct AspellSpeller *,struct _iobuf *,struct _iobuf *,int)" (?0CheckerString@@QAE@PAUAspellSpeller@@PAU_iobuf@@1H@Z)Not sure if this helps explain what is happening better

bijie85 at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 6

You class methods need to be exported from the dll. I would read up on the topic:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore/html/_core_export_from_a_dll_usingdeclspec.28.dllexport.29.asp

BrianKramer at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 7
hi i am looking at that website but am unsure where to add the dllexport statements. As there are a lot of classes. Are you familiar with aspell yourself? Do you know where they should be added by any chance?
bijie85 at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 8

The usual way class definitions are exported is to prepend "class Foo" with __declspec(dllexport). Since this header is used by both the build of the DLL and the client code, a macro is introduced that evaluates to either __declspec(dllexport) or empty (or __declspec(dllimport), but that's a more advanced topic).

To see this, use the Win32 DLL wizard in Visual Studio to create a DLL project from scratch: the wizard sets this up for you. Maybe aspell is doing this already, but the macro needed to enable __declspec(dllexport) is not being defined in the build of aspell.

Brian

BrianKramer at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 9
Hi i have now added these lines into the class "checker_string.cpp" as i need the methods in the lines:
__declspec(dllexport) void __cdecl CheckerString::replace(ParmString repl);
__declspec(dllexport) bool __cdecl CheckerString::next_misspelling();

however i now get the errors come up when i compile the project:

c:\Documents and Settings\Shaun\Desktop\aspell-win32\prog\checker_string.cpp(16): error C2761: 'bool CheckerString::next_misspelling(void)' : member function redeclaration not allowed

c:\Documents and Settings\Shaun\Desktop\aspell-win32\prog\checker_string.cpp(15): error C2761: 'void CheckerString::replace(acommon::ParmString)' : member function redeclaration not allowed

im guessing this is because there is no main method where they are used but are declared as their own methods further down the code. p.s. i have tried adding them in different parts of the class but there is no change.

bijie85 at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 10
ah ha i have fixed that. just found the declaration of each method and put the dll export line in that. however i am still getting the link errors i mentioned above. everything i have tried just doesnt seem to work. i have tried including the aspell.lib file.
bijie85 at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 11
I have also now entered the code to allow me to import the dll functions in my exe file. However i also get the link error come up when i try to use any of the methods in my code and build it.
bijie85 at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 12

Just put __declspec(dllexport) before "class" and every method will be exported. (I have said this.)

Make sure you really are using the right version of the lib (the one you just built).

Go to the Visual Studio 2005 Command Prompt (under Tools), find your DLL, and type:

dumpbin -exports aspell.dll

This should verify that your methods are being exported.

Brian

BrianKramer at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 13
Hi apologies for being slow i did not notice the class thing.
I am actually still only running visual studio 2003. However i now no longer get those errors i now get:

aspellcmd fatal error LNK1141: failure during build of exports file
aspellcmd fatal error LNK1149: output filename matches input filename 'c:\Documents and Settings\Shaun\Desktop\aspell-win32\Debug\aspell.lib'

which i have found confusing because as far as i know i need the aspell.lib file included in the project.

bijie85 at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 14

You're making settings in an attempt to fix the problem that are causing other problems. The MSDN docs for LNK1149 makes it pretty clear on what the solution is.

Fix the LNK1149 and see if the problem goes away.

To be sure you're on track, ASPELL.LIB is not "included" like header files are. They are added to the linker settings. (Project Properties->Linker->Input->Additional Dependencies.)

Brian

BrianKramer at 2007-9-9 > top of Msdn Tech,Visual C++,Visual C++ Language...