Windows环境下使用nmake编译GitHub程序出现LNK2019未解析外部符号错误的解决方法求助
Hey there, let's break down what's going on here and fix those linking errors you're seeing. Those LNK2019 and LNK1120 messages boil down to one core issue: your linker can't find the actual code implementations for the zs_* functions (zs_init, zs_free, etc.) that your program is trying to use.
Looking at the link command that failed:
link.exe /nologo /out:..\mseed2ascii.exe ..\libmseed\libmseed.lib mseed2ascii.obj
You're only linking against libmseed.lib, but the zs_* functions live in a separate library—most likely libslink.lib, another key dependency for the mseed2ascii tool. Here's how to fix this step by step:
Step 1: Compile the missing dependency library
First, check if there's a libslink directory in your project (usually alongside the libmseed folder). If it exists, navigate to that directory in your Developer Command Prompt and run:
nmake -f Makefile.win
This will compile the libslink.lib file that contains all the missing zs_* function implementations.
Step 2: Update the Makefile to include the missing library
Open up Makefile.win for mseed2ascii, find the line that runs the link.exe command, and add the path to libslink.lib right after libmseed.lib. For example, if libslink.lib is located in ..\libslink\, your updated link command should look like:
link.exe /nologo /out:..\mseed2ascii.exe ..\libmseed\libmseed.lib ..\libslink\libslink.lib mseed2ascii.obj
Step 3: Automate dependency builds (optional but recommended)
To make sure nmake builds the required libraries before mseed2ascii, you can add a dependency rule to the Makefile. Look for the target that builds mseed2ascii.exe and add ..\libslink\libslink.lib as a prerequisite. For example:
..\mseed2ascii.exe: mseed2ascii.obj ..\libmseed\libmseed.lib ..\libslink\libslink.lib link.exe /nologo /out:$@ ..\libmseed\libmseed.lib ..\libslink\libslink.lib mseed2ascii.obj
Now when you run nmake -f Makefile.win, it will automatically build both dependent libraries first before linking your executable.
Once you've made these changes, re-run the nmake command, and those linking errors should disappear—your mseed2ascii.exe should compile successfully!
内容的提问来源于stack exchange,提问作者Eva Cerviño Luridiana

