我正在尝试使用Libnoise库,但不断出现此错误:

F:\PortableApps\Documents\Adventure³>g++ Compiled/*.o -o Adventure3 -L./Libs -static -lglew32 -lglfw3dll -lopengl32 -lfreetype -lnoise -static-libgcc-static-libstdc++ Resources/icon.res
f:/portableapps/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../../mingw32/bin/ld.exe: cannot find -lnoise
collect2.exe: error: ld returned 1 exit status


我的libnoise.lib文件夹中有Libs。我尝试使用-llibnoise代替,我得到:

F:\PortableApps\Documents\Adventure³>g++ Compiled/*.o -o Adventure3  -L./Libs -static -lglew32 -lglfw3dll -lopengl32 -lfreetype -llibnoise -static-libgcc -static-libstdc++ Resources/icon.res
Compiled/Generator.o:Generator.cpp:(.text+0x3d): undefined reference to `noise::module::Perlin::GetValue(double, double, double) const'
Compiled/Generator.o:Generator.cpp:(.text+0x8a): undefined reference to `noise::module::Perlin::Perlin()'
Compiled/Generator.o:Generator.cpp:(.text$_ZN5noise6module6PerlinD1Ev[__ZN5noise6module6PerlinD1Ev]+0xa): undefined reference to `vtable for noise::module::Perlin'
Compiled/Generator.o:Generator.cpp:(.text$_ZN5noise6module6PerlinD1Ev[__ZN5noise6module6PerlinD1Ev]+0x19): undefined reference to `noise::module::Module::~Module()'
collect2.exe: error: ld returned 1 exit status


我不知道如何手动编译源代码,无论我尝试使用什么WinMain@16方式,它总是会返回make错误。

现在,我真的不知道该怎么办...

有人有解决办法吗?

最佳答案

gcc的-l选项假定库的名称以lib开头,因此-lnoise会链接libn​​oise。

通常.lib是n导入库或静态库。与导入库有关的问题在这里描述:How do import libraries work and why doesn't MinGW need them?

关于libnoise:Netbeans C++ using MinGW and the libnoise library

10-08 14:07