被标记为重复的文章无济于事,因为它解决了一般的链接程序问题,但没有解决特定的链接器问题。
我试图将我使用Boost,SQLite和GTK + 3为Linux编写的一个小型C ++程序移植到Windows。该代码可以很好地编译,但是遇到了我似乎无法解决的链接问题。我对C ++领域比较陌生,因此希望该问题很容易解决。在过去的两天里,我已经在互联网上进行搜索,但是没有找到任何有用的信息,所以我现在在这里询问。
在Linux上,我使用的是g ++,因此我在Windows 10上使用msys2设置了mingw。在msys2中使用pacman安装了必需的库:
pacman -S base-devel mingw-w64-x86_64-gcc-libs mingw-w64-x86_64-gtk3 mingw-w64-x86_64-pkg-config mingw-w64-x86_64-sqlite3 mingw-w64-x86_64-boost
我用来链接的命令是:
g++ \
-Wall -g -std=c++11 -no-pie \
-o bin/developersnotebook.exe \
-lsqlite3 -lboost_system-mt -lboost_filesystem-mt \
`pkg-config --libs gtk+-3.0` \
build/components/Modal.o build/db/SqliteConnectionManager.o [...]
链接libsqlite3,libboost_system-mt和libboost_filesystem-mt没问题,但是我仍然遇到以下错误:
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot find -ldwmapi
我试图在路径dwmapi.dll中包含路径C:\ Windows \ SysWOW64,
g++ \
-Wall -g -std=c++11 -no-pie \
-o bin/developersnotebook.exe \
-lsqlite3 -lboost_system-mt -lboost_filesystem-mt -L"C:\Windows\SysWOW64" \
`pkg-config --libs gtk+-3.0` \
build/components/Modal.o build/db/SqliteConnectionManager.o [...]
但是只会产生更多错误:
Warning: resolving _SetUnhandledExceptionFilter@4 by linking to _SetUnhandledExceptionFilter
Use --enable-stdcall-fixup to disable these warnings
Use --disable-stdcall-fixup to disable these fixups
Warning: resolving _ExitProcess@4 by linking to _ExitProcess
Warning: resolving _GetModuleHandleA@4 by linking to _GetModuleHandleA
Warning: resolving _GetProcAddress@8 by linking to _GetProcAddress
Warning: resolving _FreeLibrary@4 by linking to _FreeLibrary
Warning: resolving _GetCommandLineA@0 by linking to _GetCommandLineA
Warning: resolving _EnterCriticalSection@4 by linking to _EnterCriticalSection
Warning: resolving _TlsGetValue@4 by linking to _TlsGetValue
Warning: resolving _GetLastError@0 by linking to _GetLastError
Warning: resolving _LeaveCriticalSection@4 by linking to _LeaveCriticalSection
Warning: resolving _DeleteCriticalSection@4 by linking to _DeleteCriticalSection
Warning: resolving _VirtualQuery@12 by linking to _VirtualQuery
Warning: resolving _VirtualProtect@16 by linking to _VirtualProtect
Warning: resolving _FindFirstFileA@8 by linking to _FindFirstFileA
Warning: resolving _FindNextFileA@8 by linking to _FindNextFileA
Warning: resolving _FindClose@4 by linking to _FindClose
Warning: resolving _IsDBCSLeadByteEx@8 by linking to _IsDBCSLeadByteEx
Warning: resolving _MultiByteToWideChar@24 by linking to _MultiByteToWideChar
Warning: resolving _WideCharToMultiByte@32 by linking to _WideCharToMultiByte
Warning: resolving _Sleep@4 by linking to _Sleep
Warning: resolving _InterlockedExchange@8 by linking to _InterlockedExchange
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/crtbegin.o:cygming-crtbegin.c:(.text+0x29): undefined reference to `LoadLibraryA@4'
加上GTK +,Boost和SQLite的“未定义引用”错误。
我对如何解决这个问题有些迷惑。我过去2天一直在努力,却没有取得任何进展...有人有任何想法吗?鉴于互联网上缺乏相关信息,我认为这不是菜鸟问题,还是很少见。
提前谢谢!
该项目位于Github上:https://github.com/eiskalteschatten/developersnotebook