2

この他のプロジェクトをビルドすると、ロギングプロジェクトに依存するプロジェクトがあり、次のリンカーエラーが発生します。

ロギングプロジェクトはうまく構築されますが、このプロジェクト内のロギングプロジェクトをリンカーオプションのライブラリとして使用すると、次のエラーが発生します。ロギングプロジェクトには、wxRegKeyが定義されているlogger.cppがあります。

../logging/dist/Debug/MinGW_1-Windows/liblogging.a(Logger.o): In function `ZN7Logging6Logger17CreateRegistryKeyEv':
c:\logging/impl/Logger.cpp:125: undefined reference to `_imp___ZN8wxRegKeyC1ENS_6StdKeyERK8wxString'
c:\logging/impl/Logger.cpp:127: undefined reference to `_imp___ZN8wxRegKeyC1ENS_6StdKeyERK8wxString'
c:\logging/impl/Logger.cpp:129: undefined reference to `_imp___ZNK8wxRegKey6ExistsEv'
c:\logging/impl/Logger.cpp:135: undefined reference to `_imp___ZN8wxRegKeyD1Ev'
c:\logging/impl/Logger.cpp:140: undefined reference to `_imp___ZN8wxRegKeyC1ENS_6StdKeyERK8wxString'
c:\logging/impl/Logger.cpp:142: undefined reference to `_imp___ZNK8wxRegKey6ExistsEv'
c:\logging/impl/Logger.cpp:143: undefined reference to `_imp___ZN8wxRegKey6CreateEb'
c:\logging/impl/Logger.cpp:149: undefined reference to `_imp___ZNK8wxRegKey6ExistsEv'
c:\logging/impl/Logger.cpp:152: undefined reference to `_imp___ZN8wxRegKeyD1Ev'
c:\logging/impl/Logger.cpp:155: undefined reference to `_imp___ZN8wxRegKeyC1ENS_6StdKeyERK8wxString'
c:\logging/impl/Logger.cpp:156: undefined reference to `_imp___ZNK8wxRegKey6ExistsEv'
c:\logging/impl/Logger.cpp:157: undefined reference to `_imp___ZN8wxRegKey6CreateEb'
../logging/dist/Debug/MinGW_1-Windows/liblogging.a(Logger.o): In function 
`ZN7Logging6Logger13GetLoggStatusEv':
c:\logging/impl/Logger.cpp:169: undefined reference to     
`_imp___ZNK8wxRegKey8HasValueEPKc'
c:\logging/impl/Logger.cpp:170: undefined reference to 
`_imp___ZNK8wxRegKey10QueryValueEPKcPl'
c:\logging/impl/Logger.cpp:176: undefined reference to 
`_imp___ZN8wxRegKey8SetValueEPKcl'


../logging/dist/Debug/MinGW_1-Windows/liblogging.a(Logger.o): In function  
`ZN7Logging6Logger12SetLoggLevelEv':
c:\logging/impl/Logger.cpp:186: undefined reference to    
`_imp___ZNK8wxRegKey8HasValueEPKc'
 c:\logging/impl/Logger.cpp:193: undefined reference to 
`_imp___ZN8wxRegKey8SetValueEPKcRK8wxString'
c:\logging/impl/Logger.cpp:200: undefined reference to `_imp__wxConvUTF8'
../logging/dist/Debug/MinGW_1-Windows/liblogging.a(Logger.o): In function 
`ZN12wxStringBase4InitEv':
C:/wxWidgets-2.8.12/include/wx/string.h:270: undefined reference to   
`_imp__wxEmptyString'
../logging/dist/Debug/MinGW_1-Windows/liblogging.a(Logger.o): In function `wxStringBase':
C:/wxWidgets-2.8.12/include/wx/string.h:368: undefined reference to   
`_imp___ZN12wxStringBase4nposE'
C:/wxWidgets-2.8.12/include/wx/string.h:368: undefined reference to 
`_imp___ZN12wxStringBase8InitWithEPKcjj'
../logging/dist/Debug/MinGW_1-Windows/liblogging.a(Logger.o): In function 
 `ZNK8wxRegKey10QueryValueEPKcR8wxString':
C:/wxWidgets-2.8.12/include/wx/msw/registry.h:167: undefined reference to    
`_imp___ZNK8wxRegKey10QueryValueEPKcR8wxStringb'
collect2: ld returned 1 exit status
make[2]: *** [dist/Debug/MinGW_1-Windows/abcproject.dll] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
make[2]: Leaving directory `/c/abcproject'
make[1]: Leaving directory `/c/abcproject'


 BUILD FAILED (exit value 2, total time: 34s)

logger.hのインクルードファイルの順序

 #include <vector>
 #include <sstream>
 #include <string>
 #include <ctime>
 #include <windows.h>
 #include <winbase.h>
 #include <wx/wx.h>
 #include <wx/thread.h>
 #include <wx/log.h>
 #include <wx/app.h>
 #include <wx/msw/registry.h>
 #include <wx/utils.h>
 #include <map>

助けてください

4

3 に答える 3

8

wxRegKeyクラスのいくつかの関数を定義するライブラリを含めることを明らかに怠っています。それがリンカーが見つけられないと言っていることです。logger.cppが定義wxRegKey ているメソッドとそのすべてのメソッドを確認してください。

これは実際には外部ライブラリのクラスであるため、ソースコードは実際には関連するものを何も定義していないと思います。そのクラスを定義するwxRegKeyのではなく、そのクラスが宣言されているヘッダーファイルをインクルードしました。定義は外部ファイルにあり、ビルドシステムにどのファイルであるかを伝える必要があります。

コンパイルエラーではなくリンクエラーがあるため、ステートメントの順序は関係ありません。ここで報告しているエラーが表示されるまでに、コンパイラはすでにすべてのコンパイルを完了しています。コンパイラはテキストソースコードをバイナリオブジェクトコードに変換し、リンカはすべてのバイナリファイルをまとめて最終的な実行可能プログラムを形成しようとしています。バイナリファイルは、コンパイラが別の場所で定義されると言われたいくつかの関数を参照し、リンカはそれらの定義を見つけようとしますが、それはできません。#include

関数がどこで定義されているか、またはビルドシステムに関数の場所を指示する方法がわからない場合は、別の質問を投稿する必要があります。wxRegKeyを使用するには何にリンクする必要がありますか?NetBeansプロジェクトでwxWidgetsとリンクするにはどうすればよいですか?私はそれらのツールを使ったことがないので、それらの質問に対する答えはわかりません。

于 2012-08-17T13:00:41.267 に答える
0

-symbolswxBaseでさえ解決されないため、リンカーコマンドラインにライブラリを追加するのを忘れているようです。wxString

于 2012-08-17T13:16:13.240 に答える
0

を使用しているようですwxwidgets。最終的な実行可能ファイルをリンクしているときに、ライブラリを正しくリンクしていることを確認しますか?リンカに渡されたコマンドを確認してください。

于 2012-08-17T13:02:56.757 に答える