我的头痛很大,在MSYS2 Mingw中链接静态libcurl。
我安装了libcurl和所有列出的依赖关系,
由于我将CodeBlocks用作IDE,因此我需要以lib#?世界和GCC工具和命令行,否则我不会使用IDE!
我也不足以编译Lib包装。我只需要编写一些便携式代码即可在CPP中执行HTTPS POST请求,因此我需要Libcurl。
您能告诉我一个需要与之链接的所有所需液体的完整列表吗?我尽了最大的努力,但是在检查了libcurl的包装config of of libcurl所说的内容后,我一直在获得无穷无尽的符号
更新
,我已经安装了所有缺少的libs并使用了以下命令行:
g ++。exe-o myProg.exe obj \ obj \ \ \ \ \ \ \ \ \ \ Release\main.o -static-libstdc++ -static-libgcc -static -m64 -lcurl -lnghttp2 -lidn2 -lssh2 -lpsl -ladvapi32 -lcrypt32 -lssl -lcrypto -lssl -lcrypto -lgdi32 -lwldap32 -lzstd -lbrotlidec -lz - lws2_32 -s
尽管我仍在获得大量未定义的参考文献:
d:/msys64/mingw64/bin /../ lib/gcc/x86_64-w64-w64-mingw32/10.2.0 /../../../../。 ./x86_64-W64-MingW32/bin/ld.exe:d:/msys64/mingw64/bin /../ lib/gcc/x86_64-w64-w64-mingw32/10.2.0 /../../../../。 ):未定义的引用`gsasl_init'
:(.Text+0x14
./x86_64-w64-mingw32/lib/../lib \ libcurl.a(gsasl.o : :/msys64/mingw64/bin /../ lib/gcc/x86_64-w64-w64-mingw32/10.2.0 /../../../../../ x86_64-w64-w64-mingw32/bin/ld.exe:d :/msys64/mingw64/bin /../ lib/gcc/x86_64-w64-w64-mingw32/10.2.0 /../../../../../../ lib \ lib \ libbrotlidec.a(decode.co):(。文本+0x2D28):未定义的引用`brotlitransformdictionaryword'
[加上许多其他“ brotli ...'参考)
I am having some big headaches linking statically libcurl in MSYS2 mingw.
I installed libcurl and all the listed dependencies from here
https://packages.msys2.org/package/mingw-w64-x86_64-curl
Since I am using CodeBlocks as IDE I need to supply a whole list of libs in form of lib#?.a, please keep in mind that I know nothing of Linux world and gcc tools and command line, otherwise I wouldn't be using an IDE!
Also I am not skilled enough to compile lib packages. I just need to write some portable code to do a https post request in cpp, so I need libcurl.
Can you tell me a complete list of all the needed libs to link against ? I tried all my best but I keep getting an infinity of unresolved symbols
UPDATE
After having checked what the package config for libcurl says, I have installed all the missing libs and used the following command line:
g++.exe -o MyProg.exe obj\Release\main.o -static-libstdc++ -static-libgcc -static -m64 -lcurl -lnghttp2 -lidn2 -lssh2 -lpsl -ladvapi32 -lcrypt32 -lssl -lcrypto -lssl -lcrypto -lgdi32 -lwldap32 -lzstd -lbrotlidec -lz -lws2_32 -s
Despite that I am still getting tons of undefined references:
d:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: d:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/lib/../lib\libcurl.a(gsasl.o):(.text+0x14): undefined reference to `gsasl_init'
[plus many other 'gsasl...' referrences]
d:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: d:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../../../lib\libbrotlidec.a(decode.c.o):(.text+0x2d28): undefined reference to `BrotliTransformDictionaryWord'
[plus many other 'brotli...' references]
发布评论
评论(1)
pkg-config
将告诉您必要的标志。从软件包mingw-w64-x86_64-pkg-config
安装它。将其运行为
pkg-config -libs-static libcurl
。将输出复制到“链接标志 - >其他”中。 For me the output is
-L/mingw64/lib -lcurl -lnghttp2 -lidn2 -lssh2 -lpsl -ladvapi32 -lcrypt32 -lssl -lcrypto -lssl -lcrypto -lgdi32 -lwldap32 -lzstd -lbrotlidec -lz -lws2_32。如果您还没有这样做,请不要忘记添加
- 静态
标志。pkg-config
will tell you the necessary flags. Install it from the packagemingw-w64-x86_64-pkg-config
.Run it as
pkg-config --libs --static libcurl
.Copy the output into "linker flags -> other". For me the output is
-L/mingw64/lib -lcurl -lnghttp2 -lidn2 -lssh2 -lpsl -ladvapi32 -lcrypt32 -lssl -lcrypto -lssl -lcrypto -lgdi32 -lwldap32 -lzstd -lbrotlidec -lz -lws2_32
. Don't forget to add the--static
flag, if you're not already doing so.