2012-02-16 19 views
1

XPでeclipseを使用して書かれたC++プログラムでサードパーティのSDKを使用しようとすると、上記のエラーが発生します。検索に基づいて、私はこのエラーが.dllまたは.libを正しく指していないリンカによって引き起こされることを理解しています。これらの項目へのパスは環境変数-PATHに、またプロパティ\ C/C++ビルド\設定\ MinGW C++リンカー\ライブラリの下のeclipseにも含まれています。これらの項目の両方のために使用されるパスは、C:\ Program Files \カードスキャンソリューション\ SDK'_imp__InitBizLib'への未定義の参照

は、ここでコンソール出力されます。

**** Build of configuration Debug for project HelloWorld **** 

**** Internal Builder is used for build    **** 
g++ -IC:\Program Files\Card Scanning Solutions\SDK -O0 -g3 -Wall -c -fmessage-length=0 -lm -v -o src\BizScan.o ..\src\BizScan.cpp 
Using built-in specs. 
COLLECT_GCC=g++ 
COLLECT_LTO_WRAPPER=c:/mingw/bin/../libexec/gcc/mingw32/4.6.1/lto-wrapper.exe 
Target: mingw32 
Configured with: ../gcc-4.6.1/configure --enable-languages=c,c++,fortran,objc,obj-c++ --disable-sjlj-exceptions --with-dwarf2 --enable-shared --enable-libgomp --disable-win32-registry --enable-libstdcxx-debug --enable-version-specific-runtime-libs --build=mingw32 --prefix=/mingw 
Thread model: win32 
gcc version 4.6.1 (GCC) 
COLLECT_GCC_OPTIONS='-I' 'C:\Program Files\Card Scanning Solutions\SDK' '-O0' '-g3' '-Wall' '-c' '-fmessage-length=0' '-v' '-o' 'src\BizScan.o' '-shared-libgcc' '-mtune=i386' '-march=i386' 
c:/mingw/bin/../libexec/gcc/mingw32/4.6.1/cc1plus.exe -quiet -v -I C:\Program Files\Card Scanning Solutions\SDK -iprefix c:\mingw\bin\../lib/gcc/mingw32/4.6.1/ -dD ..\src\BizScan.cpp -quiet -dumpbase BizScan.cpp -mtune=i386 -march=i386 -auxbase-strip src\BizScan.o -g3 -O0 -Wall -version -fmessage-length=0 -o C:\DOCUME~1\Game\LOCALS~1\Temp\ccwufpbm.s 
GNU C++ (GCC) version 4.6.1 (mingw32) 
    compiled by GNU C version 4.6.1, GMP version 5.0.1, MPFR version 2.4.1, MPC version 0.8.1 
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=65307 
ignoring nonexistent directory "c:\mingw\bin\../lib/gcc/mingw32/4.6.1/../../../../mingw32/include" 
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.6.1/include/c++" 
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.6.1/include/c++/mingw32" 
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.6.1/include/c++/backward" 
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.6.1/include" 
ignoring duplicate directory "/mingw/lib/gcc/mingw32/4.6.1/../../../../include" 
ignoring duplicate directory "c:/mingw/lib/gcc/../../include" 
ignoring duplicate directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.6.1/include-fixed" 
ignoring nonexistent directory "c:/mingw/lib/gcc/../../lib/gcc/mingw32/4.6.1/../../../../mingw32/include" 
ignoring duplicate directory "/mingw/include" 
#include "..." search starts here: 
#include <...> search starts here: 
C:\Program Files\Card Scanning Solutions\SDK 
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++ 
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/mingw32 
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include/c++/backward 
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include 
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/../../../../include 
c:\mingw\bin\../lib/gcc/mingw32/4.6.1/include-fixed 
End of search list. 
GNU C++ (GCC) version 4.6.1 (mingw32) 
    compiled by GNU C version 4.6.1, GMP version 5.0.1, MPFR version 2.4.1, MPC version 0.8.1 
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=65307 
Compiler executable checksum: 8e56a7b4b7f3db333ff95dd4b2d788a4 
COLLECT_GCC_OPTIONS='-I' 'C:\Program Files\Card Scanning Solutions\SDK' '-O0' '-g3' '-Wall' '-c' '-fmessage-length=0' '-v' '-o' 'src\BizScan.o' '-shared-libgcc' '-mtune=i386' '-march=i386' 
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/as.exe -o src\BizScan.o C:\DOCUME~1\Game\LOCALS~1\Temp\ccwufpbm.s 
COMPILER_PATH=c:/mingw/bin/../libexec/gcc/mingw32/4.6.1/;c:/mingw/bin/../libexec/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ 
LIBRARY_PATH=c:/mingw/bin/../lib/gcc/mingw32/4.6.1/;c:/mingw/bin/../lib/gcc/;c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/lib/;c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../;/mingw/lib/ 
COLLECT_GCC_OPTIONS='-I' 'C:\Program Files\Card Scanning Solutions\SDK' '-O0' '-g3' '-Wall' '-c' '-fmessage-length=0' '-v' '-o' 'src\BizScan.o' '-shared-libgcc' '-mtune=i386' '-march=i386' 
g++ -LC:\Program Files\Card Scanning Solutions\SDK -lm -o HelloWorld.exe src\HelloWorld.o src\BizScan.o 
src\BizScan.o: In function `ZN7BizScan4InitEv': 
C:\Documents and Settings\Game\workspace\HelloWorld\Debug/../src/BizScan.cpp:20: undefined reference to `_imp__UseFixedModel' 
C:\Documents and Settings\Game\workspace\HelloWorld\Debug/../src/BizScan.cpp:22: undefined reference to `_imp__SetTwainScanner' 
C:\Documents and Settings\Game\workspace\HelloWorld\Debug/../src/BizScan.cpp:23: undefined reference to `_imp__InitScanLib' 
C:\Documents and Settings\Game\workspace\HelloWorld\Debug/../src/BizScan.cpp:27: undefined reference to `_imp__InitImageLib' 
C:\Documents and Settings\Game\workspace\HelloWorld\Debug/../src/BizScan.cpp:31: undefined reference to `_imp__InitBizLib' 
src\BizScan.o: In function `~BizScan': 
C:\Documents and Settings\Game\workspace\HelloWorld\Debug/../src/BizScan.cpp:39: undefined reference to `_imp__UnInitScanLib' 
collect2: ld returned 1 exit status 
Build error occurred, build is stopped 
Time consumed: 5648 ms. 

ここではBizScan.cppです:

/* 
* BizScan.cpp 
* 
* Created on: Feb 13, 2012 
*  Author: TFB 
*/ 

#include "BizScan.h" 
#include "slibexp.h" // ScanLib SDK header file 
#include "..\header_lib\BizExp.h" // ScanLib SDK header file 
#include "..\header_lib\ImageExp.h" // ScanLib SDK header file 
#include "CSSN.h" 
#include "windef.h" 

BizScan::BizScan() { 
    BizScan::Init(); 
} 

const char* BizScan::Init() { 
    UseFixedModel(11); 
    const char *scannerSelected = "WIA-A6 Scanner 735"; 
    int result = SetTwainScanner(scannerSelected); 
    result = InitScanLib(CSSN::GetSDKLicense().c_str()); 
    if(result < 0 && result != -13){ 
     return ScannerErrors(result); 
    } else { 
     result = InitImageLib(CSSN::GetSDKLicense().c_str());//initialize Image Lib SDK 
     if(result < 0 && result != -13)//if error 
      return ImageErrors(result);//call image lib sdk 

     result = InitBizLib(CSSN::GetSDKLicense().c_str());//initialize Biz Card Lib Scanner SDK 
     if(result < 0 && result != -13)//if error 
      return BizErrors(result);//call biz card scanner Lib SDK error handler 
    } 
    return "Successful Initialization !!"; 
} 

BizScan::~BizScan() { 
    UnInitScanLib(); 
} 

ここBizScan.hは次のとおりです。

/* 
* BizScan.h 
* 
* Created on: Feb 13, 2012 
*  Author: TFB 
*/ 

#ifndef BIZSCAN_H_ 
#define BIZSCAN_H_ 

#include "windef.h" 

typedef HINSTANCE hDLL; 

class BizScan { 
private: 

public: 
    BizScan(); 
    virtual ~BizScan(); 
    const char* Init() ; 
}; 

#endif /* BIZSCAN_H_ */ 

そして、ここではslibexp.hの関連する部分である。

/*///////////////////////////////////////////////////////////////////// 
// 
// SLibExp.h 
// 
// Card Scanning Solutions (LLC) 
// All Rights Reserved 
// 
/////////////////////////////////////////////////////////////////////*/ 
#ifndef SLIBEXP_H 
#define SLIBEXP_H 


#ifdef SDLL 
#define SDLL_EXP __declspec(dllexport) 
#else 
#define SDLL_EXP __declspec(dllimport) 
#endif 

// Functions Prototypes 
#if defined __cplusplus || defined c_plusplus 
extern "C" 
{ 
#endif 

SDLL_EXP void UseFixedModel(int val); 
SDLL_EXP short SetTwainScanner(const char *szStr); 
SDLL_EXP short InitScanLib(const char * license); 
IMAGE_EXPORT short InitImageLib(const char *licanse); 
SDLL_EXP short UnInitScanLib(); 

#if defined __cplusplus || defined c_plusplus 
}; 
#endif 

#endif /* SLIBEXP_H */ 

コンソール出力で参照される他の2つの方法は、同じフォルダ(プロジェクトのルートディレクトリ)にある他のヘッダーファイルで定義されています。これらは次のように定義されています:

IMAGE_EXPORT short InitImageLib(const char *licanse); 
extern "C" BIZ_EXPORT short InitBizLib(const char *license); 

これらの.dllをリンクする必要がある別の場所はありますか?私はLoadLibrary()メソッドを使用しようとしましたが、そのメソッドはスコープの一部ではないため拒否されます。どのようにこれらのDLLにリンクする必要がありますか?あなたが提供する可能性のある任意の方向性に感謝します。あなたが表示され、出力を見てみると

答えて

1

、これは、関連するコマンドです:

g++ -LC:\Program Files\Card Scanning Solutions\SDK -lm -o HelloWorld.exe src\HelloWorld.o src\BizScan.o 

それは、ライブラリへのパスが含まれていますが、実際のライブラリ自体ROの参照はありません。私はライブラリの名前が何であるか分かりませんが、libBizLib.aと仮定しましょう。そのコマンドの最後に-lBizLibがあるはずです。またはDLLとリンクする場合は、フルネーム(-lなし)を使用できます。

は(ところで、あなたはライブラリの.libファイル拡張子を言及する。これは通常、Visual Studioのライブラリを示しています。あなたが持っているバージョンは、MinGWのと互換性がありますか?)あなたの提案のための

+0

感謝を。それは、最終的には、Visual Studioでコンパイルされたライブラリの結果であった。 – OnesAndZeros

関連する問題