-1

I am getting linker failures under MinGW, however I cannot see why. This is the link command:

g++ -shared -mthreads -Wl,--out-implib,C:\Users\camm\Syren\libs\libSy_polyMesh.a -o C:\Users\camm\Syren\libs\Sy_polyMesh.dll debug/Sy_polyMesh.o debug/moc_Sy_polyMesh.o debug/qrc_Sy_polyMesh.o -L"c:\Qt\4.8.4\lib" -lglu32 -lopengl32 -lgdi32 -luser32 -LC:\Users\camm\Syren/libs -lSyren -lglew32 -lboost_system -lQtSvgd4 -lQtSqld4 -lQtOpenGLd4 -lQtGuid4 -lQtCored4

The undefined reference errors come from the Syren dll (I should state the command was automatically generated by qmake). The -LC:\Users\camm\Syren/libs looks malformed to me because of the mix of forward and backslashes, but if I manually set them to all one way or the other - it does not change the compiler output.

I had earlier problems with 3rd party libraries I needed (GLEW and Boost specifically), but because they were relatively 'constant' I didn't have a problem putting them in my C:\MinGW\lib directory. But that is really not an option for my plugins.

What I find is that the MinGW docs state in a few locations:

...since suitable search paths may always be specified using -L options.

...but that GCC itself furnishes the effective defaults, by supplying appropriate -L options.

However, C:\Users\camm\Syren\libs is where Syren.dll resides!

Edit: Here are the LIBS declarations in my .pro file:

LIBS += -L$(SYREN_PATH)/libs \
    -lSyren
win32 {
    LIBS += -lglew32 \
            -lboost_system
}

And $(SYREN_PATH) expands to C:\Users\camm\Syren. Also I can see to the 'missing' symbols in Syren.dll, for example:

C:\Users\camm\Documents\Syren\Sy_polyMesh_debug/../Sy_polyMesh/src/Sy_polyMesh.cpp:341: undefined reference to `Sy_GLBuffer::unbind()'

Can be seen listed as:

6c500bd6 T _ZN11Sy_GLBuffer6unbindEv

Edit2

After adding a verbose flag to the linker stage I noticed that the linker was iterating through each search path and then through each library naming convention, and using the first one it could open.

attempt to open C:\Users\camm\Syren/libs/libSyren.dll.a failed
attempt to open C:\Users\camm\Syren/libs/Syren.dll.a failed
attempt to open C:\Users\camm\Syren/libs/libSyren.a succeeded

Hypothesizing that the libSyren.a may be broken, I renamed it to force the linker to use the .dll:

attempt to open C:\Users\camm\Syren/libs/libSyren.dll.a failed
attempt to open C:\Users\camm\Syren/libs/Syren.dll.a failed
attempt to open C:\Users\camm\Syren/libs/libSyren.a failed
attempt to open C:\Users\camm\Syren/libs/Syren.lib failed
attempt to open C:\Users\camm\Syren/libs/libSyren.dll failed
attempt to open C:\Users\camm\Syren/libs/Syren.dll succeeded

But I still get exactly the same error messages!

4

3 に答える 3

2

適切な DLL をリンクしていて、リンカがファイルの欠落について不平を言っていない場合は、DLL がリンクを許可するためのエクスポートを欠いている可能性があります。

MinGW リンカーは、シンボルを適切にエクスポートする場合、DLL に直接リンクできますが、lib*.aまたはという名前のインポート ライブラリ (qmake ビルドで作成する必要がある) にリンクすることをお勧めしlib*.dll.aます。リンカーはlibプレフィックスの有無にかかわらずバリアントを検索すると思いますが、確信が持てず、これを自分でテストする必要があります。

objdumpおよび/またはを使用して、DLL がエクスポートするシンボルを確認できますnm

于 2012-12-19T12:29:26.340 に答える
1

リンカがロードできないことについて文句を言わない場合Syren dll、それはファイルが正しくロードされていることを意味します...シンボルがSyren dll(エクスポートされていませんか?)...

Syren lib をビルドしたとき、プロトタイプが見つからないという警告はありましたか? Syren lib で使用されるものは何ですか?移植性がなく、Windows dll が必要なものはありませんか? 不足しているシンボルのリストを教えてください。

編集:どのようにコンパイルしSyren.dllますか?あなたはMingwを使いましたか?コンパイラ/リンカーに渡したオプションは何ですか? これらの2つのリンクを読むことをお勧めします:

C++ 関数をエクスポートする場合は、プログラムと DLL の間で同じコンパイラを使用する必要があります。または、C スタイルのラッパー関数を使用して C++ ABI をカプセル化することもできます。

この主題に関する非常に良い記事: http://www.codeproject.com/Articles/28969/HowTo-Export-C-classes-from-a-DLL

于 2012-12-19T12:49:15.197 に答える
0

に置き換える$(SYREN_PATH)とどうなり$${SYREN_PATH}ますか?前者の表記はMakefile 実行時$()の環境変数の内容を意味するためです。

qmake 変数リファレンスを参照してください。

于 2012-12-19T10:50:56.003 に答える