Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我尝试将我的 .C 编译为 png 时,我需要帮助
gcc --std=c99 -Wall -lz a.c -o a.png c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lz collect2.exe: error: ld returned 1 exit status
这是什么意思?
从错误消息中,链接器说它找不到libz.so或libz.a。如果您从自己的路径提供该库,请告诉链接器它必须在您的路径中搜索,通过
libz.so
libz.a
gcc --std=c99 -Wall -Ldir -lz a.c -o a.png
利用
ld -lz --verbose
查看链接器在哪里搜索了 libz。