Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
234 views
in Technique[技术] by (71.8m points)

visual studio - C++ Newbie: Having all sorts of problems linking

I am having several problems with tessdll in Visual Studio 2008. FYI, I created this app as an MFC application, I did this just to take advantage of the simple GUI I needed. It is just straight C++ and win32 from there on out.

This builds fine as a debug release for some reason (as I have included the header files and lib files that I need, and dll resides in every directory I could put it......).

So, there is a linking problem during building a release version:

Linking...
MTGOBot.obj : error LNK2001: unresolved external symbol "__declspec
(dllimport) public: __thiscall TessDllAPI::TessDllAPI(char const
*)" (__imp_??0TessDllAPI@@QAE@PBD@Z)
MTGOBot.obj : error LNK2001: unresolved external symbol "__declspec
(dllimport) public: __thiscall TessDllAPI::~TessDllAPI(void)" (__imp_??
1TessDllAPI@@QAE@XZ)
MTGOBot.obj : error LNK2001: unresolved external symbol "__declspec
(dllimport) public: int __thiscall TessDllAPI::BeginPage(unsigned
int,unsigned int,unsigned char *,unsigned char)" (__imp_?
BeginPage@TessDllAPI@@QAEHIIPAEE@Z)
MTGOBot.obj : error LNK2001: unresolved external symbol "__declspec
(dllimport) public: struct ETEXT_STRUCT * __thiscall
TessDllAPI::Recognize_all_Words(void)" (__imp_?
Recognize_all_Words@TessDllAPI@@QAEPAUETEXT_STRUCT@@XZ)
C:CPP ProjectsVisual Studio 2008ProjectsMTGO SO BotMTGO SO Bot
ReleaseMTGO SO Bot.exe : fatal error LNK1120: 4 unresolved externals 

Also, for reference, the source to tessdll.h can be found here: http://code.google.com/p/tesseract-ocr/source/browse/trunk/tessdll.h?r=165

A few more details:

  • I debug by from the toolbar and use the integrated debugger.
  • I use Batch Build to create the release version.
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

A first guess: You did not use the link-library for the DLL. The linker shouts about not finding some symbols, and TessDllAPI sound very much like a DLL. By default (read: on Project Settings Dialog Startup) all your project settings are specific to the build-configuration (Debug, Release), but you can select "All Configurations" from the GUI. This would explain why it works in one configuration, but not in another.

Try a

#pragma comment(lib:"tessdll")
// (Of course you need to replace the `tessdll` with the name of the library.)

in the header-file, or add this library for linking in the "Release" configuration.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...